mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-12 00:59:41 +01:00
UIScreen helper class, derive your newUI screens from this.
This commit is contained in:
1 parent
2b3e1355ad
commit
c87fe2f782
5 files changed
+70
No files matched your search
@@ -63,6 +63,7 @@ LOCAL_SRC_FILES :=\
|
||||
ui/view.cpp \
|
||||
ui/viewgroup.cpp \
|
||||
ui/ui.cpp \
|
||||
ui/ui_screen.cpp \
|
||||
ui/ui_context.cpp \
|
||||
ui/screen.cpp \
|
||||
ui/virtual_input.cpp \
|
||||
|
||||
@@ -244,6 +244,7 @@
|
||||
<ClInclude Include="ui\screen.h" />
|
||||
<ClInclude Include="ui\ui.h" />
|
||||
<ClInclude Include="ui\ui_context.h" />
|
||||
<ClInclude Include="ui\ui_screen.h" />
|
||||
<ClInclude Include="ui\view.h" />
|
||||
<ClInclude Include="ui\viewgroup.h" />
|
||||
<ClInclude Include="ui\virtual_input.h" />
|
||||
@@ -361,6 +362,7 @@
|
||||
<ClCompile Include="ui\screen.cpp" />
|
||||
<ClCompile Include="ui\ui.cpp" />
|
||||
<ClCompile Include="ui\ui_context.cpp" />
|
||||
<ClCompile Include="ui\ui_screen.cpp" />
|
||||
<ClCompile Include="ui\view.cpp" />
|
||||
<ClCompile Include="ui\viewgroup.cpp" />
|
||||
<ClCompile Include="ui\virtual_input.cpp" />
|
||||
|
||||
@@ -269,6 +269,9 @@
|
||||
<ClInclude Include="base\functional.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ui\ui_screen.h">
|
||||
<Filter>ui</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="gfx\gl_debug_log.cpp">
|
||||
@@ -474,6 +477,9 @@
|
||||
<ClCompile Include="net\url.cpp">
|
||||
<Filter>net</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ui\ui_screen.cpp">
|
||||
<Filter>ui</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="gfx">
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
#include "ui/ui_screen.h"
|
||||
#include "ui/ui_context.h"
|
||||
#include "ui/screen.h"
|
||||
|
||||
void UIScreen::update(InputState &input) {
|
||||
if (!root_) {
|
||||
CreateViews();
|
||||
}
|
||||
|
||||
if (orientationChanged_) {
|
||||
delete root_;
|
||||
root_ = 0;
|
||||
CreateViews();
|
||||
}
|
||||
|
||||
UpdateViewHierarchy(input, root_);
|
||||
}
|
||||
|
||||
void UIScreen::render() {
|
||||
UI::LayoutViewHierarchy(*screenManager()->getUIContext(), root_);
|
||||
|
||||
screenManager()->getUIContext()->Begin();
|
||||
DrawBackground();
|
||||
root_->Draw(*screenManager()->getUIContext());
|
||||
screenManager()->getUIContext()->End();
|
||||
screenManager()->getUIContext()->Flush();
|
||||
}
|
||||
|
||||
void UIScreen::touch(const TouchInput &touch) {
|
||||
root_->Touch(touch);
|
||||
}
|
||||
|
||||
UI::EventReturn UIScreen::OnBack(UI::EventParams &e) {
|
||||
screenManager()->finishDialog(this, DR_OK);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui/screen.h"
|
||||
#include "ui/viewgroup.h"
|
||||
|
||||
class UIScreen : public Screen {
|
||||
public:
|
||||
UIScreen() : Screen(), root_(0), orientationChanged_(false) {}
|
||||
~UIScreen() { delete root_; }
|
||||
|
||||
virtual void update(InputState &input);
|
||||
virtual void render();
|
||||
virtual void touch(const TouchInput &touch);
|
||||
|
||||
// Some useful default event handlers
|
||||
UI::EventReturn OnBack(UI::EventParams &e);
|
||||
|
||||
protected:
|
||||
virtual void CreateViews() = 0;
|
||||
virtual void DrawBackground() {}
|
||||
|
||||
UI::ViewGroup *root_;
|
||||
bool orientationChanged_;
|
||||
};
|
||||
Reference in new issue
Block a user