Browse Source

New UI Work

Josh Engebretson 10 years ago
parent
commit
19ed80c490

+ 1 - 1
Source/Atomic/Engine/Engine.cpp

@@ -683,7 +683,7 @@ void Engine::Render()
     GetSubsystem<Renderer>()->Render();
     GetSubsystem<Renderer>()->Render();
 
 
 #ifdef ATOMIC_TBUI
 #ifdef ATOMIC_TBUI
-    //GetSubsystem<TBUI>()->Render();
+    GetSubsystem<TBUI>()->Render();
 #endif
 #endif
 
 
     graphics->EndFrame();
     graphics->EndFrame();

+ 20 - 33
Source/Atomic/UI/TBUI.cpp

@@ -18,14 +18,8 @@
 
 
 #include <TurboBadger/tb_core.h>
 #include <TurboBadger/tb_core.h>
 #include <TurboBadger/tb_system.h>
 #include <TurboBadger/tb_system.h>
-#include <TurboBadger/tb_debug.h>
-#include <TurboBadger/animation/tb_widget_animation.h>
-#include <TurboBadger/renderers/tb_renderer_batcher.h>
-#include <TurboBadger/tb_font_renderer.h>
-#include <TurboBadger/tb_node_tree.h>
-#include <TurboBadger/tb_widgets_reader.h>
-#include <TurboBadger/tb_window.h>
 
 
+#include "UIView.h"
 
 
 using namespace tb;
 using namespace tb;
 
 
@@ -43,52 +37,45 @@ namespace Atomic
 {
 {
 
 
 TBUI::TBUI(Context* context) :
 TBUI::TBUI(Context* context) :
-    Object(context),
-    rootWidget_(0),
-    initialized_(false),
-    shuttingDown_(false)
+    Object(context)
 {
 {
-//    /SubscribeToEvent(E_SCREENMODE, HANDLER(TBUI, HandleScreenMode));
+
 }
 }
 
 
 TBUI::~TBUI()
 TBUI::~TBUI()
 {
 {
-    if (initialized_)
-    {
-        tb::TBWidgetsAnimationManager::Shutdown();
-        delete rootWidget_;
-        // leak
-        //delete TBUIRenderer::renderer_;
-        tb_core_shutdown();
-    }
-}
 
 
+}
 
 
-void TBUI::Shutdown()
+void TBUI::Render()
 {
 {
-    shuttingDown_ = true;
-    //SetInputDisabled(true);
+    theView_->Render();
 }
 }
 
 
+tb::TBWidget* TBUI::GetRootWidget()
+{
+    return theView_->GetRootWidget();
+}
 
 
-void TBUI::Initialize()
+bool TBUI::LoadResourceFile(tb::TBWidget* widget, const String& filename)
 {
 {
+    return theView_->LoadResourceFile(widget, filename);
+}
 
 
+void TBUI::Shutdown()
+{
+    theView_->SetInputDisabled(true);
+    theView_ = 0;
 }
 }
 
 
 
 
-bool TBUI::LoadResourceFile(TBWidget* widget, const String& filename)
+void TBUI::Initialize()
 {
 {
+    theView_ = new UIView(context_);
 
 
-    tb::TBNode node;
+}
 
 
-    // TODO: use Urho resources
-    if (!node.ReadFile(filename.CString()))
-        return false;
 
 
-    tb::g_widgets_reader->LoadNodeTree(widget, &node);
-    return true;
-}
 
 
 
 
 
 

+ 5 - 10
Source/Atomic/UI/TBUI.h

@@ -3,8 +3,6 @@
 #ifdef ATOMIC_TBUI
 #ifdef ATOMIC_TBUI
 
 
 #include "../Core/Object.h"
 #include "../Core/Object.h"
-#include "../UI/UIBatch.h"
-
 namespace tb
 namespace tb
 {
 {
 
 
@@ -15,24 +13,20 @@ class TBWidget;
 namespace Atomic
 namespace Atomic
 {
 {
 
 
-class VertexBuffer;
+class UIView;
 
 
-/// %UI element which renders a 3D scene.
 class ATOMIC_API TBUI : public Object
 class ATOMIC_API TBUI : public Object
 {
 {
     OBJECT(TBUI)
     OBJECT(TBUI)
 
 
-    tb::TBWidget* rootWidget_;
-    bool initialized_;    
-
 public:
 public:
     /// Construct.
     /// Construct.
     TBUI(Context* context);
     TBUI(Context* context);
     /// Destruct.
     /// Destruct.
     virtual ~TBUI();
     virtual ~TBUI();
 
 
-    tb::TBWidget* GetRootWidget() { return rootWidget_; }
-
+    void Render();
+    tb::TBWidget* GetRootWidget();
     bool LoadResourceFile(tb::TBWidget* widget, const String& filename);
     bool LoadResourceFile(tb::TBWidget* widget, const String& filename);
 
 
     void Initialize();
     void Initialize();
@@ -41,7 +35,8 @@ public:
 
 
 private:
 private:
 
 
-    bool shuttingDown_;
+    SharedPtr<UIView> theView_;
+
 };
 };
 
 
 }
 }

+ 17 - 351
Source/Atomic/UI/UIView.cpp

@@ -46,10 +46,17 @@ UIView::UIView(Context* context) :
 
 
     vertexBuffer_ = new VertexBuffer(context_);
     vertexBuffer_ = new VertexBuffer(context_);
 
 
+    Initialize();
+
 }
 }
 
 
 UIView::~UIView()
 UIView::~UIView()
 {
 {
+    tb::TBWidgetsAnimationManager::Shutdown();
+    delete rootWidget_;
+    // leak
+    //delete TBUIRenderer::renderer_;
+    tb_core_shutdown();
 
 
 }
 }
 
 
@@ -235,7 +242,7 @@ void UIView::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexDat
     //if (!initialized_)
     //if (!initialized_)
     //    return;
     //    return;
 
 
-    // TBAnimationManager::Update();
+    TBAnimationManager::Update();
 
 
     rootWidget_->InvokeProcessStates();
     rootWidget_->InvokeProcessStates();
     rootWidget_->InvokeProcess();
     rootWidget_->InvokeProcess();
@@ -298,369 +305,28 @@ void UIView::TBFileReader(const char* filename, void** data, unsigned* length)
 
 
 }
 }
 
 
