forked from pioneerspacesim/pioneer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIView.cpp
37 lines (31 loc) · 906 Bytes
/
UIView.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright © 2008-2018 Pioneer Developers. See AUTHORS.txt for details
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
#include "UIView.h"
#include "Pi.h"
#include "ui/Context.h"
#include "gameui/Panel.h"
void UIView::OnSwitchTo()
{
UI::VBox *box = Pi::ui->VBox();
UI::Expand *expander = Pi::ui->Expand();
BuildUI(expander);
box->PackEnd(expander);
box->PackEnd(new GameUI::Panel(Pi::ui.Get()));
Pi::ui->DropAllLayers();
Pi::ui->GetTopLayer()->SetInnerWidget(box);
}
void UIView::OnSwitchFrom()
{
Pi::ui->DropAllLayers();
Pi::ui->Layout(); // UI does important things on layout, like updating keyboard shortcuts
}
void UIView::BuildUI(UI::Single *container) {
UI::Widget *w = BuildTemplateUI();
if (w) container->SetInnerWidget(w);
}
UI::Widget *UIView::BuildTemplateUI() {
if (m_templateName)
return Pi::ui->CallTemplate(m_templateName);
else
return nullptr;
}