diff --git a/Android.mk b/Android.mk
index 680165f278..ced4092156 100644
--- a/Android.mk
+++ b/Android.mk
@@ -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 \
diff --git a/native.vcxproj b/native.vcxproj
index cd4dcc375c..bf22e8df3d 100644
--- a/native.vcxproj
+++ b/native.vcxproj
@@ -244,6 +244,7 @@
+
@@ -361,6 +362,7 @@
+
diff --git a/native.vcxproj.filters b/native.vcxproj.filters
index bb0c7d07c8..c6f8ae6f15 100644
--- a/native.vcxproj.filters
+++ b/native.vcxproj.filters
@@ -269,6 +269,9 @@
base
+
+ ui
+
@@ -474,6 +477,9 @@
net
+
+ ui
+
diff --git a/ui/ui_screen.cpp b/ui/ui_screen.cpp
new file mode 100644
index 0000000000..09fe04791b
--- /dev/null
+++ b/ui/ui_screen.cpp
@@ -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;
+}
diff --git a/ui/ui_screen.h b/ui/ui_screen.h
new file mode 100644
index 0000000000..e8111d3727
--- /dev/null
+++ b/ui/ui_screen.h
@@ -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_;
+};