-void UIView::HandleScreenMode(StringHash eventType, VariantMap& eventData)
-{
-    using namespace ScreenMode;
-    rootWidget_->SetSize(eventData[P_WIDTH].GetInt(), eventData[P_HEIGHT].GetInt());
-    //SetSize(eventData[P_WIDTH].GetInt(), eventData[P_HEIGHT].GetInt());
-}
-
-static MODIFIER_KEYS GetModifierKeys(int qualifiers, bool superKey)
-{
-    MODIFIER_KEYS code = TB_MODIFIER_NONE;
-    if (qualifiers & QUAL_ALT)	code |= TB_ALT;
-    if (qualifiers & QUAL_CTRL)	code |= TB_CTRL;
-    if (qualifiers & QUAL_SHIFT)	code |= TB_SHIFT;
-    if (superKey)	code |= TB_SUPER;
-    return code;
-}
-
-
-// @return Return the upper case of a ascii charcter. Only for shortcut handling.
-static int toupr_ascii(int ascii)
-{
-    if (ascii >= 'a' && ascii <= 'z')
-        return ascii + 'A' - 'a';
-    return ascii;
-}
-
-void UIView::HandleMouseButtonDown(StringHash eventType, VariantMap& eventData)
-{
-    if (inputDisabled_)
-        return;
-
-    using namespace MouseButtonDown;
-    unsigned button = eventData[P_BUTTON].GetUInt();
-
-    IntVector2 pos;
-    pos = GetSubsystem<Input>()->GetMousePosition();
-
-    Input* input = GetSubsystem<Input>();
-    int qualifiers = input->GetQualifiers();
-
-#ifdef ATOMIC_PLATFORM_WINDOWS
-    bool superdown = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
-#else
-    bool superdown = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
-#endif
-
-    MODIFIER_KEYS mod = GetModifierKeys(qualifiers, superdown);
-
-
-    static double last_time = 0;
-    static int counter = 1;
-
-    Time* t = GetSubsystem<Time>();
-
-    double time = t->GetElapsedTime() * 1000;
-    if (time < last_time + 600)
-        counter++;
-    else
-        counter = 1;
-
-    last_time = time;
-    if (button == MOUSEB_RIGHT)
-        rootWidget_->InvokeRightPointerDown(pos.x_, pos.y_, counter, mod);
-    else
-        rootWidget_->InvokePointerDown(pos.x_, pos.y_, counter, mod, false);
-
-
-}
-
-
-void UIView::HandleMouseButtonUp(StringHash eventType, VariantMap& eventData)
-{
-    if (inputDisabled_)
-        return;
-
-    using namespace MouseButtonUp;
-    unsigned button = eventData[P_BUTTON].GetUInt();
-
-    IntVector2 pos;
-
-    Input* input = GetSubsystem<Input>();
-    pos = input->GetMousePosition();
-    int qualifiers = input->GetQualifiers();
-
-#ifdef ATOMIC_PLATFORM_WINDOWS
-    bool superdown = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
-#else
-    bool superdown = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
-#endif
-
-    MODIFIER_KEYS mod = GetModifierKeys(qualifiers, superdown);
-
-
-    if (button == MOUSEB_RIGHT)
-        rootWidget_->InvokeRightPointerUp(pos.x_, pos.y_, mod);
-    else
-        rootWidget_->InvokePointerUp(pos.x_, pos.y_, mod, false);
-}
-
-
-void UIView::HandleMouseMove(StringHash eventType, VariantMap& eventData)
-{
-    using namespace MouseMove;
-
-    if (inputDisabled_)
-        return;
-
-    int px = eventData[P_X].GetInt();
-    int py = eventData[P_Y].GetInt();
-
-    rootWidget_->InvokePointerMove(px, py, tb::TB_MODIFIER_NONE, false);
-
-}
-
-
-void UIView::HandleMouseWheel(StringHash eventType, VariantMap& eventData)
+bool UIView::LoadResourceFile(TBWidget* widget, const String& filename)
 {
 {
-    if (inputDisabled_)
-        return;
-
-    using namespace MouseWheel;
-
-    int delta = eventData[P_WHEEL].GetInt();
-
-    Input* input = GetSubsystem<Input>();
 
 
-    rootWidget_->InvokeWheel(input->GetMousePosition().x_, input->GetMousePosition().y_, 0, delta > 0 ? -1 : 1, tb::TB_MODIFIER_NONE);
+    tb::TBNode node;
 
 
-}
-
-static bool InvokeShortcut(int key, SPECIAL_KEY special_key, MODIFIER_KEYS modifierkeys, bool down)
-{
-#ifdef __APPLE__
-    bool shortcut_key = (modifierkeys & TB_SUPER) ? true : false;
-#else
-    bool shortcut_key = (modifierkeys & TB_CTRL) ? true : false;
-#endif
-    if (!TBWidget::focused_widget || !down || (!shortcut_key && special_key ==TB_KEY_UNDEFINED))
-        return false;
-    bool reverse_key = (modifierkeys & TB_SHIFT) ? true : false;
-    int upper_key = toupr_ascii(key);
-    TBID id;
-    if (upper_key == 'X')
-        id = TBIDC("cut");
-    else if (upper_key == 'C' || special_key == TB_KEY_INSERT)
-        id = TBIDC("copy");
-    else if (upper_key == 'V' || (special_key == TB_KEY_INSERT && reverse_key))
-        id = TBIDC("paste");
-    else if (upper_key == 'A')
-        id = TBIDC("selectall");
-    else if (upper_key == 'Z' || upper_key == 'Y')
-    {
-        bool undo = upper_key == 'Z';
-        if (reverse_key)
-            undo = !undo;
-        id = undo ? TBIDC("undo") : TBIDC("redo");
-    }
-    else if (upper_key == 'N')
-        id = TBIDC("new");
-    else if (upper_key == 'O')
-        id = TBIDC("open");
-    else if (upper_key == 'S')
-        id = TBIDC("save");
-    else if (upper_key == 'W')
-        id = TBIDC("close");
-    else if (upper_key == 'F')
-        id = TBIDC("find");
- #ifdef ATOMIC_PLATFORM_OSX
-    else if (upper_key == 'G' && (modifierkeys & TB_SHIFT))
-        id = TBIDC("findprev");
-    else if (upper_key == 'G')
-        id = TBIDC("findnext");
-#else
-    else if (special_key == TB_KEY_F3 && (modifierkeys & TB_SHIFT))
-        id = TBIDC("findprev");
-    else if (special_key == TB_KEY_F3)
-        id = TBIDC("findnext");
-
-#endif
-    else if (upper_key == 'P')
-        id = TBIDC("play");
-    else if (upper_key == 'I')
-        id = TBIDC("beautify");
-    else if (special_key == TB_KEY_PAGE_UP)
-        id = TBIDC("prev_doc");
-    else if (special_key == TB_KEY_PAGE_DOWN)
-        id = TBIDC("next_doc");
-    else
+    // TODO: use Urho resources
+    if (!node.ReadFile(filename.CString()))
         return false;
         return false;
 
 
-    TBWidgetEvent ev(EVENT_TYPE_SHORTCUT);
-    ev.modifierkeys = modifierkeys;
-    ev.ref_id = id;
-    return TBWidget::focused_widget->InvokeEvent(ev);
-}
-
-static bool InvokeKey(TBWidget* root, unsigned int key, SPECIAL_KEY special_key, MODIFIER_KEYS modifierkeys, bool keydown)
-{
-    if (InvokeShortcut(key, special_key, modifierkeys, keydown))
-        return true;
-    root->InvokeKey(key, special_key, modifierkeys, keydown);
+    tb::g_widgets_reader->LoadNodeTree(widget, &node);
     return true;
     return true;
 }
 }
 
 
 
 
-void UIView::HandleKey(bool keydown, int keycode, int scancode)
-{
-
-#ifdef ATOMIC_PLATFORM_WINDOWS
-    if (keycode == KEY_LCTRL || keycode == KEY_RCTRL)
-        return;
-#else
-    if (keycode == KEY_LGUI || keycode == KEY_RGUI)
-        return;
-#endif
-
-    Input* input = GetSubsystem<Input>();
-    int qualifiers = input->GetQualifiers();
-
-#ifdef ATOMIC_PLATFORM_WINDOWS
-    bool superdown = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
-#else
-    bool superdown = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
-#endif
-    MODIFIER_KEYS mod = GetModifierKeys(qualifiers, superdown);
-
-    switch (keycode)
-    {
-    case KEY_RETURN:
-    case KEY_RETURN2:
-    case KEY_KP_ENTER:
-        InvokeKey(rootWidget_, 0, TB_KEY_ENTER, mod, keydown);
-        break;
-
-    case KEY_F1:
-        InvokeKey(rootWidget_, 0, TB_KEY_F1, mod, keydown);
-        break;
-    case KEY_F2:
-        InvokeKey(rootWidget_, 0, TB_KEY_F2, mod, keydown);
-        break;
-    case KEY_F3:
-        InvokeKey(rootWidget_, 0, TB_KEY_F3, mod, keydown);
-        break;
-    case KEY_F4:
-        InvokeKey(rootWidget_, 0, TB_KEY_F4, mod, keydown);
-        break;
-    case KEY_F5:
-        InvokeKey(rootWidget_, 0, TB_KEY_F5, mod, keydown);
-        break;
-    case KEY_F6:
-        InvokeKey(rootWidget_, 0, TB_KEY_F6, mod, keydown);
-        break;
-    case KEY_F7:
-        InvokeKey(rootWidget_, 0, TB_KEY_F7, mod, keydown);
-        break;
-    case KEY_F8:
-        InvokeKey(rootWidget_, 0, TB_KEY_F8, mod, keydown);
-        break;
-    case KEY_F9:
-        InvokeKey(rootWidget_, 0, TB_KEY_F9, mod, keydown);
-        break;
-    case KEY_F10:
-        InvokeKey(rootWidget_, 0, TB_KEY_F10, mod, keydown);
-        break;
-    case KEY_F11:
-        InvokeKey(rootWidget_, 0, TB_KEY_F11, mod, keydown);
-        break;
-    case KEY_F12:
-        InvokeKey(rootWidget_, 0, TB_KEY_F12, mod, keydown);
-        break;
-    case KEY_LEFT:
-        InvokeKey(rootWidget_, 0, TB_KEY_LEFT, mod, keydown);
-        break;
-    case KEY_UP:
-        InvokeKey(rootWidget_, 0, TB_KEY_UP, mod, keydown);
-        break;
-    case KEY_RIGHT:
-        InvokeKey(rootWidget_, 0, TB_KEY_RIGHT, mod, keydown);
-        break;
-    case KEY_DOWN:
-        InvokeKey(rootWidget_, 0, TB_KEY_DOWN, mod, keydown);
-        break;
-    case KEY_PAGEUP:
-        InvokeKey(rootWidget_, 0, TB_KEY_PAGE_UP, mod, keydown);
-        break;
-    case KEY_PAGEDOWN:
-        InvokeKey(rootWidget_, 0, TB_KEY_PAGE_DOWN, mod, keydown);
-        break;
-    case KEY_HOME:
-        InvokeKey(rootWidget_, 0, TB_KEY_HOME, mod, keydown);
-        break;
-    case KEY_END:
-        InvokeKey(rootWidget_, 0, TB_KEY_END, mod, keydown);
-        break;
-    case KEY_INSERT:
-        InvokeKey(rootWidget_, 0, TB_KEY_INSERT, mod, keydown);
-        break;
-    case KEY_TAB:
-        InvokeKey(rootWidget_, 0, TB_KEY_TAB, mod, keydown);
-        break;
-    case KEY_DELETE:
-        InvokeKey(rootWidget_, 0, TB_KEY_DELETE, mod, keydown);
-        break;
-    case KEY_BACKSPACE:
-        InvokeKey(rootWidget_, 0, TB_KEY_BACKSPACE, mod, keydown);
-        break;
-    case KEY_ESC:
-        InvokeKey(rootWidget_, 0, TB_KEY_ESC, mod, keydown);
-        break;
-    default:
-        if (mod & TB_SUPER)
-        {
-            InvokeKey(rootWidget_, keycode, TB_KEY_UNDEFINED, mod, keydown);
-        }
-
-    }
-
-}
-
-void UIView::HandleKeyDown(StringHash eventType, VariantMap& eventData)
-{
-    if (inputDisabled_ || keyboardDisabled_)
-        return;
-
-    using namespace KeyDown;
-
-    int keycode = eventData[P_KEY].GetInt();
-    int scancode = eventData[P_SCANCODE].GetInt();
-
-    HandleKey(true, keycode, scancode);
-
-}
-
-void UIView::HandleKeyUp(StringHash eventType, VariantMap& eventData)
+void UIView::HandleScreenMode(StringHash eventType, VariantMap& eventData)
 {
 {
-    if (inputDisabled_ || keyboardDisabled_)
-        return;
-
-    using namespace KeyUp;
-
-    int keycode = eventData[P_KEY].GetInt();
-    int scancode = eventData[P_SCANCODE].GetInt();
-
-    HandleKey(false, keycode, scancode);
-
+    using namespace ScreenMode;
+    rootWidget_->SetSize(eventData[P_WIDTH].GetInt(), eventData[P_HEIGHT].GetInt());
+    //SetSize(eventData[P_WIDTH].GetInt(), eventData[P_HEIGHT].GetInt());
 }
 }
 
 
-void UIView::HandleTextInput(StringHash eventType, VariantMap& eventData)
-{
-    if (inputDisabled_ || keyboardDisabled_)
-        return;
 
 
-    using namespace TextInput;
-
-    const String& text = eventData[P_TEXT].GetString();
-
-    for (unsigned i = 0; i < text.Length(); i++)
-    {
-        InvokeKey(rootWidget_, text[i], TB_KEY_UNDEFINED, TB_MODIFIER_NONE, true);
-        InvokeKey(rootWidget_, text[i], TB_KEY_UNDEFINED, TB_MODIFIER_NONE, false);
-    }
-
-}
 
 
 void UIView::HandleUpdate(StringHash eventType, VariantMap& eventData)
 void UIView::HandleUpdate(StringHash eventType, VariantMap& eventData)
 {
 {

+ 3 - 0
Source/Atomic/UI/UIView.h

@@ -26,6 +26,9 @@ public:
     /// Destruct.
     /// Destruct.
     virtual ~UIView();
     virtual ~UIView();
 
 
+    tb::TBWidget* GetRootWidget() { return rootWidget_; }
+    bool LoadResourceFile(tb::TBWidget* widget, const String& filename);
+
     void SetKeyboardDisabled(bool disabled) {keyboardDisabled_ = disabled; }
     void SetKeyboardDisabled(bool disabled) {keyboardDisabled_ = disabled; }
     void SetInputDisabled(bool disabled) { inputDisabled_ = disabled; }
     void SetInputDisabled(bool disabled) { inputDisabled_ = disabled; }
 
 

+ 370 - 0
Source/Atomic/UI/UIViewInput.cpp

@@ -0,0 +1,370 @@
+#include <TurboBadger/tb_widgets.h>
+
+using namespace tb;
+
+#include "../Core/Timer.h"
+#include "../Input/Input.h"
+#include "../Input/InputEvents.h"
+
+#include "UIView.h"
+
+namespace Atomic
+{
+
+static MODIFIER_KEYS GetModifierKeys(int qualifiers, bool superKey)
+{
+    MODIFIER_KEYS code = TB_MODIFIER_NONE;
+    if (qualifiers & QUAL_ALT)	code |= TB_ALT;
+    if (qualifiers & QUAL_CTRL)	code |= TB_CTRL;
+    if (qualifiers & QUAL_SHIFT)	code |= TB_SHIFT;
+    if (superKey)	code |= TB_SUPER;
+    return code;
+}
+
+
+// @return Return the upper case of a ascii charcter. Only for shortcut handling.
+static int toupr_ascii(int ascii)
+{
+    if (ascii >= 'a' && ascii <= 'z')
+        return ascii + 'A' - 'a';
+    return ascii;
+}
+
+void UIView::HandleMouseButtonDown(StringHash eventType, VariantMap& eventData)
+{
+    if (inputDisabled_)
+        return;
+
+    using namespace MouseButtonDown;
+    unsigned button = eventData[P_BUTTON].GetUInt();
+
+    IntVector2 pos;
+    pos = GetSubsystem<Input>()->GetMousePosition();
+
+    Input* input = GetSubsystem<Input>();
+    int qualifiers = input->GetQualifiers();
+
+#ifdef ATOMIC_PLATFORM_WINDOWS
+    bool superdown = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
+#else
+    bool superdown = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
+#endif
+
+    MODIFIER_KEYS mod = GetModifierKeys(qualifiers, superdown);
+
+
+    static double last_time = 0;
+    static int counter = 1;
+
+    Time* t = GetSubsystem<Time>();
+
+    double time = t->GetElapsedTime() * 1000;
+    if (time < last_time + 600)
+        counter++;
+    else
+        counter = 1;
+
+    last_time = time;
+    if (button == MOUSEB_RIGHT)
+        rootWidget_->InvokeRightPointerDown(pos.x_, pos.y_, counter, mod);
+    else
+        rootWidget_->InvokePointerDown(pos.x_, pos.y_, counter, mod, false);
+
+
+}
+
+
+void UIView::HandleMouseButtonUp(StringHash eventType, VariantMap& eventData)
+{
+    if (inputDisabled_)
+        return;
+
+    using namespace MouseButtonUp;
+    unsigned button = eventData[P_BUTTON].GetUInt();
+
+    IntVector2 pos;
+
+    Input* input = GetSubsystem<Input>();
+    pos = input->GetMousePosition();
+    int qualifiers = input->GetQualifiers();
+
+#ifdef ATOMIC_PLATFORM_WINDOWS
+    bool superdown = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
+#else
+    bool superdown = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
+#endif
+
+    MODIFIER_KEYS mod = GetModifierKeys(qualifiers, superdown);
+
+
+    if (button == MOUSEB_RIGHT)
+        rootWidget_->InvokeRightPointerUp(pos.x_, pos.y_, mod);
+    else
+        rootWidget_->InvokePointerUp(pos.x_, pos.y_, mod, false);
+}
+
+
+void UIView::HandleMouseMove(StringHash eventType, VariantMap& eventData)
+{
+    using namespace MouseMove;
+
+    if (inputDisabled_)
+        return;
+
+    int px = eventData[P_X].GetInt();
+    int py = eventData[P_Y].GetInt();
+
+    rootWidget_->InvokePointerMove(px, py, tb::TB_MODIFIER_NONE, false);
+
+}
+
+
+void UIView::HandleMouseWheel(StringHash eventType, VariantMap& eventData)
+{
+    if (inputDisabled_)
+        return;
+
+    using namespace MouseWheel;
+
+    int delta = eventData[P_WHEEL].GetInt();
+
+    Input* input = GetSubsystem<Input>();
+
+    rootWidget_->InvokeWheel(input->GetMousePosition().x_, input->GetMousePosition().y_, 0, delta > 0 ? -1 : 1, tb::TB_MODIFIER_NONE);
+
+}
+
+static bool InvokeShortcut(int key, SPECIAL_KEY special_key, MODIFIER_KEYS modifierkeys, bool down)
+{
+#ifdef __APPLE__
+    bool shortcut_key = (modifierkeys & TB_SUPER) ? true : false;
+#else
+    bool shortcut_key = (modifierkeys & TB_CTRL) ? true : false;
+#endif
+    if (!TBWidget::focused_widget || !down || (!shortcut_key && special_key ==TB_KEY_UNDEFINED))
+        return false;
+    bool reverse_key = (modifierkeys & TB_SHIFT) ? true : false;
+    int upper_key = toupr_ascii(key);
+    TBID id;
+    if (upper_key == 'X')
+        id = TBIDC("cut");
+    else if (upper_key == 'C' || special_key == TB_KEY_INSERT)
+        id = TBIDC("copy");
+    else if (upper_key == 'V' || (special_key == TB_KEY_INSERT && reverse_key))
+        id = TBIDC("paste");
+    else if (upper_key == 'A')
+        id = TBIDC("selectall");
+    else if (upper_key == 'Z' || upper_key == 'Y')
+    {
+        bool undo = upper_key == 'Z';
+        if (reverse_key)
+            undo = !undo;
+        id = undo ? TBIDC("undo") : TBIDC("redo");
+    }
+    else if (upper_key == 'N')
+        id = TBIDC("new");
+    else if (upper_key == 'O')
+        id = TBIDC("open");
+    else if (upper_key == 'S')
+        id = TBIDC("save");
+    else if (upper_key == 'W')
+        id = TBIDC("close");
+    else if (upper_key == 'F')
+        id = TBIDC("find");
+ #ifdef ATOMIC_PLATFORM_OSX
+    else if (upper_key == 'G' && (modifierkeys & TB_SHIFT))
+        id = TBIDC("findprev");
+    else if (upper_key == 'G')
+        id = TBIDC("findnext");
+#else
+    else if (special_key == TB_KEY_F3 && (modifierkeys & TB_SHIFT))
+        id = TBIDC("findprev");
+    else if (special_key == TB_KEY_F3)
+        id = TBIDC("findnext");
+
+#endif
+    else if (upper_key == 'P')
+        id = TBIDC("play");
+    else if (upper_key == 'I')
+        id = TBIDC("beautify");
+    else if (special_key == TB_KEY_PAGE_UP)
+        id = TBIDC("prev_doc");
+    else if (special_key == TB_KEY_PAGE_DOWN)
+        id = TBIDC("next_doc");
+    else
+        return false;
+
+    TBWidgetEvent ev(EVENT_TYPE_SHORTCUT);
+    ev.modifierkeys = modifierkeys;
+    ev.ref_id = id;
+    return TBWidget::focused_widget->InvokeEvent(ev);
+}
+
+static bool InvokeKey(TBWidget* root, unsigned int key, SPECIAL_KEY special_key, MODIFIER_KEYS modifierkeys, bool keydown)
+{
+    if (InvokeShortcut(key, special_key, modifierkeys, keydown))
+        return true;
+    root->InvokeKey(key, special_key, modifierkeys, keydown);
+    return true;
+}
+
+
+void UIView::HandleKey(bool keydown, int keycode, int scancode)
+{
+
+#ifdef ATOMIC_PLATFORM_WINDOWS
+    if (keycode == KEY_LCTRL || keycode == KEY_RCTRL)
+        return;
+#else
+    if (keycode == KEY_LGUI || keycode == KEY_RGUI)
+        return;
+#endif
+
+    Input* input = GetSubsystem<Input>();
+    int qualifiers = input->GetQualifiers();
+
+#ifdef ATOMIC_PLATFORM_WINDOWS
+    bool superdown = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
+#else
+    bool superdown = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
+#endif
+    MODIFIER_KEYS mod = GetModifierKeys(qualifiers, superdown);
+
+    switch (keycode)
+    {
+    case KEY_RETURN:
+    case KEY_RETURN2:
+    case KEY_KP_ENTER:
+        InvokeKey(rootWidget_, 0, TB_KEY_ENTER, mod, keydown);
+        break;
+
+    case KEY_F1:
+        InvokeKey(rootWidget_, 0, TB_KEY_F1, mod, keydown);
+        break;
+    case KEY_F2:
+        InvokeKey(rootWidget_, 0, TB_KEY_F2, mod, keydown);
+        break;
+    case KEY_F3:
+        InvokeKey(rootWidget_, 0, TB_KEY_F3, mod, keydown);
+        break;
+    case KEY_F4:
+        InvokeKey(rootWidget_, 0, TB_KEY_F4, mod, keydown);
+        break;
+    case KEY_F5:
+        InvokeKey(rootWidget_, 0, TB_KEY_F5, mod, keydown);
+        break;
+    case KEY_F6:
+        InvokeKey(rootWidget_, 0, TB_KEY_F6, mod, keydown);
+        break;
+    case KEY_F7:
+        InvokeKey(rootWidget_, 0, TB_KEY_F7, mod, keydown);
+        break;
+    case KEY_F8:
+        InvokeKey(rootWidget_, 0, TB_KEY_F8, mod, keydown);
+        break;
+    case KEY_F9:
+        InvokeKey(rootWidget_, 0, TB_KEY_F9, mod, keydown);
+        break;
+    case KEY_F10:
+        InvokeKey(rootWidget_, 0, TB_KEY_F10, mod, keydown);
+        break;
+    case KEY_F11:
+        InvokeKey(rootWidget_, 0, TB_KEY_F11, mod, keydown);
+        break;
+    case KEY_F12:
+        InvokeKey(rootWidget_, 0, TB_KEY_F12, mod, keydown);
+        break;
+    case KEY_LEFT:
+        InvokeKey(rootWidget_, 0, TB_KEY_LEFT, mod, keydown);
+        break;
+    case KEY_UP:
+        InvokeKey(rootWidget_, 0, TB_KEY_UP, mod, keydown);
+        break;
+    case KEY_RIGHT:
+        InvokeKey(rootWidget_, 0, TB_KEY_RIGHT, mod, keydown);
+        break;
+    case KEY_DOWN:
+        InvokeKey(rootWidget_, 0, TB_KEY_DOWN, mod, keydown);
+        break;
+    case KEY_PAGEUP:
+        InvokeKey(rootWidget_, 0, TB_KEY_PAGE_UP, mod, keydown);
+        break;
+    case KEY_PAGEDOWN:
+        InvokeKey(rootWidget_, 0, TB_KEY_PAGE_DOWN, mod, keydown);
+        break;
+    case KEY_HOME:
+        InvokeKey(rootWidget_, 0, TB_KEY_HOME, mod, keydown);
+        break;
+    case KEY_END:
+        InvokeKey(rootWidget_, 0, TB_KEY_END, mod, keydown);
+        break;
+    case KEY_INSERT:
+        InvokeKey(rootWidget_, 0, TB_KEY_INSERT, mod, keydown);
+        break;
+    case KEY_TAB:
+        InvokeKey(rootWidget_, 0, TB_KEY_TAB, mod, keydown);
+        break;
+    case KEY_DELETE:
+        InvokeKey(rootWidget_, 0, TB_KEY_DELETE, mod, keydown);
+        break;
+    case KEY_BACKSPACE:
+        InvokeKey(rootWidget_, 0, TB_KEY_BACKSPACE, mod, keydown);
+        break;
+    case KEY_ESC:
+        InvokeKey(rootWidget_, 0, TB_KEY_ESC, mod, keydown);
+        break;
+    default:
+        if (mod & TB_SUPER)
+        {
+            InvokeKey(rootWidget_, keycode, TB_KEY_UNDEFINED, mod, keydown);
+        }
+
+    }
+
+}
+
+void UIView::HandleKeyDown(StringHash eventType, VariantMap& eventData)
+{
+    if (inputDisabled_ || keyboardDisabled_)
+        return;
+
+    using namespace KeyDown;
+
+    int keycode = eventData[P_KEY].GetInt();
+    int scancode = eventData[P_SCANCODE].GetInt();
+
+    HandleKey(true, keycode, scancode);
+
+}
+
+void UIView::HandleKeyUp(StringHash eventType, VariantMap& eventData)
+{
+    if (inputDisabled_ || keyboardDisabled_)
+        return;
+
+    using namespace KeyUp;
+
+    int keycode = eventData[P_KEY].GetInt();
+    int scancode = eventData[P_SCANCODE].GetInt();
+
+    HandleKey(false, keycode, scancode);
+
+}
+
+void UIView::HandleTextInput(StringHash eventType, VariantMap& eventData)
+{
+    if (inputDisabled_ || keyboardDisabled_)
+        return;
+
+    using namespace TextInput;
+
+    const String& text = eventData[P_TEXT].GetString();
+
+    for (unsigned i = 0; i < text.Length(); i++)
+    {
+        InvokeKey(rootWidget_, text[i], TB_KEY_UNDEFINED, TB_MODIFIER_NONE, true);
+        InvokeKey(rootWidget_, text[i], TB_KEY_UNDEFINED, TB_MODIFIER_NONE, false);
+    }
+
+}
+}

+ 0 - 3
Source/AtomicEditor/Source/AEApplication.cpp

@@ -82,10 +82,7 @@ void AEApplication::Start()
     TBUI* tbui = GetSubsystem<TBUI>();
     TBUI* tbui = GetSubsystem<TBUI>();
     tbui->Initialize();
     tbui->Initialize();
 
 
-    XMLFile* xmlFile = cache->GetResource<XMLFile>("UI/DefaultStyle.xml");
-
     Input* input = GetSubsystem<Input>();
     Input* input = GetSubsystem<Input>();
-
     input->SetMouseVisible(true);
     input->SetMouseVisible(true);
 
 
  #ifdef ATOMIC_PLATFORM_WINDOWS
  #ifdef ATOMIC_PLATFORM_WINDOWS

+ 1 - 1
Source/AtomicEditor/Source/UI/UIView3D.cpp

@@ -7,7 +7,7 @@
 #include "AtomicEditor.h"
 #include "AtomicEditor.h"
 
 
 
 
-#include <Atomic/UI/TBUI.h>
+#include <Atomic/UI/UIBatch.h>
 #include <Atomic/IO/Log.h>
 #include <Atomic/IO/Log.h>
 #include <Atomic/Engine/Engine.h>
 #include <Atomic/Engine/Engine.h>
 #include <Atomic/Graphics/Graphics.h>
 #include <Atomic/Graphics/Graphics.h>