Browse Source

New UI work

Josh Engebretson 10 years ago
parent
commit
b0e9a94380
56 changed files with 34 additions and 11474 deletions
  1. 4 6
      Source/Atomic/Engine/Console.cpp
  2. 4 0
      Source/Atomic/Engine/Console.h
  3. 4 2
      Source/Atomic/Engine/DebugHud.cpp
  4. 4 0
      Source/Atomic/Engine/DebugHud.h
  5. 7 0
      Source/Atomic/Engine/Engine.cpp
  6. 5 1
      Source/Atomic/Input/Input.cpp
  7. 0 187
      Source/Atomic/UI/Button.cpp
  8. 0 100
      Source/Atomic/UI/Button.h
  9. 0 111
      Source/Atomic/UI/CheckBox.cpp
  10. 0 69
      Source/Atomic/UI/CheckBox.h
  11. 0 342
      Source/Atomic/UI/DropDownList.cpp
  12. 0 118
      Source/Atomic/UI/DropDownList.h
  13. 0 492
      Source/Atomic/UI/FileSelector.cpp
  14. 0 179
      Source/Atomic/UI/FileSelector.h
  15. 0 231
      Source/Atomic/UI/Font.cpp
  16. 0 105
      Source/Atomic/UI/Font.h
  17. 0 125
      Source/Atomic/UI/FontFace.cpp
  18. 0 111
      Source/Atomic/UI/FontFace.h
  19. 0 387
      Source/Atomic/UI/FontFaceBitmap.cpp
  20. 0 60
      Source/Atomic/UI/FontFaceBitmap.h
  21. 0 454
      Source/Atomic/UI/FontFaceFreeType.cpp
  22. 0 71
      Source/Atomic/UI/FontFaceFreeType.h
  23. 0 660
      Source/Atomic/UI/LineEdit.cpp
  24. 0 153
      Source/Atomic/UI/LineEdit.h
  25. 0 1138
      Source/Atomic/UI/ListView.cpp
  26. 0 180
      Source/Atomic/UI/ListView.h
  27. 0 439
      Source/Atomic/UI/Menu.cpp
  28. 0 106
      Source/Atomic/UI/Menu.h
  29. 0 144
      Source/Atomic/UI/MessageBox.cpp
  30. 0 74
      Source/Atomic/UI/MessageBox.h
  31. 0 322
      Source/Atomic/UI/ScrollBar.cpp
  32. 0 125
      Source/Atomic/UI/ScrollBar.h
  33. 0 702
      Source/Atomic/UI/ScrollView.cpp
  34. 0 178
      Source/Atomic/UI/ScrollView.h
  35. 0 279
      Source/Atomic/UI/Slider.cpp
  36. 0 110
      Source/Atomic/UI/Slider.h
  37. 0 278
      Source/Atomic/UI/Sprite.cpp
  38. 0 119
      Source/Atomic/UI/Sprite.h
  39. 0 714
      Source/Atomic/UI/Text.cpp
  40. 0 231
      Source/Atomic/UI/Text.h
  41. 0 590
      Source/Atomic/UI/Text3D.cpp
  42. 0 194
      Source/Atomic/UI/Text3D.h
  43. 0 110
      Source/Atomic/UI/ToolTip.cpp
  44. 0 66
      Source/Atomic/UI/ToolTip.h
  45. 0 325
      Source/Atomic/UI/UI.cpp
  46. 1 12
      Source/Atomic/UI/UI.h
  47. 0 174
      Source/Atomic/UI/View3D.cpp
  48. 0 98
      Source/Atomic/UI/View3D.h
  49. 0 415
      Source/Atomic/UI/Window.cpp
  50. 0 154
      Source/Atomic/UI/Window.h
  51. 0 9
      Source/AtomicEditor/Source/AEApplication.cpp
  52. 0 210
      Source/AtomicEditor/Source/Editors/ModelResourceEditor.cpp
  53. 1 2
      Source/AtomicEditor/Source/Editors/ModelResourceEditor.h
  54. 0 1
      Source/AtomicEditor/Source/Editors/SceneEditor3D/SceneEditor3D.cpp
  55. 3 3
      Source/AtomicJS/JSBind/modules/Engine.json
  56. 1 8
      Source/AtomicJS/JSBind/modules/UI.json

+ 4 - 6
Source/Atomic/Engine/Console.cpp

@@ -1,3 +1,5 @@
+#ifdef __disabled
+
 //
 //
 // Copyright (c) 2008-2014 the Urho3D project.
 // Copyright (c) 2008-2014 the Urho3D project.
 //
 //
@@ -24,20 +26,14 @@
 #include "../Engine/Console.h"
 #include "../Engine/Console.h"
 #include "../Core/Context.h"
 #include "../Core/Context.h"
 #include "../Core/CoreEvents.h"
 #include "../Core/CoreEvents.h"
-#include "../UI/DropDownList.h"
 #include "../Engine/EngineEvents.h"
 #include "../Engine/EngineEvents.h"
-#include "../UI/Font.h"
 #include "../Graphics/Graphics.h"
 #include "../Graphics/Graphics.h"
 #include "../Graphics/GraphicsEvents.h"
 #include "../Graphics/GraphicsEvents.h"
 #include "../Input/Input.h"
 #include "../Input/Input.h"
 #include "../Input/InputEvents.h"
 #include "../Input/InputEvents.h"
 #include "../IO/IOEvents.h"
 #include "../IO/IOEvents.h"
-#include "../UI/LineEdit.h"
-#include "../UI/ListView.h"
 #include "../IO/Log.h"
 #include "../IO/Log.h"
 #include "../Resource/ResourceCache.h"
 #include "../Resource/ResourceCache.h"
-#include "../UI/ScrollBar.h"
-#include "../UI/Text.h"
 #include "../UI/UI.h"
 #include "../UI/UI.h"
 #include "../UI/UIEvents.h"
 #include "../UI/UIEvents.h"
 
 
@@ -437,3 +433,5 @@ void Console::HandlePostUpdate(StringHash eventType, VariantMap& eventData)
 }
 }
 
 
 }
 }
+
+#endif

+ 4 - 0
Source/Atomic/Engine/Console.h

@@ -1,3 +1,5 @@
+#ifdef __disabled
+
 //
 //
 // Copyright (c) 2008-2014 the Urho3D project.
 // Copyright (c) 2008-2014 the Urho3D project.
 //
 //
@@ -152,3 +154,5 @@ private:
 };
 };
 
 
 }
 }
+
+#endif

+ 4 - 2
Source/Atomic/Engine/DebugHud.cpp

@@ -1,3 +1,5 @@
+#ifdef __disabled
+
 //
 //
 // Copyright (c) 2008-2014 the Urho3D project.
 // Copyright (c) 2008-2014 the Urho3D project.
 //
 //
@@ -24,12 +26,10 @@
 #include "../Core/CoreEvents.h"
 #include "../Core/CoreEvents.h"
 #include "../Engine/DebugHud.h"
 #include "../Engine/DebugHud.h"
 #include "../Engine/Engine.h"
 #include "../Engine/Engine.h"
-#include "../UI/Font.h"
 #include "../Graphics/Graphics.h"
 #include "../Graphics/Graphics.h"
 #include "../IO/Log.h"
 #include "../IO/Log.h"
 #include "../Core/Profiler.h"
 #include "../Core/Profiler.h"
 #include "../Graphics/Renderer.h"
 #include "../Graphics/Renderer.h"
-#include "../UI/Text.h"
 #include "../UI/UI.h"
 #include "../UI/UI.h"
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
@@ -267,3 +267,5 @@ void DebugHud::HandlePostUpdate(StringHash eventType, VariantMap& eventData)
 }
 }
 
 
 }
 }
+
+#endif

+ 4 - 0
Source/Atomic/Engine/DebugHud.h

@@ -1,3 +1,5 @@
+#ifdef __disabled
+
 //
 //
 // Copyright (c) 2008-2014 the Urho3D project.
 // Copyright (c) 2008-2014 the Urho3D project.
 //
 //
@@ -118,3 +120,5 @@ private:
 };
 };
 
 
 }
 }
+
+#endif

+ 7 - 0
Source/Atomic/Engine/Engine.cpp

@@ -471,6 +471,8 @@ void Engine::RunFrame()
 
 
 Console* Engine::CreateConsole()
 Console* Engine::CreateConsole()
 {
 {
+    return 0;
+    /*
     if (headless_ || !initialized_)
     if (headless_ || !initialized_)
         return 0;
         return 0;
 
 
@@ -483,10 +485,14 @@ Console* Engine::CreateConsole()
     }
     }
 
 
     return console;
     return console;
+    */
 }
 }
 
 
 DebugHud* Engine::CreateDebugHud()
 DebugHud* Engine::CreateDebugHud()
 {
 {
+    return 0;
+
+    /*
     if (headless_ || !initialized_)
     if (headless_ || !initialized_)
         return 0;
         return 0;
 
 
@@ -499,6 +505,7 @@ DebugHud* Engine::CreateDebugHud()
     }
     }
 
 
     return debugHud;
     return debugHud;
+    */
 }
 }
 
 
 void Engine::SetTimeStepSmoothing(int frames)
 void Engine::SetTimeStepSmoothing(int frames)

+ 5 - 1
Source/Atomic/Input/Input.cpp

@@ -34,7 +34,6 @@
 #include "../Resource/ResourceCache.h"
 #include "../Resource/ResourceCache.h"
 #include "../IO/RWOpsWrapper.h"
 #include "../IO/RWOpsWrapper.h"
 #include "../Core/StringUtils.h"
 #include "../Core/StringUtils.h"
-#include "../UI/Text.h"
 #include "../UI/UI.h"
 #include "../UI/UI.h"
 
 
 #include <cstring>
 #include <cstring>
@@ -678,6 +677,10 @@ static void PopulateMouseButtonBindingMap(HashMap<String, int>& mouseButtonBindi
 
 
 int Input::AddScreenJoystick(XMLFile* layoutFile, XMLFile* styleFile)
 int Input::AddScreenJoystick(XMLFile* layoutFile, XMLFile* styleFile)
 {
 {
+
+    return -1;
+
+    /*
     static HashMap<String, int> keyBindingMap;
     static HashMap<String, int> keyBindingMap;
     static HashMap<String, int> mouseButtonBindingMap;
     static HashMap<String, int> mouseButtonBindingMap;
 
 
@@ -844,6 +847,7 @@ int Input::AddScreenJoystick(XMLFile* layoutFile, XMLFile* styleFile)
     SubscribeToEvent(E_TOUCHEND, HANDLER(Input, HandleScreenJoystickTouch));
     SubscribeToEvent(E_TOUCHEND, HANDLER(Input, HandleScreenJoystickTouch));
 
 
     return joystickID;
     return joystickID;
+    */
 }
 }
 
 
 bool Input::RemoveScreenJoystick(SDL_JoystickID id)
 bool Input::RemoveScreenJoystick(SDL_JoystickID id)

+ 0 - 187
Source/Atomic/UI/Button.cpp

@@ -1,187 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../UI/Button.h"
-#include "../Core/Context.h"
-#include "../Input/InputEvents.h"
-#include "../UI/UI.h"
-#include "../UI/UIEvents.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-extern const char* UI_CATEGORY;
-
-Button::Button(Context* context) :
-    BorderImage(context),
-    pressedOffset_(IntVector2::ZERO),
-    pressedChildOffset_(IntVector2::ZERO),
-    repeatDelay_(1.0f),
-    repeatRate_(0.0f),
-    repeatTimer_(0.0f),
-    pressed_(false)
-{
-    SetEnabled(true);
-    focusMode_ = FM_FOCUSABLE;
-}
-
-Button::~Button()
-{
-}
-
-void Button::RegisterObject(Context* context)
-{
-    context->RegisterFactory<Button>(UI_CATEGORY);
-
-    COPY_BASE_ATTRIBUTES(BorderImage);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Is Enabled", true);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Focus Mode", FM_FOCUSABLE);
-    ACCESSOR_ATTRIBUTE("Pressed Image Offset", GetPressedOffset, SetPressedOffset, IntVector2, IntVector2::ZERO, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Pressed Child Offset", GetPressedChildOffset, SetPressedChildOffset, IntVector2, IntVector2::ZERO, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Repeat Delay", GetRepeatDelay, SetRepeatDelay, float, 1.0f, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Repeat Rate", GetRepeatRate, SetRepeatRate, float, 0.0f, AM_FILE);
-}
-
-void Button::Update(float timeStep)
-{
-    if (!hovering_ && pressed_)
-        SetPressed(false);
-
-    // Send repeat events if pressed
-    if (pressed_ && repeatRate_ > 0.0f)
-    {
-        repeatTimer_ -= timeStep;
-        if (repeatTimer_ <= 0.0f)
-        {
-            repeatTimer_ += 1.0f / repeatRate_;
-
-            using namespace Pressed;
-
-            VariantMap& eventData = GetEventDataMap();
-            eventData[P_ELEMENT] = this;
-            SendEvent(E_PRESSED, eventData);
-        }
-    }
-}
-
-void Button::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor)
-{
-    IntVector2 offset(IntVector2::ZERO);
-    if (hovering_ || HasFocus())
-        offset += hoverOffset_;
-    if (pressed_ || selected_)
-        offset += pressedOffset_;
-
-    BorderImage::GetBatches(batches, vertexData, currentScissor, offset);
-}
-
-void Button::OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
-{
-    if (button == MOUSEB_LEFT)
-    {
-        SetPressed(true);
-        repeatTimer_ = repeatDelay_;
-        hovering_ = true;
-
-        using namespace Pressed;
-
-        VariantMap& eventData = GetEventDataMap();
-        eventData[P_ELEMENT] = this;
-        SendEvent(E_PRESSED, eventData);
-    }
-}
-
-void Button::OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement)
-{
-    if (pressed_ && button == MOUSEB_LEFT)
-    {
-        SetPressed(false);
-
-        using namespace Released;
-
-        VariantMap& eventData = GetEventDataMap();
-        eventData[P_ELEMENT] = this;
-        SendEvent(E_RELEASED, eventData);
-    }
-}
-
-void Button::OnDragMove(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
-{
-    SetPressed(true);
-}
-
-void Button::OnKey(int key, int buttons, int qualifiers)
-{
-    if (HasFocus() && (key == KEY_RETURN || key == KEY_RETURN2 || key == KEY_KP_ENTER || key == KEY_SPACE))
-    {
-        // Simulate LMB click
-        OnClickBegin(IntVector2(), IntVector2(), MOUSEB_LEFT, 0, 0, 0);
-        OnClickEnd(IntVector2(), IntVector2(), MOUSEB_LEFT, 0, 0, 0, 0);
-    }
-}
-
-void Button::SetPressedOffset(const IntVector2& offset)
-{
-    pressedOffset_ = offset;
-}
-
-void Button::SetPressedOffset(int x, int y)
-{
-    pressedOffset_ = IntVector2(x, y);
-}
-
-void Button::SetPressedChildOffset(const IntVector2& offset)
-{
-    pressedChildOffset_ = offset;
-}
-
-void Button::SetPressedChildOffset(int x, int y)
-{
-    pressedChildOffset_ = IntVector2(x, y);
-}
-
-void Button::SetRepeat(float delay, float rate)
-{
-    SetRepeatDelay(delay);
-    SetRepeatRate(rate);
-}
-
-void Button::SetRepeatDelay(float delay)
-{
-    repeatDelay_ = Max(delay, 0.0f);
-}
-
-void Button::SetRepeatRate(float rate)
-{
-    repeatRate_ = Max(rate, 0.0f);
-}
-
-void Button::SetPressed(bool enable)
-{
-    pressed_ = enable;
-    SetChildOffset(pressed_ ? pressedChildOffset_ : IntVector2::ZERO);
-}
-
-}

+ 0 - 100
Source/Atomic/UI/Button.h

@@ -1,100 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/BorderImage.h"
-
-namespace Atomic
-{
-
-/// Pushbutton %UI element.
-class ATOMIC_API Button : public BorderImage
-{
-    OBJECT(Button);
-    
-public:
-    /// Construct.
-    Button(Context* context);
-    /// Destruct.
-    virtual ~Button();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-    
-    /// Perform UI element update.
-    virtual void Update(float timeStep);
-    /// Return UI rendering batches.
-    virtual void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
-    /// React to mouse click begin.
-    virtual void OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse click end.
-    virtual void OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement);
-    /// React to mouse drag motion.
-    virtual void OnDragMove(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
-    /// React to a key press.
-    virtual void OnKey(int key, int buttons, int qualifiers);
-
-    /// Set offset to image rectangle used when pressed.
-    void SetPressedOffset(const IntVector2& offset);
-    /// Set offset to image rectangle used when pressed.
-    void SetPressedOffset(int x, int y);
-    /// Set offset of child elements when pressed.
-    void SetPressedChildOffset(const IntVector2& offset);
-    /// Set offset of child elements when pressed.
-    void SetPressedChildOffset(int x, int y);
-    /// Set repeat properties. Rate 0 (default) disables repeat.
-    void SetRepeat(float delay, float rate);
-    /// Set repeat delay.
-    void SetRepeatDelay(float delay);
-    /// Set repeat rate.
-    void SetRepeatRate(float rate);
-    
-    /// Return pressed image offset.
-    const IntVector2& GetPressedOffset() const { return pressedOffset_; }
-    /// Return offset of child elements when pressed.
-    const IntVector2& GetPressedChildOffset() const { return pressedChildOffset_; }
-    /// Return repeat delay.
-    float GetRepeatDelay() const { return repeatDelay_; }
-    /// Return repeat rate.
-    float GetRepeatRate() const { return repeatRate_; }
-    /// Return whether is currently pressed.
-    bool IsPressed() const { return pressed_; }
-
-protected:
-    /// Set new pressed state.
-    void SetPressed(bool enable);
-    
-    /// Pressed image offset.
-    IntVector2 pressedOffset_;
-    /// Pressed label offset.
-    IntVector2 pressedChildOffset_;
-    /// Repeat delay.
-    float repeatDelay_;
-    /// Repeat rate.
-    float repeatRate_;
-    /// Repeat timer.
-    float repeatTimer_;
-    /// Current pressed state.
-    bool pressed_;
-};
-
-}

+ 0 - 111
Source/Atomic/UI/CheckBox.cpp

@@ -1,111 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../UI/CheckBox.h"
-#include "../Core/Context.h"
-#include "../Input/InputEvents.h"
-#include "../UI/UIEvents.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-extern const char* UI_CATEGORY;
-
-CheckBox::CheckBox(Context* context) :
-    BorderImage(context),
-    checkedOffset_(IntVector2::ZERO),
-    checked_(false)
-{
-    SetEnabled(true);
-    focusMode_ = FM_FOCUSABLE_DEFOCUSABLE;
-}
-
-CheckBox::~CheckBox()
-{
-}
-
-void CheckBox::RegisterObject(Context* context)
-{
-    context->RegisterFactory<CheckBox>(UI_CATEGORY);
-
-    COPY_BASE_ATTRIBUTES(BorderImage);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Is Enabled", true);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Focus Mode", FM_FOCUSABLE_DEFOCUSABLE);
-    ACCESSOR_ATTRIBUTE("Is Checked", IsChecked, SetChecked, bool, false, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Checked Image Offset", GetCheckedOffset, SetCheckedOffset, IntVector2, IntVector2::ZERO, AM_FILE);
-}
-
-void CheckBox::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor)
-{
-    IntVector2 offset(IntVector2::ZERO);
-    if (hovering_ || selected_ || HasFocus())
-        offset += hoverOffset_;
-    if (checked_)
-        offset += checkedOffset_;
-
-    BorderImage::GetBatches(batches, vertexData, currentScissor, offset);
-}
-
-void CheckBox::OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
-{
-    if (button == MOUSEB_LEFT && editable_)
-        SetChecked(!checked_);
-}
-
-void CheckBox::OnKey(int key, int buttons, int qualifiers)
-{
-    if (HasFocus() && key == KEY_SPACE)
-    {
-        // Simulate LMB click
-        OnClickBegin(IntVector2(), IntVector2(), MOUSEB_LEFT, 0, 0, 0);
-    }
-}
-
-void CheckBox::SetChecked(bool enable)
-{
-    if (enable != checked_)
-    {
-        checked_ = enable;
-
-        using namespace Toggled;
-
-        VariantMap& eventData = GetEventDataMap();
-        eventData[P_ELEMENT] = this;
-        eventData[P_STATE] = checked_;
-        SendEvent(E_TOGGLED, eventData);
-    }
-}
-
-void CheckBox::SetCheckedOffset(const IntVector2& offset)
-{
-    checkedOffset_ = offset;
-}
-
-void CheckBox::SetCheckedOffset(int x, int y)
-{
-    checkedOffset_ = IntVector2(x, y);
-}
-
-}

+ 0 - 69
Source/Atomic/UI/CheckBox.h

@@ -1,69 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/BorderImage.h"
-
-namespace Atomic
-{
-
-/// %UI element that can be toggled between unchecked and checked state.
-class ATOMIC_API CheckBox : public BorderImage
-{
-    OBJECT(CheckBox);
-    
-public:
-    /// Construct.
-    CheckBox(Context* context);
-    /// Destruct.
-    virtual ~CheckBox();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-    
-    /// Return UI rendering batches.
-    virtual void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
-    /// React to mouse click begin.
-    virtual void OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor);
-    /// React to a key press.
-    virtual void OnKey(int key, int buttons, int qualifiers);
-    
-    /// Set checked state.
-    void SetChecked(bool enable);
-    /// Set checked image offset.
-    void SetCheckedOffset(const IntVector2& rect);
-    /// Set checked image offset.
-    void SetCheckedOffset(int x, int y);
-    
-    /// Return whether is checked.
-    bool IsChecked() const { return checked_; }
-    /// Return checked image offset.
-    const IntVector2& GetCheckedOffset() const { return checkedOffset_; }
-    
-protected:
-    /// Checked image offset.
-    IntVector2 checkedOffset_;
-    /// Current checked state.
-    bool checked_;
-};
-
-}

+ 0 - 342
Source/Atomic/UI/DropDownList.cpp

@@ -1,342 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../UI/DropDownList.h"
-#include "../Input/InputEvents.h"
-#include "../UI/ListView.h"
-#include "../IO/Log.h"
-#include "../UI/Text.h"
-#include "../UI/UI.h"
-#include "../UI/UIEvents.h"
-#include "../UI/Window.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-extern const char* UI_CATEGORY;
-
-DropDownList::DropDownList(Context* context) :
-    Menu(context),
-    resizePopup_(false),
-    selectionAttr_(0)
-{
-    focusMode_ = FM_FOCUSABLE_DEFOCUSABLE;
-
-    Window* window = new Window(context_);
-    window->SetInternal(true);
-    SetPopup(window);
-
-    listView_ = new ListView(context_);
-    listView_->SetInternal(true);
-    listView_->SetScrollBarsVisible(false, false);
-    popup_->SetLayout(LM_VERTICAL);
-    popup_->AddChild(listView_);
-    placeholder_ = CreateChild<UIElement>("DDL_Placeholder");
-    placeholder_->SetInternal(true);
-    Text* text = placeholder_->CreateChild<Text>("DDL_Placeholder_Text");
-    text->SetInternal(true);
-    text->SetVisible(false);
-
-    SubscribeToEvent(listView_, E_ITEMCLICKED, HANDLER(DropDownList, HandleItemClicked));
-    SubscribeToEvent(listView_, E_UNHANDLEDKEY, HANDLER(DropDownList, HandleListViewKey));
-}
-
-DropDownList::~DropDownList()
-{
-}
-
-void DropDownList::RegisterObject(Context* context)
-{
-    context->RegisterFactory<DropDownList>(UI_CATEGORY);
-
-    COPY_BASE_ATTRIBUTES(Menu);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Focus Mode", FM_FOCUSABLE_DEFOCUSABLE);
-    ACCESSOR_ATTRIBUTE("Selection", GetSelection, SetSelectionAttr, unsigned, 0, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Resize Popup", GetResizePopup, SetResizePopup, bool, false, AM_FILE);
-}
-
-void DropDownList::ApplyAttributes()
-{
-    // Reapply selection after possible items have been loaded
-    SetSelection(selectionAttr_);
-}
-
-void DropDownList::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor)
-{
-    Menu::GetBatches(batches, vertexData, currentScissor);
-
-    if (!placeholder_->IsVisible())
-        return;
-
-    UIElement* selectedItem = GetSelectedItem();
-    if (selectedItem)
-    {
-        // Can not easily copy the selected item. However, it can be re-rendered on the placeholder's position
-        const IntVector2& targetPos = placeholder_->GetScreenPosition();
-        const IntVector2& originalPos = selectedItem->GetScreenPosition();
-        IntVector2 offset = targetPos - originalPos;
-
-        // GetBatches() usually resets the hover flag. Therefore get its value and then reset it for the real rendering
-        // Render the selected item without its selection color, so temporarily reset the item's selected attribute
-        bool hover = selectedItem->IsHovering();
-        selectedItem->SetSelected(false);
-        selectedItem->SetHovering(false);
-        selectedItem->GetBatchesWithOffset(offset, batches, vertexData, currentScissor);
-        selectedItem->SetSelected(true);
-        selectedItem->SetHovering(hover);
-    }
-}
-
-void DropDownList::OnShowPopup()
-{
-    // Resize the popup to match the size of the list content, and optionally match the button width
-    UIElement* content = listView_->GetContentElement();
-    content->UpdateLayout();
-    const IntVector2& contentSize = content->GetSize();
-    const IntRect& border = popup_->GetLayoutBorder();
-    popup_->SetSize(resizePopup_ ? GetWidth() : contentSize.x_ + border.left_ + border.right_, contentSize.y_ + border.top_ +
-        border.bottom_);
-
-    // Check if popup fits below the button. If not, show above instead
-    bool showAbove = false;
-    UIElement* root = GetRoot();
-    if (root)
-    {
-        const IntVector2& screenPos = GetScreenPosition();
-        if (screenPos.y_ + GetHeight() + popup_->GetHeight() > root->GetHeight() && screenPos.y_ - popup_->GetHeight() >= 0)
-            showAbove = true;
-    }
-    SetPopupOffset(0, showAbove ? -popup_->GetHeight() : GetHeight());
-
-    // Focus the ListView to allow making the selection with keys
-    GetSubsystem<UI>()->SetFocusElement(listView_);
-}
-
-void DropDownList::OnHidePopup()
-{
-    // When the popup is hidden, propagate the selection
-    using namespace ItemSelected;
-
-    VariantMap& eventData = GetEventDataMap();
-    eventData[P_ELEMENT] = this;
-    eventData[P_SELECTION] = GetSelection();
-    SendEvent(E_ITEMSELECTED, eventData);
-}
-
-void DropDownList::OnSetEditable()
-{
-    listView_->SetEditable(editable_);
-}
-
-void DropDownList::AddItem(UIElement* item)
-{
-    InsertItem(M_MAX_UNSIGNED, item);
-}
-
-void DropDownList::InsertItem(unsigned index, UIElement* item)
-{
-    listView_->InsertItem(index, item);
-
-    // If there was no selection, set to the first
-    if (listView_->GetSelection() == M_MAX_UNSIGNED)
-        listView_->SetSelection(0);
-}
-
-void DropDownList::RemoveItem(UIElement* item)
-{
-    listView_->RemoveItem(item);
-}
-
-void DropDownList::RemoveItem(unsigned index)
-{
-    listView_->RemoveItem(index);
-}
-
-void DropDownList::RemoveAllItems()
-{
-    listView_->RemoveAllItems();
-}
-
-void DropDownList::SetSelection(unsigned index)
-{
-    listView_->SetSelection(index);
-
-    // Display the place holder text when there is no selection, however, the place holder text is only visible when the place holder itself is set to visible
-    placeholder_->GetChild(0)->SetVisible(index == M_MAX_UNSIGNED);
-}
-
-void DropDownList::SetPlaceholderText(const String& text)
-{
-    static_cast<Text*>(placeholder_->GetChild(0))->SetText(text);
-}
-
-void DropDownList::SetResizePopup(bool enable)
-{
-    resizePopup_ = enable;
-}
-
-unsigned DropDownList::GetNumItems() const
-{
-    return listView_->GetNumItems();
-}
-
-UIElement* DropDownList::GetItem(unsigned index) const
-{
-    return listView_->GetItem(index);
-}
-
-PODVector<UIElement*> DropDownList::GetItems() const
-{
-    return listView_->GetItems();
-}
-
-unsigned DropDownList::GetSelection() const
-{
-    return listView_->GetSelection();
-}
-
-UIElement* DropDownList::GetSelectedItem() const
-{
-    return listView_->GetSelectedItem();
-}
-
-const String& DropDownList::GetPlaceholderText() const
-{
-    return static_cast<Text*>(placeholder_->GetChild(0))->GetText();
-}
-
-void DropDownList::SetSelectionAttr(unsigned index)
-{
-    selectionAttr_ = index;
-
-    // We may not have the list items yet. Apply the index again in ApplyAttributes().
-    SetSelection(index);
-}
-
-bool DropDownList::FilterImplicitAttributes(XMLElement& dest) const
-{
-    if (!Menu::FilterImplicitAttributes(dest))
-        return false;
-
-    if (!RemoveChildXML(dest, "Popup Offset"))
-        return false;
-
-    XMLElement childElem = dest.GetChild("element");
-    if (!childElem)
-        return false;
-    if (!RemoveChildXML(childElem, "Name", "DDL_Placeholder"))
-        return false;
-    if (!RemoveChildXML(childElem, "Size"))
-        return false;
-
-    childElem = childElem.GetChild("element");
-    if (!childElem)
-        return false;
-    if (!RemoveChildXML(childElem, "Name", "DDL_Placeholder_Text"))
-        return false;
-    if (!RemoveChildXML(childElem, "Is Visible"))
-        return false;
-
-    return true;
-}
-
-bool DropDownList::FilterPopupImplicitAttributes(XMLElement& dest) const
-{
-    if (!Menu::FilterPopupImplicitAttributes(dest))
-        return false;
-
-    // Window popup
-    if (dest.GetAttribute("style").Empty() && !dest.SetAttribute("style", "none"))
-        return false;
-    if (!RemoveChildXML(dest, "Layout Mode", "Vertical"))
-        return false;
-    if (!RemoveChildXML(dest, "Size"))
-        return false;
-
-    // ListView
-    XMLElement childElem = dest.GetChild("element");
-    if (!childElem)
-        return false;
-    if (!listView_->FilterAttributes(childElem))
-        return false;
-    if (childElem.GetAttribute("style").Empty() && !childElem.SetAttribute("style", "none"))
-        return false;
-    if (!RemoveChildXML(childElem, "Focus Mode", "NotFocusable"))
-        return false;
-    if (!RemoveChildXML(childElem, "Auto Show/Hide Scrollbars", "false"))
-        return false;
-
-    // Horizontal scroll bar
-    childElem = childElem.GetChild("element");
-    if (childElem && !childElem.GetParent().RemoveChild(childElem))
-        return false;
-
-    // Vertical scroll bar
-    childElem = childElem.GetNext("element");
-    if (childElem && !childElem.GetParent().RemoveChild(childElem))
-        return false;
-
-    // Scroll panel
-    childElem = childElem.GetNext("element");
-    if (!childElem)
-        return false;
-    if (childElem.GetAttribute("style").Empty() && !childElem.SetAttribute("style", "none"))
-        return false;
-
-    // Item container
-    childElem = childElem.GetChild("element");
-    if (!childElem)
-        return false;
-    if (childElem.GetAttribute("style").Empty() && !childElem.SetAttribute("style", "none"))
-        return false;
-
-    return true;
-}
-
-void DropDownList::HandleItemClicked(StringHash eventType, VariantMap& eventData)
-{
-    // Resize the selection placeholder to match the selected item
-    UIElement* selectedItem = GetSelectedItem();
-    if (selectedItem)
-        placeholder_->SetSize(selectedItem->GetSize());
-
-    // Close and defocus the popup. This will actually send the selection forward
-    if (listView_->HasFocus())
-        GetSubsystem<UI>()->SetFocusElement(focusMode_ < FM_FOCUSABLE ? 0 : this);
-    ShowPopup(false);
-}
-
-void DropDownList::HandleListViewKey(StringHash eventType, VariantMap& eventData)
-{
-    using namespace UnhandledKey;
-
-    // If enter pressed in the list view, close and propagate selection
-    int key = eventData[P_KEY].GetInt();
-    if (key == KEY_RETURN || key == KEY_RETURN2 || key == KEY_KP_ENTER)
-        HandleItemClicked(eventType, eventData);
-}
-
-}

+ 0 - 118
Source/Atomic/UI/DropDownList.h

@@ -1,118 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/Menu.h"
-
-namespace Atomic
-{
-
-class ListView;
-
-/// %Menu %UI element that displays a popup list view.
-class ATOMIC_API DropDownList : public Menu
-{
-    OBJECT(DropDownList)
-
-public:
-    /// Construct.
-    DropDownList(Context* context);
-    /// Destruct.
-    ~DropDownList();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// Apply attribute changes that can not be applied immediately.
-    virtual void ApplyAttributes();
-    /// Return UI rendering batches.
-    virtual void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
-    /// React to the popup being shown.
-    virtual void OnShowPopup();
-    /// React to the popup being hidden.
-    virtual void OnHidePopup();
-    /// React to editable status change.
-    virtual void OnSetEditable();
-    
-    /// Add item to the end of the list.
-    void AddItem(UIElement* item);
-    /// Insert item to a specific position.
-    void InsertItem(unsigned index, UIElement* item);
-    /// Remove specific item.
-    void RemoveItem(UIElement* item);
-    /// Remove item at index.
-    void RemoveItem(unsigned index);
-    /// Remove all items.
-    void RemoveAllItems();
-    /// Set selection.
-    void SetSelection(unsigned index);
-    /// Set place holder text. This is the text shown when there is no selection in drop down list.
-    void SetPlaceholderText(const String& text);
-    /// Set whether popup should be automatically resized to match the dropdown button width.
-    void SetResizePopup(bool enable);
-
-    /// Return number of items.
-    unsigned GetNumItems() const;
-    /// Return item at index.
-    UIElement* GetItem(unsigned index) const;
-    /// Return all items.
-    PODVector<UIElement*> GetItems() const;
-    /// Return selection index, or M_MAX_UNSIGNED if none selected.
-    unsigned GetSelection() const;
-    /// Return selected item, or null if none selected.
-    UIElement* GetSelectedItem() const;
-    /// Return listview element.
-    ListView* GetListView() const { return listView_; }
-    /// Return selected item placeholder element.
-    UIElement* GetPlaceholder() const { return placeholder_; }
-    /// Return place holder text.
-    const String& GetPlaceholderText() const;
-    /// Return whether popup should be automatically resized.
-    bool GetResizePopup() const { return resizePopup_; }
-
-    /// Set selection attribute.
-    void SetSelectionAttr(unsigned index);
-
-protected:
-    /// Filter implicit attributes in serialization process.
-    virtual bool FilterImplicitAttributes(XMLElement& dest) const;
-    /// Filter implicit attributes in serialization process.
-    virtual bool FilterPopupImplicitAttributes(XMLElement& dest) const;
-
-    /// Listview element.
-    SharedPtr<ListView> listView_;
-    /// Selected item placeholder element.
-    SharedPtr<UIElement> placeholder_;
-    /// Resize popup flag.
-    bool resizePopup_;
-
-private:
-    /// Handle listview item click event.
-    void HandleItemClicked(StringHash eventType, VariantMap& eventData);
-    /// Handle a key press from the listview
-    void HandleListViewKey(StringHash eventType, VariantMap& eventData);
-
-    /// Selected item index attribute.
-    unsigned selectionAttr_;
-};
-
-}

+ 0 - 492
Source/Atomic/UI/FileSelector.cpp

@@ -1,492 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../UI/DropDownList.h"
-#include "../IO/File.h"
-#include "../UI/FileSelector.h"
-#include "../IO/FileSystem.h"
-#include "../Input/InputEvents.h"
-#include "../UI/LineEdit.h"
-#include "../UI/ListView.h"
-#include "../UI/Text.h"
-#include "../UI/UI.h"
-#include "../UI/UIEvents.h"
-#include "../UI/Window.h"
-
-#include "../Container/Sort.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-static bool CompareEntries(const FileSelectorEntry& lhs, const FileSelectorEntry& rhs)
-{
-    if (lhs.directory_ && !rhs.directory_)
-        return true;
-    if (!lhs.directory_ && rhs.directory_)
-        return false;
-    return lhs.name_.Compare(rhs.name_, false) < 0;
-}
-
-FileSelector::FileSelector(Context* context) :
-    Object(context),
-    directoryMode_(false),
-    ignoreEvents_(false)
-{
-    window_ = new Window(context_);
-    window_->SetLayout(LM_VERTICAL);
-
-    titleLayout = new UIElement(context_);
-    titleLayout->SetLayout(LM_HORIZONTAL);
-    window_->AddChild(titleLayout);
-
-    titleText_ = new Text(context_);
-    titleLayout->AddChild(titleText_);
-
-    closeButton_ = new Button(context_);
-    titleLayout->AddChild(closeButton_);
-
-    pathEdit_ = new LineEdit(context_);
-    window_->AddChild(pathEdit_);
-
-    fileList_ = new ListView(context_);
-    window_->AddChild(fileList_);
-
-    fileNameLayout_ = new UIElement(context_);
-    fileNameLayout_->SetLayout(LM_HORIZONTAL);
-
-    fileNameEdit_ = new LineEdit(context_);
-    fileNameLayout_->AddChild(fileNameEdit_);
-
-    filterList_ = new DropDownList(context_);
-    fileNameLayout_->AddChild(filterList_);
-
-    window_->AddChild(fileNameLayout_);
-
-    separatorLayout_ = new UIElement(context_);
-    window_->AddChild(separatorLayout_);
-
-    buttonLayout_ = new UIElement(context_);
-    buttonLayout_->SetLayout(LM_HORIZONTAL);
-
-    buttonLayout_->AddChild(new UIElement(context_)); // Add spacer
-
-    cancelButton_ = new Button(context_);
-    cancelButtonText_ = new Text(context_);
-    cancelButtonText_->SetAlignment(HA_CENTER, VA_CENTER);
-    cancelButton_->AddChild(cancelButtonText_);
-    buttonLayout_->AddChild(cancelButton_);
-
-    okButton_ = new Button(context_);
-    okButtonText_ = new Text(context_);
-    okButtonText_->SetAlignment(HA_CENTER, VA_CENTER);
-    okButton_->AddChild(okButtonText_);
-    buttonLayout_->AddChild(okButton_);
-
-    window_->AddChild(buttonLayout_);
-
-    Vector<String> defaultFilters;
-    defaultFilters.Push("*.*");
-    SetFilters(defaultFilters, 0);
-    FileSystem* fileSystem = GetSubsystem<FileSystem>();
-    SetPath(fileSystem->GetCurrentDir());
-
-    // Focus the fileselector's filelist initially when created, and bring to front
-    UI* ui = GetSubsystem<UI>();
-    ui->GetRoot()->AddChild(window_);
-    ui->SetFocusElement(fileList_);
-    window_->SetModal(true);
-
-    SubscribeToEvent(filterList_, E_ITEMSELECTED, HANDLER(FileSelector, HandleFilterChanged));
-    SubscribeToEvent(pathEdit_, E_TEXTFINISHED, HANDLER(FileSelector, HandlePathChanged));
-    SubscribeToEvent(fileNameEdit_, E_TEXTFINISHED, HANDLER(FileSelector, HandleOKPressed));
-    SubscribeToEvent(fileList_, E_ITEMSELECTED, HANDLER(FileSelector, HandleFileSelected));
-    SubscribeToEvent(fileList_, E_ITEMDOUBLECLICKED, HANDLER(FileSelector, HandleFileDoubleClicked));
-    SubscribeToEvent(fileList_, E_UNHANDLEDKEY, HANDLER(FileSelector, HandleFileListKey));
-    SubscribeToEvent(okButton_, E_RELEASED, HANDLER(FileSelector, HandleOKPressed));
-    SubscribeToEvent(cancelButton_, E_RELEASED, HANDLER(FileSelector, HandleCancelPressed));
-    SubscribeToEvent(closeButton_, E_RELEASED, HANDLER(FileSelector, HandleCancelPressed));
-    SubscribeToEvent(window_, E_MODALCHANGED, HANDLER(FileSelector, HandleCancelPressed));
-}
-
-FileSelector::~FileSelector()
-{
-    window_->Remove();
-}
-
-void FileSelector::RegisterObject(Context* context)
-{
-    context->RegisterFactory<FileSelector>();
-}
-
-void FileSelector::SetDefaultStyle(XMLFile* style)
-{
-    if (!style)
-        return;
-
-    window_->SetDefaultStyle(style);
-    window_->SetStyle("FileSelector");
-
-    titleText_->SetStyle("FileSelectorTitleText");
-    closeButton_->SetStyle("CloseButton");
-
-    okButtonText_->SetStyle("FileSelectorButtonText");
-    cancelButtonText_->SetStyle("FileSelectorButtonText");
-
-    titleLayout->SetStyle("FileSelectorLayout");
-    fileNameLayout_->SetStyle("FileSelectorLayout");
-    buttonLayout_->SetStyle("FileSelectorLayout");
-    separatorLayout_->SetStyle("EditorSeparator");
-
-    fileList_->SetStyle("FileSelectorListView");
-    fileNameEdit_->SetStyle("FileSelectorLineEdit");
-    pathEdit_->SetStyle("FileSelectorLineEdit");
-
-    filterList_->SetStyle("FileSelectorFilterList");
-
-    okButton_->SetStyle("FileSelectorButton");
-    cancelButton_->SetStyle("FileSelectorButton");
-
-    const Vector<SharedPtr<UIElement> >& filterTexts = filterList_->GetListView()->GetContentElement()->GetChildren();
-    for (unsigned i = 0; i < filterTexts.Size(); ++i)
-        filterTexts[i]->SetStyle("FileSelectorFilterText");
-
-    const Vector<SharedPtr<UIElement> >& listTexts = fileList_->GetContentElement()->GetChildren();
-    for (unsigned i = 0; i < listTexts.Size(); ++i)
-        listTexts[i]->SetStyle("FileSelectorListText");
-
-    UpdateElements();
-}
-
-void FileSelector::SetTitle(const String& text)
-{
-    titleText_->SetText(text);
-}
-
-void FileSelector::SetButtonTexts(const String& okText, const String& cancelText)
-{
-    okButtonText_->SetText(okText);
-    cancelButtonText_->SetText(cancelText);
-}
-
-void FileSelector::SetPath(const String& path)
-{
-    FileSystem* fileSystem = GetSubsystem<FileSystem>();
-    if (fileSystem->DirExists(path))
-    {
-        path_ = AddTrailingSlash(path);
-        SetLineEditText(pathEdit_, path_);
-        RefreshFiles();
-    }
-    else
-    {
-        // If path was invalid, restore the old path to the line edit
-        if (pathEdit_->GetText() != path_)
-            SetLineEditText(pathEdit_, path_);
-    }
-}
-
-void FileSelector::SetFileName(const String& fileName)
-{
-    SetLineEditText(fileNameEdit_, fileName);
-}
-
-void FileSelector::SetFilters(const Vector<String>& filters, unsigned defaultIndex)
-{
-    if (filters.Empty())
-        return;
-
-    ignoreEvents_ = true;
-
-    filters_ = filters;
-    filterList_->RemoveAllItems();
-    for (unsigned i = 0; i < filters_.Size(); ++i)
-    {
-        Text* filterText = new Text(context_);
-        filterList_->AddItem(filterText);
-        filterText->SetText(filters_[i]);
-        filterText->SetStyle("FileSelectorFilterText");
-    }
-    if (defaultIndex > filters.Size())
-        defaultIndex = 0;
-    filterList_->SetSelection(defaultIndex);
-
-    ignoreEvents_ = false;
-
-    if (GetFilter() != lastUsedFilter_)
-        RefreshFiles();
-}
-
-void FileSelector::SetDirectoryMode(bool enable)
-{
-    directoryMode_ = enable;
-}
-
-void FileSelector::UpdateElements()
-{
-    buttonLayout_->SetFixedHeight(Max(okButton_->GetHeight(), cancelButton_->GetHeight()));
-}
-
-XMLFile* FileSelector::GetDefaultStyle() const
-{
-    return window_->GetDefaultStyle(false);
-}
-
-const String& FileSelector::GetTitle() const
-{
-    return titleText_->GetText();
-}
-
-const String& FileSelector::GetFileName() const
-{
-    return fileNameEdit_->GetText();
-}
-
-const String& FileSelector::GetFilter() const
-{
-    Text* selectedFilter = static_cast<Text*>(filterList_->GetSelectedItem());
-    if (selectedFilter)
-        return selectedFilter->GetText();
-    else
-        return String::EMPTY;
-}
-
-unsigned FileSelector::GetFilterIndex() const
-{
-    return filterList_->GetSelection();
-}
-
-void FileSelector::SetLineEditText(LineEdit* edit, const String& text)
-{
-    ignoreEvents_ = true;
-    edit->SetText(text);
-    ignoreEvents_ = false;
-}
-
-void FileSelector::RefreshFiles()
-{
-    FileSystem* fileSystem = GetSubsystem<FileSystem>();
-
-    ignoreEvents_ = true;
-
-    fileList_->RemoveAllItems();
-    fileEntries_.Clear();
-
-    Vector<String> directories;
-    Vector<String> files;
-    fileSystem->ScanDir(directories, path_, "*", SCAN_DIRS, false);
-    fileSystem->ScanDir(files, path_, GetFilter(), SCAN_FILES, false);
-
-    fileEntries_.Reserve(directories.Size() + files.Size());
-
-    for (unsigned i = 0; i < directories.Size(); ++i)
-    {
-        FileSelectorEntry newEntry;
-        newEntry.name_ = directories[i];
-        newEntry.directory_ = true;
-        fileEntries_.Push(newEntry);
-    }
-
-    for (unsigned i = 0; i < files.Size(); ++i)
-    {
-        FileSelectorEntry newEntry;
-        newEntry.name_ = files[i];
-        newEntry.directory_ = false;
-        fileEntries_.Push(newEntry);
-    }
-
-    // Sort and add to the list view
-    // While items are being added, disable layout update for performance optimization
-    Sort(fileEntries_.Begin(), fileEntries_.End(), CompareEntries);
-    UIElement* listContent = fileList_->GetContentElement();
-    listContent->DisableLayoutUpdate();
-    for (unsigned i = 0; i < fileEntries_.Size(); ++i)
-    {
-        String displayName;
-        if (fileEntries_[i].directory_)
-            displayName = "<DIR> " + fileEntries_[i].name_;
-        else
-            displayName = fileEntries_[i].name_;
-
-        Text* entryText = new Text(context_);
-        fileList_->AddItem(entryText);
-        entryText->SetText(displayName);
-        entryText->SetStyle("FileSelectorListText");
-    }
-    listContent->EnableLayoutUpdate();
-    listContent->UpdateLayout();
-
-    ignoreEvents_ = false;
-
-    // Clear filename from the previous dir so that there is no confusion
-    SetFileName(String::EMPTY);
-    lastUsedFilter_ = GetFilter();
-}
-
-bool FileSelector::EnterFile()
-{
-    unsigned index = fileList_->GetSelection();
-    if (index >= fileEntries_.Size())
-        return false;
-
-    if (fileEntries_[index].directory_)
-    {
-        // If a directory double clicked, enter it. Recognize . and .. as a special case
-        const String& newPath = fileEntries_[index].name_;
-        if ((newPath != ".") &&  (newPath != ".."))
-            SetPath(path_ + newPath);
-        else if (newPath == "..")
-        {
-            String parentPath = GetParentPath(path_);
-            SetPath(parentPath);
-        }
-
-        return true;
-    }
-    else
-    {
-        // Double clicking a file is the same as pressing OK
-        if (!directoryMode_)
-        {
-            using namespace FileSelected;
-
-            VariantMap& eventData = GetEventDataMap();
-            eventData[P_FILENAME] = path_ + fileEntries_[index].name_;
-            eventData[P_FILTER] = GetFilter();
-            eventData[P_OK] = true;
-            SendEvent(E_FILESELECTED, eventData);
-        }
-    }
-
-    return false;
-}
-
-void FileSelector::HandleFilterChanged(StringHash eventType, VariantMap& eventData)
-{
-    if (ignoreEvents_)
-        return;
-
-    if (GetFilter() != lastUsedFilter_)
-        RefreshFiles();
-}
-
-void FileSelector::HandlePathChanged(StringHash eventType, VariantMap& eventData)
-{
-    if (ignoreEvents_)
-        return;
-
-    // Attempt to set path. Restores old if does not exist
-    SetPath(pathEdit_->GetText());
-}
-
-void FileSelector::HandleFileSelected(StringHash eventType, VariantMap& eventData)
-{
-    if (ignoreEvents_)
-        return;
-
-    unsigned index = fileList_->GetSelection();
-    if (index >= fileEntries_.Size())
-        return;
-    // If a file selected, update the filename edit field
-    if (!fileEntries_[index].directory_)
-        SetFileName(fileEntries_[index].name_);
-}
-
-void FileSelector::HandleFileDoubleClicked(StringHash eventType, VariantMap& eventData)
-{
-    if (ignoreEvents_)
-        return;
-
-    if (eventData[ItemDoubleClicked::P_BUTTON] == MOUSEB_LEFT)
-        EnterFile();
-}
-
-void FileSelector::HandleFileListKey(StringHash eventType, VariantMap& eventData)
-{
-    if (ignoreEvents_)
-        return;
-
-    using namespace UnhandledKey;
-
-    int key = eventData[P_KEY].GetInt();
-    if (key == KEY_RETURN || key == KEY_RETURN2 || key == KEY_KP_ENTER)
-    {
-        bool entered = EnterFile();
-        // When a key is used to enter a directory, select the first file if no selection
-        if (entered && !fileList_->GetSelectedItem())
-            fileList_->SetSelection(0);
-    }
-}
-
-void FileSelector::HandleOKPressed(StringHash eventType, VariantMap& eventData)
-{
-    if (ignoreEvents_)
-        return;
-
-    const String& fileName = GetFileName();
-
-    if (!directoryMode_)
-    {
-        if (!fileName.Empty())
-        {
-            using namespace FileSelected;
-
-            VariantMap& newEventData = GetEventDataMap();
-            newEventData[P_FILENAME] = path_ + GetFileName();
-            newEventData[P_FILTER] = GetFilter();
-            newEventData[P_OK] = true;
-            SendEvent(E_FILESELECTED, newEventData);
-        }
-    }
-    else if (eventType == E_RELEASED && !path_.Empty())
-    {
-        using namespace FileSelected;
-
-        VariantMap& newEventData = GetEventDataMap();
-        newEventData[P_FILENAME] = path_;
-        newEventData[P_FILTER] = GetFilter();
-        newEventData[P_OK] = true;
-        SendEvent(E_FILESELECTED, newEventData);
-    }
-}
-
-void FileSelector::HandleCancelPressed(StringHash eventType, VariantMap& eventData)
-{
-    if (ignoreEvents_)
-        return;
-
-    if (eventType == E_MODALCHANGED && eventData[ModalChanged::P_MODAL].GetBool())
-        return;
-
-    using namespace FileSelected;
-
-    VariantMap& newEventData = GetEventDataMap();
-    newEventData[P_FILENAME] = String::EMPTY;
-    newEventData[P_FILTER] = GetFilter();
-    newEventData[P_OK] = false;
-    SendEvent(E_FILESELECTED, newEventData);
-}
-
-}

+ 0 - 179
Source/Atomic/UI/FileSelector.h

@@ -1,179 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../Core/Object.h"
-
-namespace Atomic
-{
-
-class Button;
-class DropDownList;
-class Font;
-class LineEdit;
-class ListView;
-class ResourceCache;
-class Text;
-class UIElement;
-class Window;
-class XMLFile;
-
-/// %File selector's list entry (file or directory.)
-struct FileSelectorEntry
-{
-    /// Name.
-    String name_;
-    /// Directory flag.
-    bool directory_;
-};
-
-/// %File selector dialog.
-class ATOMIC_API FileSelector : public Object
-{
-    OBJECT(FileSelector);
-
-public:
-    /// Construct.
-    FileSelector(Context* context);
-    /// Destruct.
-    virtual ~FileSelector();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// Set fileselector UI style.
-    void SetDefaultStyle(XMLFile* style);
-    /// Set title text.
-    void SetTitle(const String& text);
-    /// Set button texts.
-    void SetButtonTexts(const String& okText, const String& cancelText);
-    /// Set current path.
-    void SetPath(const String& path);
-    /// Set current filename.
-    void SetFileName(const String& fileName);
-    /// Set filters.
-    void SetFilters(const Vector<String>& filters, unsigned defaultIndex);
-    /// Set directory selection mode. Default false.
-    void SetDirectoryMode(bool enable);
-    /// Update elements to layout properly. Call this after manually adjusting the sub-elements.
-    void UpdateElements();
-
-    /// Return the UI style file.
-    XMLFile* GetDefaultStyle() const;
-    /// Return fileselector window.
-    Window* GetWindow() const { return window_; }
-    /// Return window title text element.
-    Text* GetTitleText() const { return titleText_; }
-    /// Return file list.
-    ListView* GetFileList() const { return fileList_; }
-    /// Return path editor.
-    LineEdit* GetPathEdit() const { return pathEdit_; }
-    /// Return filename editor.
-    LineEdit* GetFileNameEdit() const { return fileNameEdit_; }
-    /// Return filter dropdown.
-    DropDownList* GetFilterList() const { return filterList_; }
-    /// Return OK button.
-    Button* GetOKButton() const { return okButton_; }
-    /// Return cancel button.
-    Button* GetCancelButton() const { return cancelButton_; }
-    /// Return close button.
-    Button* GetCloseButton() const { return closeButton_; }
-    /// Return window title.
-    const String& GetTitle() const;
-    /// Return current path.
-    const String& GetPath() const { return path_; }
-    /// Return current filename.
-    const String& GetFileName() const;
-    /// Return current filter.
-    const String& GetFilter() const;
-    /// Return current filter index.
-    unsigned GetFilterIndex() const;
-    /// Return directory mode flag.
-    bool GetDirectoryMode() const { return directoryMode_; }
-
-private:
-    /// Set the text of an edit field and ignore the resulting event.
-    void SetLineEditText(LineEdit* edit, const String& text);
-    /// Refresh the directory listing.
-    void RefreshFiles();
-    /// Enter a directory or confirm a file. Return true if a directory entered.
-    bool EnterFile();
-    /// Handle filter changed.
-    void HandleFilterChanged(StringHash eventType, VariantMap& eventData);
-    /// Handle path edited.
-    void HandlePathChanged(StringHash eventType, VariantMap& eventData);
-    /// Handle file selected from the list.
-    void HandleFileSelected(StringHash eventType, VariantMap& eventData);
-    /// Handle file doubleclicked from the list (enter directory / OK the file selection.)
-    void HandleFileDoubleClicked(StringHash eventType, VariantMap& eventData);
-    /// Handle file list key pressed.
-    void HandleFileListKey(StringHash eventType, VariantMap& eventData);
-    /// Handle OK button pressed.
-    void HandleOKPressed(StringHash eventType, VariantMap& eventData);
-    /// Handle cancel button pressed.
-    void HandleCancelPressed(StringHash eventType, VariantMap& eventData);
-
-    /// Fileselector window.
-    SharedPtr<Window> window_;
-    /// Title layout.
-    UIElement* titleLayout;
-    /// Window title text.
-    Text* titleText_;
-    /// File list.
-    ListView* fileList_;
-    /// Path editor.
-    LineEdit* pathEdit_;
-    /// Filename editor.
-    LineEdit* fileNameEdit_;
-    /// Filter dropdown.
-    DropDownList* filterList_;
-    /// OK button.
-    Button* okButton_;
-    /// OK button text.
-    Text* okButtonText_;
-    /// Cancel button.
-    Button* cancelButton_;
-    /// Cancel button text.
-    Text* cancelButtonText_;
-    /// Close button.
-    Button* closeButton_;
-    /// Filename and filter layout.
-    UIElement* fileNameLayout_;
-    /// Separator layout.
-    UIElement* separatorLayout_;
-    /// Button layout.
-    UIElement* buttonLayout_;
-    /// Current directory.
-    String path_;
-    /// Filters.
-    Vector<String> filters_;
-    /// File entries.
-    Vector<FileSelectorEntry> fileEntries_;
-    /// Filter used to get the file list.
-    String lastUsedFilter_;
-    /// Directory mode flag.
-    bool directoryMode_;
-    /// Ignore events flag, used when changing line edits manually.
-    bool ignoreEvents_;
-};
-
-}

+ 0 - 231
Source/Atomic/UI/Font.cpp

@@ -1,231 +0,0 @@
-//
-// Copyright (c) 2008-2015 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../IO/Deserializer.h"
-#include "../IO/FileSystem.h"
-#include "../UI/Font.h"
-#include "../UI/FontFaceBitmap.h"
-#include "../UI/FontFaceFreeType.h"
-#include "../Graphics/Graphics.h"
-#include "../Core/Profiler.h"
-#include "../Resource/ResourceCache.h"
-#include "../Resource/XMLElement.h"
-#include "../Resource/XMLFile.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-static const int MIN_POINT_SIZE = 1;
-static const int MAX_POINT_SIZE = 96;
-
-Font::Font(Context* context) :
-    Resource(context),
-    fontDataSize_(0),
-    absoluteOffset_(IntVector2::ZERO),
-    scaledOffset_(Vector2::ZERO),
-    fontType_(FONT_NONE),
-    sdfFont_(false)
-{
-}
-
-Font::~Font()
-{
-    // To ensure FreeType deallocates properly, first clear all faces, then release the raw font data
-    ReleaseFaces();
-    fontData_.Reset();
-}
-
-void Font::RegisterObject(Context* context)
-{
-    context->RegisterFactory<Font>();
-}
-
-bool Font::BeginLoad(Deserializer& source)
-{
-    // In headless mode, do not actually load, just return success
-    Graphics* graphics = GetSubsystem<Graphics>();
-    if (!graphics)
-        return true;
-
-    fontType_ = FONT_NONE;
-    faces_.Clear();
-
-    fontDataSize_ = source.GetSize();
-    if (fontDataSize_)
-    {
-        fontData_ = new unsigned char[fontDataSize_];
-        if (source.Read(&fontData_[0], fontDataSize_) != fontDataSize_)
-            return false;
-    }
-    else
-    {
-        fontData_.Reset();
-        return false;
-    }
-
-    String ext = GetExtension(GetName());
-    if (ext == ".ttf" || ext == ".otf" || ext == ".woff")
-    {
-        fontType_ = FONT_FREETYPE;
-        LoadParameters();
-    }
-    else if (ext == ".xml" || ext == ".fnt" || ext == ".sdf")
-        fontType_ = FONT_BITMAP;
-
-    sdfFont_ = ext == ".sdf";
-
-    SetMemoryUse(fontDataSize_);
-    return true;
-}
-
-bool Font::SaveXML(Serializer& dest, int pointSize, bool usedGlyphs, const String& indentation)
-{
-    FontFace* fontFace = GetFace(pointSize);
-    if (!fontFace)
-        return false;
-
-    PROFILE(FontSaveXML);
-
-    SharedPtr<FontFaceBitmap> packedFontFace(new FontFaceBitmap(this));
-    if (!packedFontFace->Load(fontFace, usedGlyphs))
-        return false;
-
-    return packedFontFace->Save(dest, pointSize, indentation);
-}
-
-void Font::SetAbsoluteGlyphOffset(const IntVector2& offset)
-{
-    absoluteOffset_ = offset;
-}
-
-void Font::SetScaledGlyphOffset(const Vector2& offset)
-{
-    scaledOffset_ = offset;
-}
-
-FontFace* Font::GetFace(int pointSize)
-{
-    // In headless mode, always return null
-    Graphics* graphics = GetSubsystem<Graphics>();
-    if (!graphics)
-        return 0;
-
-    // For bitmap font type, always return the same font face provided by the font's bitmap file regardless of the actual requested point size
-    if (fontType_ == FONT_BITMAP)
-        pointSize = 0;
-    else
-        pointSize = Clamp(pointSize, MIN_POINT_SIZE, MAX_POINT_SIZE);
-
-    HashMap<int, SharedPtr<FontFace> >::Iterator i = faces_.Find(pointSize);
-    if (i != faces_.End())
-    {
-        if (!i->second_->IsDataLost())
-            return i->second_;
-        else
-        {
-            // Erase and reload face if texture data lost (OpenGL mode only)
-            faces_.Erase(i);
-        }
-    }
-
-    PROFILE(GetFontFace);
-
-    switch (fontType_)
-    {
-    case FONT_FREETYPE:
-        return GetFaceFreeType(pointSize);
-
-    case FONT_BITMAP:
-        return GetFaceBitmap(pointSize);
-
-    default:
-        return 0;
-    }
-}
-
-IntVector2 Font::GetTotalGlyphOffset(int pointSize) const
-{
-    Vector2 multipliedOffset = (float)pointSize * scaledOffset_;
-    return absoluteOffset_ + IntVector2((int)multipliedOffset.x_, (int)multipliedOffset.y_);
-}
-
-void Font::ReleaseFaces()
-{
-    faces_.Clear();
-}
-
-void Font::LoadParameters()
-{
-    ResourceCache* cache = GetSubsystem<ResourceCache>();
-    String xmlName = ReplaceExtension(GetName(), ".xml");
-    SharedPtr<XMLFile> xml = cache->GetTempResource<XMLFile>(xmlName, false);
-    if (!xml)
-        return;
-    
-    XMLElement rootElem = xml->GetRoot();
-    
-    XMLElement absoluteElem = rootElem.GetChild("absoluteoffset");
-    if (!absoluteElem)
-        absoluteElem = rootElem.GetChild("absolute");
-    
-    if (absoluteElem)
-    {
-        absoluteOffset_.x_ = absoluteElem.GetInt("x");
-        absoluteOffset_.y_ = absoluteElem.GetInt("y");
-    }
-    
-    XMLElement scaledElem = rootElem.GetChild("scaledoffset");
-    if (!scaledElem)
-        scaledElem = rootElem.GetChild("scaled");
-    
-    if (scaledElem)
-    {
-        scaledOffset_.x_ = scaledElem.GetFloat("x");
-        scaledOffset_.y_ = scaledElem.GetFloat("y");
-    }
-}
-
-FontFace* Font::GetFaceFreeType(int pointSize)
-{
-    SharedPtr<FontFace> newFace(new FontFaceFreeType(this));
-    if (!newFace->Load(&fontData_[0], fontDataSize_, pointSize))
-        return 0;
-
-    faces_[pointSize] = newFace;
-    return newFace;
-}
-
-FontFace* Font::GetFaceBitmap(int pointSize)
-{
-    SharedPtr<FontFace> newFace(new FontFaceBitmap(this));
-    if (!newFace->Load(&fontData_[0], fontDataSize_, pointSize))
-        return 0;
-
-    faces_[pointSize] = newFace;
-    return newFace;
-}
-
-}

+ 0 - 105
Source/Atomic/UI/Font.h

@@ -1,105 +0,0 @@
-//
-// Copyright (c) 2008-2015 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../Container/ArrayPtr.h"
-#include "../Resource/Resource.h"
-
-namespace Atomic
-{
-
-class FontFace;
-
-static const int FONT_TEXTURE_MIN_SIZE = 128;
-static const int FONT_DPI = 96;
-
-/// %Font file type.
-enum FONT_TYPE
-{
-    FONT_NONE = 0,
-    FONT_FREETYPE,
-    FONT_BITMAP,
-    MAX_FONT_TYPES
-};
-
-/// %Font resource.
-class ATOMIC_API Font : public Resource
-{
-    OBJECT(Font);
-
-public:
-    /// Construct.
-    Font(Context* context);
-    /// Destruct.
-    virtual ~Font();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// Load resource from stream. May be called from a worker thread. Return true if successful.
-    virtual bool BeginLoad(Deserializer& source);
-    /// Save resource as a new bitmap font type in XML format. Return true if successful.
-    bool SaveXML(Serializer& dest, int pointSize, bool usedGlyphs = false, const String& indentation = "\t");
-    /// Set absolute (in pixels) position adjustment for glyphs.
-    void SetAbsoluteGlyphOffset(const IntVector2& offset);
-    /// Set point size scaled position adjustment for glyphs.
-    void SetScaledGlyphOffset(const Vector2& offset);
-
-    /// Return font face. Pack and render to a texture if not rendered yet. Return null on error.
-    FontFace* GetFace(int pointSize);
-    /// Is signed distance field font.
-    bool IsSDFFont() const { return sdfFont_; }
-    /// Return absolute position adjustment for glyphs.
-    const IntVector2& GetAbsoluteGlyphOffset() const { return absoluteOffset_; }
-    /// Return point size scaled position adjustment for glyphs.
-    const Vector2& GetScaledGlyphOffset() const { return scaledOffset_; }
-    /// Return the total effective offset for a point size.
-    IntVector2 GetTotalGlyphOffset(int pointSize) const;
-    
-    /// Release font faces and recreate them next time when requested. Called when font textures lost or global font properties change.
-    void ReleaseFaces();
-    
-private:
-    /// Load font glyph offset parameters from an optional XML file. Called internally when loading TrueType fonts.
-    void LoadParameters();
-    /// Return font face using FreeType. Called internally. Return null on error.
-    FontFace* GetFaceFreeType(int pointSize);
-    /// Return bitmap font face. Called internally. Return null on error.
-    FontFace* GetFaceBitmap(int pointSize);
-    
-    /// Created faces.
-    HashMap<int, SharedPtr<FontFace> > faces_;
-    /// Font data.
-    SharedArrayPtr<unsigned char> fontData_;
-    /// Size of font data.
-    unsigned fontDataSize_;
-    /// Absolute position adjustment for glyphs.
-    IntVector2 absoluteOffset_;
-    /// Point size scaled position adjustment for glyphs.
-    Vector2 scaledOffset_;
-    /// Font type.
-    FONT_TYPE fontType_;
-    /// Signed distance field font flag.
-    bool sdfFont_;
-};
-
-}

+ 0 - 125
Source/Atomic/UI/FontFace.cpp

@@ -1,125 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../UI/Font.h"
-#include "../UI/FontFace.h"
-#include "../Resource/Image.h"
-#include "../IO/Log.h"
-#include "../Graphics/Texture2D.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-FontGlyph::FontGlyph() :
-    page_(M_MAX_UNSIGNED),
-    used_(false)
-{
-}
-
-FontFace::FontFace(Font* font) :
-    font_(font)
-{
-}
-
-FontFace::~FontFace()
-{
-    if (font_)
-    {
-        // When a face is unloaded, deduct the used texture data size from the parent font
-        unsigned totalTextureSize = 0;
-        for (unsigned i = 0; i < textures_.Size(); ++i)
-            totalTextureSize += textures_[i]->GetWidth() * textures_[i]->GetHeight();
-        font_->SetMemoryUse(font_->GetMemoryUse() - totalTextureSize);
-    }
-}
-
-const FontGlyph* FontFace::GetGlyph(unsigned c)
-{
-    HashMap<unsigned, FontGlyph>::Iterator i = glyphMapping_.Find(c);
-    if (i != glyphMapping_.End())
-    {
-        FontGlyph& glyph = i->second_;
-        glyph.used_ = true;
-        return &glyph;
-    }
-    else
-        return 0;
-}
-
-short FontFace::GetKerning(unsigned c, unsigned d) const
-{
-    if (kerningMapping_.Empty())
-        return 0;
-
-    if (c == '\n' || d == '\n')
-        return 0;
-
-    if (c > 0xffff || d > 0xffff)
-        return 0;
-
-    unsigned value = (c << 16) + d;
-
-    HashMap<unsigned, short>::ConstIterator i = kerningMapping_.Find(value);
-    if (i != kerningMapping_.End())
-        return i->second_;
-
-    return 0;
-}
-
-bool FontFace::IsDataLost() const
-{
-    for (unsigned i = 0; i < textures_.Size(); ++i)
-    {
-        if (textures_[i]->IsDataLost())
-            return true;
-    }
-    return false;
-}
-
-
-SharedPtr<Texture2D> FontFace::CreateFaceTexture()
-{
-    SharedPtr<Texture2D> texture(new Texture2D(font_->GetContext()));
-    texture->SetMipsToSkip(QUALITY_LOW, 0); // No quality reduction
-    texture->SetNumLevels(1); // No mipmaps
-    texture->SetAddressMode(COORD_U, ADDRESS_BORDER);
-    texture->SetAddressMode(COORD_V, ADDRESS_BORDER),
-        texture->SetBorderColor(Color(0.0f, 0.0f, 0.0f, 0.0f));
-    return texture;
-}
-
-SharedPtr<Texture2D> FontFace::LoadFaceTexture(SharedPtr<Image> image)
-{
-    SharedPtr<Texture2D> texture = CreateFaceTexture();
-    if (!texture->SetData(image, true))
-    {
-        LOGERROR("Could not load texture from image resource");
-        return SharedPtr<Texture2D>();
-    }
-    return texture;
-}
-
-}

+ 0 - 111
Source/Atomic/UI/FontFace.h

@@ -1,111 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../Math/AreaAllocator.h"
-#include "../Container/ArrayPtr.h"
-#include "../Container/List.h"
-
-namespace Atomic
-{
-
-class Font;
-class Image;
-class Texture2D;
-
-/// %Font glyph description.
-struct FontGlyph
-{
-    /// Construct.
-    FontGlyph();
-
-    /// X position in texture.
-    short x_;
-    /// Y position in texture.
-    short y_;
-    /// Width.
-    short width_;
-    /// Height.
-    short height_;
-    /// Glyph X offset from origin.
-    short offsetX_;
-    /// Glyph Y offset from origin.
-    short offsetY_;
-    /// Horizontal advance.
-    short advanceX_;
-    /// Texture page. M_MAX_UNSIGNED if not yet resident on any texture.
-    unsigned page_;
-    /// Used flag.
-    bool used_;
-};
-
-/// %Font face description.
-class ATOMIC_API FontFace : public RefCounted
-{
-    friend class Font;
-
-public:
-    /// Construct.
-    FontFace(Font* font);
-    /// Destruct.
-    ~FontFace();
-
-    /// Load font face.
-    virtual bool Load(const unsigned char* fontData, unsigned fontDataSize, int pointSize) = 0;
-    /// Return pointer to the glyph structure corresponding to a character. Return null if glyph not found.
-    virtual const FontGlyph* GetGlyph(unsigned c);
-    /// Return if font face uses mutable glyphs.
-    virtual bool HasMutableGlyphs() const { return false; }
-    /// Return the kerning for a character and the next character.
-    short GetKerning(unsigned c, unsigned d) const;
-    /// Return true when one of the texture has a data loss.
-    bool IsDataLost() const;
-    /// Return point size.
-    int GetPointSize() const { return pointSize_; }
-    /// Return row height.
-    int GetRowHeight() const { return rowHeight_; }
-    /// Return textures.
-    const Vector<SharedPtr<Texture2D> >& GetTextures() const { return textures_; }
-
-protected:
-    friend class FontFaceBitmap;
-    /// Create a texture for font rendering.
-    SharedPtr<Texture2D> CreateFaceTexture();
-    /// Load font face texture from image resource.
-    SharedPtr<Texture2D> LoadFaceTexture(SharedPtr<Image> image);
-
-    /// Parent font.
-    Font* font_;
-    /// Glyph mapping.
-    HashMap<unsigned, FontGlyph> glyphMapping_;
-    /// Kerning mapping.
-    HashMap<unsigned, short> kerningMapping_;
-    /// Glyph texture pages.
-    Vector<SharedPtr<Texture2D> > textures_;
-    /// Point size.
-    int pointSize_;
-    /// Row height.
-    int rowHeight_;
-};
-
-}

+ 0 - 387
Source/Atomic/UI/FontFaceBitmap.cpp

@@ -1,387 +0,0 @@
-//
-// Copyright (c) 2008-2015 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../IO/File.h"
-#include "../IO/FileSystem.h"
-#include "../UI/Font.h"
-#include "../UI/FontFaceBitmap.h"
-#include "../Graphics/Graphics.h"
-#include "../Resource/Image.h"
-#include "../IO/Log.h"
-#include "../IO/MemoryBuffer.h"
-#include "../Resource/ResourceCache.h"
-#include "../Graphics/Texture2D.h"
-#include "../UI/UI.h"
-#include "../Resource/XMLFile.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-FontFaceBitmap::FontFaceBitmap(Font* font) :
-    FontFace(font)
-{
-}
-
-FontFaceBitmap::~FontFaceBitmap()
-{
-}
-
-bool FontFaceBitmap::Load(const unsigned char* fontData, unsigned fontDataSize, int pointSize)
-{
-    Context* context = font_->GetContext();
-
-    SharedPtr<XMLFile> xmlReader(new XMLFile(context));
-    MemoryBuffer memoryBuffer(fontData, fontDataSize);
-    if (!xmlReader->Load(memoryBuffer))
-    {
-        LOGERROR("Could not load XML file");
-        return false;
-    }
-
-    XMLElement root = xmlReader->GetRoot("font");
-    if (root.IsNull())
-    {
-        LOGERROR("Could not find Font element");
-        return false;
-    }
-
-    XMLElement pagesElem = root.GetChild("pages");
-    if (pagesElem.IsNull())
-    {
-        LOGERROR("Could not find Pages element");
-        return false;
-    }
-
-    XMLElement infoElem = root.GetChild("info");
-    if (!infoElem.IsNull())
-        pointSize_ = infoElem.GetInt("size");
-
-    XMLElement commonElem = root.GetChild("common");
-    rowHeight_ = commonElem.GetInt("lineHeight");
-    unsigned pages = commonElem.GetInt("pages");
-    textures_.Reserve(pages);
-
-    ResourceCache* resourceCache = font_->GetSubsystem<ResourceCache>();
-    String fontPath = GetPath(font_->GetName());
-    unsigned totalTextureSize = 0;
-
-    XMLElement pageElem = pagesElem.GetChild("page");
-    for (unsigned i = 0; i < pages; ++i)
-    {
-        if (pageElem.IsNull())
-        {
-            LOGERROR("Could not find Page element for page: " + String(i));
-            return 0;
-        }
-
-        // Assume the font image is in the same directory as the font description file
-        String textureFile = fontPath + pageElem.GetAttribute("file");
-
-        // Load texture manually to allow controlling the alpha channel mode
-        SharedPtr<File> fontFile = resourceCache->GetFile(textureFile);
-        SharedPtr<Image> fontImage(new Image(context));
-        if (!fontFile || !fontImage->Load(*fontFile))
-        {
-            LOGERROR("Failed to load font image file");
-            return 0;
-        }
-        SharedPtr<Texture2D> texture = LoadFaceTexture(fontImage);
-        if (!texture)
-            return 0;
-        
-        textures_.Push(texture);
-
-        // Add texture to resource cache
-        texture->SetName(fontFile->GetName());
-        resourceCache->AddManualResource(texture);
-
-        totalTextureSize += fontImage->GetWidth() * fontImage->GetHeight() * fontImage->GetComponents();
-
-        pageElem = pageElem.GetNext("page");
-    }
-
-    XMLElement charsElem = root.GetChild("chars");
-    int count = charsElem.GetInt("count");
-
-    XMLElement charElem = charsElem.GetChild("char");
-    while (!charElem.IsNull())
-    {
-        int id = charElem.GetInt("id");
-
-        FontGlyph glyph;
-        glyph.x_ = charElem.GetInt("x");
-        glyph.y_ = charElem.GetInt("y");
-        glyph.width_ = charElem.GetInt("width");
-        glyph.height_ = charElem.GetInt("height");
-        glyph.offsetX_ = charElem.GetInt("xoffset");
-        glyph.offsetY_ = charElem.GetInt("yoffset");
-        glyph.advanceX_ = charElem.GetInt("xadvance");
-        glyph.page_ = charElem.GetInt("page");
-
-        glyphMapping_[id] = glyph;
-
-        charElem = charElem.GetNext("char");
-    }
-
-    XMLElement kerningsElem = root.GetChild("kernings");
-    if (kerningsElem.NotNull())
-    {
-        XMLElement kerningElem = kerningsElem.GetChild("kerning");
-        while (!kerningElem.IsNull())
-        {
-            int first = kerningElem.GetInt("first");
-            int second = kerningElem.GetInt("second");
-            unsigned value = (first << 16) + second;
-            kerningMapping_[value] = (short)kerningElem.GetInt("amount");
-
-            kerningElem = kerningElem.GetNext("kerning");
-        }
-    }
-
-    LOGDEBUGF("Bitmap font face %s has %d glyphs", GetFileName(font_->GetName()).CString(), count);
-
-    font_->SetMemoryUse(font_->GetMemoryUse() + totalTextureSize);
-    return true;
-}
-
-bool FontFaceBitmap::Load(FontFace* fontFace, bool usedGlyphs)
-{
-    if (this == fontFace)
-        return true;
-
-    if (!usedGlyphs)
-    {
-        glyphMapping_ = fontFace->glyphMapping_;
-        kerningMapping_ = fontFace->kerningMapping_;
-        textures_ = fontFace->textures_;
-        pointSize_ = fontFace->pointSize_;
-        rowHeight_ = fontFace->rowHeight_;
-
-        return true;
-    }
-
-    pointSize_ = fontFace->pointSize_;
-    rowHeight_ = fontFace->rowHeight_;
-
-    int numPages = 1;
-    int maxTextureSize = font_->GetSubsystem<UI>()->GetMaxFontTextureSize();
-    AreaAllocator allocator(FONT_TEXTURE_MIN_SIZE, FONT_TEXTURE_MIN_SIZE, maxTextureSize, maxTextureSize);
-
-    for (HashMap<unsigned, FontGlyph>::ConstIterator i = fontFace->glyphMapping_.Begin(); i != fontFace->glyphMapping_.End(); ++i)
-    {
-        FontGlyph fontGlyph = i->second_;
-        if (!fontGlyph.used_)
-            continue;
-
-        int x, y;
-        if (!allocator.Allocate(fontGlyph.width_ + 1, fontGlyph.height_ + 1, x, y))
-        {
-            ++numPages;
-
-            allocator = AreaAllocator(FONT_TEXTURE_MIN_SIZE, FONT_TEXTURE_MIN_SIZE, maxTextureSize, maxTextureSize);
-            if (!allocator.Allocate(fontGlyph.width_ + 1, fontGlyph.height_ + 1, x, y))
-                return false;
-        }
-
-        fontGlyph.x_ = x;
-        fontGlyph.y_ = y;
-        fontGlyph.page_ = numPages - 1;
-
-        glyphMapping_[i->first_] = fontGlyph;
-    }
-
-    // Assume that format is the same for all textures and that bitmap font type may have more than one component
-    unsigned components = ConvertFormatToNumComponents(fontFace->textures_[0]->GetFormat());
-
-    // Save the existing textures as image resources
-    Vector<SharedPtr<Image> > oldImages;
-    for (unsigned i = 0; i < fontFace->textures_.Size(); ++i)
-        oldImages.Push(SaveFaceTexture(fontFace->textures_[i]));
-
-    Vector<SharedPtr<Image> > newImages(numPages);
-    for (int i = 0; i < numPages; ++i)
-    {
-        SharedPtr<Image> image(new Image(font_->GetContext()));
-
-        int width = maxTextureSize;
-        int height = maxTextureSize;
-        if (i == numPages - 1)
-        {
-            width = allocator.GetWidth();
-            height = allocator.GetHeight();
-        }
-
-        image->SetSize(width, height, components);
-        memset(image->GetData(), 0, width * height * components);
-
-        newImages.Push(image);
-    }
-
-    for (HashMap<unsigned, FontGlyph>::Iterator i = glyphMapping_.Begin(); i != glyphMapping_.End(); ++i)
-    {
-        FontGlyph& newGlyph = i->second_;
-        const FontGlyph& oldGlyph = fontFace->glyphMapping_[i->first_];
-        Blit(newImages[newGlyph.page_], newGlyph.x_, newGlyph.y_, newGlyph.width_, newGlyph.height_, oldImages[oldGlyph.page_], oldGlyph.x_, oldGlyph.y_, components);
-    }
-
-    textures_.Resize(newImages.Size());
-    for (unsigned i = 0; i < newImages.Size(); ++i)
-        textures_[i] = LoadFaceTexture(newImages[i]);
-
-    for (HashMap<unsigned, short>::ConstIterator i = fontFace->kerningMapping_.Begin(); i != fontFace->kerningMapping_.End(); ++i)
-    {
-        unsigned first = (i->first_) >> 16;
-        unsigned second = (i->first_) & 0xffff;
-        if (glyphMapping_.Find(first) != glyphMapping_.End() && glyphMapping_.Find(second) != glyphMapping_.End())
-            kerningMapping_[i->first_] = i->second_;
-    }
-
-    return true;
-}
-
-bool FontFaceBitmap::Save(Serializer& dest, int pointSize, const String& indentation)
-{
-    Context* context = font_->GetContext();
-
-    SharedPtr<XMLFile> xml(new XMLFile(context));
-    XMLElement rootElem = xml->CreateRoot("font");
-
-    // Information
-    XMLElement childElem = rootElem.CreateChild("info");
-    String fileName = GetFileName(font_->GetName());
-    childElem.SetAttribute("face", fileName);
-    childElem.SetAttribute("size", String(pointSize));
-
-    // Common
-    childElem = rootElem.CreateChild("common");
-    childElem.SetInt("lineHeight", rowHeight_);
-    unsigned pages = textures_.Size();
-    childElem.SetInt("pages", pages);
-
-    // Construct the path to store the texture
-    String pathName;
-    File* file = dynamic_cast<File*>(&dest);
-    if (file)
-        // If serialize to file, use the file's path
-        pathName = GetPath(file->GetName());
-    else
-        // Otherwise, use the font resource's path
-        pathName = "Data/" + GetPath(font_->GetName());
-
-    // Pages
-    childElem = rootElem.CreateChild("pages");
-    for (unsigned i = 0; i < pages; ++i)
-    {
-        XMLElement pageElem = childElem.CreateChild("page");
-        pageElem.SetInt("id", i);
-        String texFileName = fileName + "_" + String(i) + ".png";
-        pageElem.SetAttribute("file", texFileName);
-
-        // Save the font face texture to image file
-        SaveFaceTexture(textures_[i], pathName + texFileName);
-    }
-
-    // Chars and kernings
-    XMLElement charsElem = rootElem.CreateChild("chars");
-    unsigned numGlyphs = glyphMapping_.Size();
-    charsElem.SetInt("count", numGlyphs);
-
-    for (HashMap<unsigned, FontGlyph>::ConstIterator i = glyphMapping_.Begin(); i != glyphMapping_.End(); ++i)
-    {
-        // Char
-        XMLElement charElem = charsElem.CreateChild("char");
-        charElem.SetInt("id", i->first_);
-
-        const FontGlyph& glyph = i->second_;
-        charElem.SetInt("x", glyph.x_);
-        charElem.SetInt("y", glyph.y_);
-        charElem.SetInt("width", glyph.width_);
-        charElem.SetInt("height", glyph.height_);
-        charElem.SetInt("xoffset", glyph.offsetX_);
-        charElem.SetInt("yoffset", glyph.offsetY_);
-        charElem.SetInt("xadvance", glyph.advanceX_);
-        charElem.SetInt("page", glyph.page_);
-    }
-
-    if (!kerningMapping_.Empty())
-    {
-        XMLElement kerningsElem = rootElem.CreateChild("kernings");
-        for (HashMap<unsigned, short>::ConstIterator i = kerningMapping_.Begin(); i != kerningMapping_.End(); ++i)
-        {
-            XMLElement kerningElem = kerningsElem.CreateChild("kerning");
-            kerningElem.SetInt("first", i->first_ >> 16);
-            kerningElem.SetInt("second", i->first_ & 0xffff);
-            kerningElem.SetInt("amount", i->second_);
-        }
-    }
-
-    return xml->Save(dest, indentation);
-}
-
-unsigned FontFaceBitmap::ConvertFormatToNumComponents(unsigned format)
-{
-    if (format == Graphics::GetRGBAFormat())
-        return 4;
-    else if (format == Graphics::GetRGBFormat())
-        return 3;
-    else if (format == Graphics::GetLuminanceAlphaFormat())
-        return 2;
-    else
-        return 1;
-}
-
-SharedPtr<Image> FontFaceBitmap::SaveFaceTexture(Texture2D* texture)
-{
-    Image* image = new Image(font_->GetContext());
-    image->SetSize(texture->GetWidth(), texture->GetHeight(), ConvertFormatToNumComponents(texture->GetFormat()));
-    if (!static_cast<Texture2D*>(texture)->GetData(0, image->GetData()))
-    {
-        delete image;
-        LOGERROR("Could not save texture to image resource");
-        return SharedPtr<Image>();
-    }
-    return SharedPtr<Image>(image);
-}
-
-bool FontFaceBitmap::SaveFaceTexture(Texture2D* texture, const String& fileName)
-{
-    SharedPtr<Image> image = SaveFaceTexture(texture);
-    return image ? image->SavePNG(fileName) : false;
-}
-
-void FontFaceBitmap::Blit(Image* dest, int x, int y, int width, int height, Image* source, int sourceX, int sourceY, int components)
-{
-    unsigned char* destData = dest->GetData() + (y * dest->GetWidth() + x) * components;
-    unsigned char* sourceData = source->GetData() + (sourceY * source->GetWidth() + sourceX) * components;
-    for (int i = 0; i < height; ++i)
-    {
-        memcpy(destData, sourceData, width * components);
-        destData += dest->GetWidth() * components;
-        sourceData += source->GetWidth() * components;
-    }
-}
-
-}

+ 0 - 60
Source/Atomic/UI/FontFaceBitmap.h

@@ -1,60 +0,0 @@
-//
-// Copyright (c) 2008-2015 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/FontFace.h"
-
-namespace Atomic
-{
-
-class Image;
-class Serializer;
-
-/// Bitmap font face description.
-class ATOMIC_API FontFaceBitmap : public FontFace
-{
-public:
-    /// Construct.
-    FontFaceBitmap(Font* font);
-    /// Destruct.
-    ~FontFaceBitmap();
-
-    /// Load font face.
-    virtual bool Load(const unsigned char* fontData, unsigned fontDataSize, int pointSize);
-    /// Load from existed font face, pack used glyphs into smallest texture size and smallest number of texture.
-    bool Load(FontFace* fontFace, bool usedGlyphs);
-    /// Save as a new bitmap font type in XML format. Return true if successful.
-    bool Save(Serializer& dest, int pointSize, const String& indentation = "\t");
-
-private:
-    /// Convert graphics format to number of components.
-    unsigned ConvertFormatToNumComponents(unsigned format);
-    /// Save font face texture as image resource.
-    SharedPtr<Image> SaveFaceTexture(Texture2D* texture);
-    /// Save font face texture as image file.
-    bool SaveFaceTexture(Texture2D* texture, const String& fileName);
-    /// Blit.
-    void Blit(Image* dest, int x, int y, int width, int height, Image* source, int sourceX, int sourceY, int components);
-};
-
-}

+ 0 - 454
Source/Atomic/UI/FontFaceFreeType.cpp

@@ -1,454 +0,0 @@
-//
-// Copyright (c) 2008-2015 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "../Core/Context.h"
-#include "../IO/FileSystem.h"
-#include "../UI/Font.h"
-#include "../UI/FontFaceFreeType.h"
-#include "../Graphics/Graphics.h"
-#include "../Resource/Image.h"
-#include "../IO/Log.h"
-#include "../IO/MemoryBuffer.h"
-#include "../Graphics/Texture2D.h"
-#include "../UI/UI.h"
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_TRUETYPE_TABLES_H
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-/// FreeType library subsystem.
-class FreeTypeLibrary : public Object
-{
-    OBJECT(FreeTypeLibrary);
-
-public:
-    /// Construct.
-    FreeTypeLibrary(Context* context) :
-        Object(context)
-        {
-            FT_Error error = FT_Init_FreeType(&library_);
-            if (error)
-                LOGERROR("Could not initialize FreeType library");
-        }
-
-        /// Destruct.
-        virtual ~FreeTypeLibrary()
-        {
-            FT_Done_FreeType(library_);
-        }
-
-        FT_Library GetLibrary() const { return library_; }
-
-private:
-    /// FreeType library.
-    FT_Library library_;
-};
-
-FontFaceFreeType::FontFaceFreeType(Font* font) :
-FontFace(font),
-    face_(0), 
-    loadMode_(FT_LOAD_DEFAULT)
-{
-}
-
-FontFaceFreeType::~FontFaceFreeType()
-{
-    if (face_)
-    {
-        FT_Done_Face((FT_Face)face_);
-        face_ = 0;
-    }
-}
-
-bool FontFaceFreeType::Load(const unsigned char* fontData, unsigned fontDataSize, int pointSize)
-{
-    Context* context = font_->GetContext();
-
-    // Create & initialize FreeType library if it does not exist yet
-    FreeTypeLibrary* freeType = font_->GetSubsystem<FreeTypeLibrary>();
-    if (!freeType)
-        context->RegisterSubsystem(freeType = new FreeTypeLibrary(context));
-
-    // Ensure the FreeType library is kept alive as long as TTF font resources exist
-    freeType_ = freeType;
-
-    UI* ui = font_->GetSubsystem<UI>();
-    int maxTextureSize = ui->GetMaxFontTextureSize();
-
-    FT_Face face;
-    FT_Error error;
-    FT_Library library = freeType->GetLibrary();
-
-    if (pointSize <= 0)
-    {
-        LOGERROR("Zero or negative point size");
-        return false;
-    }
-
-    if (!fontDataSize)
-    {
-        LOGERROR("Could not create font face from zero size data");
-        return false;
-    }
-
-    error = FT_New_Memory_Face(library, fontData, fontDataSize, 0, &face);
-    if (error)
-    {
-        LOGERROR("Could not create font face");
-        return false;
-    }
-    error = FT_Set_Char_Size(face, 0, pointSize * 64, FONT_DPI, FONT_DPI);
-    if (error)
-    {
-        FT_Done_Face(face);
-        LOGERROR("Could not set font point size " + String(pointSize));
-        return false;
-    }
-
-    face_ = face;
-
-    unsigned numGlyphs = face->num_glyphs;
-    LOGDEBUGF("Font face %s (%dpt) has %d glyphs", GetFileName(font_->GetName()).CString(), pointSize, numGlyphs);
-    
-    PODVector<unsigned> charCodes(numGlyphs);
-    for (unsigned i = 0; i < numGlyphs; ++i)
-        charCodes[i] = 0;
-
-    FT_UInt glyphIndex;
-    FT_ULong charCode = FT_Get_First_Char(face, &glyphIndex);
-    while (glyphIndex != 0)
-    {
-        if (glyphIndex < numGlyphs)
-            charCodes[glyphIndex] = charCode;
-
-        charCode = FT_Get_Next_Char(face, charCode, &glyphIndex);
-    }
-
-    // Load each of the glyphs to see the sizes & store other information
-    loadMode_ = ui->GetForceAutoHint() ? FT_LOAD_FORCE_AUTOHINT : FT_LOAD_DEFAULT;
-    ascender_ = face->size->metrics.ascender >> 6;
-    int descender = face->size->metrics.descender >> 6;
-
-    // Check if the font's OS/2 info gives different (larger) values for ascender & descender
-    TT_OS2* os2Info = (TT_OS2*)FT_Get_Sfnt_Table(face, ft_sfnt_os2);
-    if (os2Info)
-    {
-        ascender_ = Max(ascender_, os2Info->usWinAscent * face->size->metrics.y_ppem / face->units_per_EM);
-        ascender_ = Max(ascender_, os2Info->sTypoAscender * face->size->metrics.y_ppem / face->units_per_EM);
-        descender = Max(descender, os2Info->usWinDescent * face->size->metrics.y_ppem / face->units_per_EM);
-        descender = Max(descender, os2Info->sTypoDescender * face->size->metrics.y_ppem / face->units_per_EM);
-    }
-
-    // Store point size and row height. Use the maximum of ascender + descender, or the face's stored default row height
-    pointSize_ = pointSize;
-    rowHeight_ = Max(ascender_ + descender, face->size->metrics.height >> 6);
-
-    int textureWidth = maxTextureSize;
-    int textureHeight = maxTextureSize;
-    bool loadAllGlyphs = CanLoadAllGlyphs(charCodes, textureWidth, textureHeight);
-
-    SharedPtr<Image> image(new Image(font_->GetContext()));
-    image->SetSize(textureWidth, textureHeight, 1);
-    unsigned char* imageData = image->GetData();
-    memset(imageData, 0, image->GetWidth() * image->GetHeight());
-    allocator_.Reset(FONT_TEXTURE_MIN_SIZE, FONT_TEXTURE_MIN_SIZE, textureWidth, textureHeight);
-
-    for (unsigned i = 0; i < numGlyphs; ++i)
-    {
-        unsigned charCode = charCodes[i];
-        if (charCode == 0)
-            continue;
-        
-        if (!loadAllGlyphs && (charCode > 0xff))
-            break;
-
-        if (!LoadCharGlyph(charCode, image))
-            return false;
-    }
-
-    SharedPtr<Texture2D> texture = LoadFaceTexture(image);
-    if (!texture)
-        return false;
-
-    textures_.Push(texture);
-    font_->SetMemoryUse(font_->GetMemoryUse() + textureWidth * textureHeight);
-
-    // Store kerning if face has kerning information
-    if (FT_HAS_KERNING(face))
-    {
-        // Read kerning manually to be more efficient and avoid out of memory crash when use large font file, for example there
-        // are 29354 glyphs in msyh.ttf
-        FT_ULong tagKern = FT_MAKE_TAG('k', 'e', 'r', 'n');
-        FT_ULong kerningTableSize = 0;
-        FT_Error error = FT_Load_Sfnt_Table(face, tagKern, 0, NULL, &kerningTableSize);
-        if (error)
-        {
-            LOGERROR("Could not get kerning table length");
-            return false;
-        }
-
-        SharedArrayPtr<unsigned char> kerningTable(new unsigned char[kerningTableSize]);
-        error = FT_Load_Sfnt_Table(face, tagKern, 0, kerningTable, &kerningTableSize);
-        if (error)
-        {
-            LOGERROR("Could not load kerning table");
-            return false;
-        }
-
-        // Convert big endian to little endian
-        for (unsigned i = 0; i < kerningTableSize; i += 2)
-            Swap(kerningTable[i], kerningTable[i + 1]);
-        MemoryBuffer deserializer(kerningTable, kerningTableSize);
-
-        unsigned short version = deserializer.ReadUShort();
-        if (version == 0)
-        {
-            unsigned numKerningTables = deserializer.ReadUShort();
-            for (unsigned i = 0; i < numKerningTables; ++i)
-            {
-                unsigned short version = deserializer.ReadUShort();
-                unsigned short length = deserializer.ReadUShort();
-                unsigned short coverage = deserializer.ReadUShort();
-
-                if (version == 0 && coverage == 1)
-                {
-                    unsigned numKerningPairs = deserializer.ReadUShort();
-                    // Skip searchRange, entrySelector and rangeShift
-                    deserializer.Seek(deserializer.GetPosition() + 3 * sizeof(unsigned short));
-
-                    for (unsigned j = 0; j < numKerningPairs; ++j)
-                    {
-                        unsigned leftIndex = deserializer.ReadUShort();
-                        unsigned rightIndex = deserializer.ReadUShort();
-                        short amount = (short)(deserializer.ReadShort() >> 6);
-
-                        unsigned leftCharCode = leftIndex < numGlyphs ? charCodes[leftIndex] : 0;
-                        unsigned rightCharCode = rightIndex < numGlyphs ? charCodes[rightIndex] : 0;
-                        if (leftCharCode != 0 && rightCharCode != 0)
-                        {
-                            unsigned value = (leftCharCode << 16) + rightCharCode;
-                            kerningMapping_[value] = amount;
-                        }
-                    }
-                }
-                else
-                {
-                    // Kerning table contains information we do not support; skip and move to the next (length includes header)
-                    deserializer.Seek(deserializer.GetPosition() + length - 3 * sizeof(unsigned short));
-                }
-            }
-        }
-        else
-            LOGWARNING("Can not read kerning information: not version 0");
-    }
-
-    if (loadAllGlyphs)
-    {
-        FT_Done_Face(face);
-        face_ = 0;
-        hasMutableGlyph_ = false;
-    }
-    else
-        hasMutableGlyph_ = true;
-
-    return true;
-}
-
-const FontGlyph* FontFaceFreeType::GetGlyph(unsigned c)
-{
-    HashMap<unsigned, FontGlyph>::Iterator i = glyphMapping_.Find(c);
-    if (i != glyphMapping_.End())
-    {
-        FontGlyph& glyph = i->second_;
-        glyph.used_ = true;
-        return &glyph;
-    }
-
-    if (LoadCharGlyph(c))
-    {
-        HashMap<unsigned, FontGlyph>::Iterator i = glyphMapping_.Find(c);
-        if (i != glyphMapping_.End())
-        {
-            FontGlyph& glyph = i->second_;
-            glyph.used_ = true;
-            return &glyph;
-        }
-    }
-
-    return 0;
-}
-
-bool FontFaceFreeType::CanLoadAllGlyphs(const PODVector<unsigned>& charCodes, int& textureWidth, int& textureHeight) const
-{
-    FT_Face face = (FT_Face)face_;
-    FT_GlyphSlot slot = face->glyph;
-    AreaAllocator allocator(FONT_TEXTURE_MIN_SIZE, FONT_TEXTURE_MIN_SIZE, textureWidth, textureHeight);
-
-    unsigned numGlyphs = charCodes.Size();
-    for (unsigned i = 0; i < numGlyphs; ++i)
-    {
-        unsigned charCode = charCodes[i];
-        if (charCode == 0)
-            continue;
-
-        FT_Error error = FT_Load_Char(face, charCode, loadMode_);
-        if (!error)
-        {
-            int width = Max(slot->metrics.width >> 6, slot->bitmap.width);
-            int height = Max(slot->metrics.height >> 6, slot->bitmap.rows);
-            int x, y;
-            if (!allocator.Allocate(width + 1, height + 1, x, y))
-                return false;
-        }
-    }
-
-    textureWidth = allocator.GetWidth();
-    textureHeight = allocator.GetHeight();
-    return true;
-}
-
-bool FontFaceFreeType::SetupNextTexture(int textureWidth, int textureHeight)
-{
-    SharedPtr<Image> image(new Image(font_->GetContext()));
-    image->SetSize(textureWidth, textureHeight, 1);
-    unsigned char* imageData = image->GetData();
-    memset(imageData, 0, image->GetWidth() * image->GetHeight());
-
-    SharedPtr<Texture2D> texture = LoadFaceTexture(image);
-    if (!texture)
-        return false;
-
-    textures_.Push(texture);
-    allocator_.Reset(FONT_TEXTURE_MIN_SIZE, FONT_TEXTURE_MIN_SIZE, textureWidth, textureHeight);
-
-    font_->SetMemoryUse(font_->GetMemoryUse() + textureWidth * textureHeight);
-
-    return true;
-}
-
-bool FontFaceFreeType::LoadCharGlyph(unsigned charCode, Image* image)
-{
-    if (!face_)
-        return false;
-
-    FT_Face face = (FT_Face)face_;
-    FT_GlyphSlot slot = face->glyph;
-
-    FontGlyph fontGlyph;
-    FT_Error error = FT_Load_Char(face, charCode, loadMode_);
-    if (!error)
-    {
-        // Note: position within texture will be filled later
-        fontGlyph.width_ = (short)Max(slot->metrics.width >> 6, slot->bitmap.width);
-        fontGlyph.height_ = (short)Max(slot->metrics.height >> 6, slot->bitmap.rows);
-        fontGlyph.offsetX_ = (short)(slot->metrics.horiBearingX >> 6);
-        fontGlyph.offsetY_ = (short)(ascender_ - (slot->metrics.horiBearingY >> 6));
-        fontGlyph.advanceX_ = (short)(slot->metrics.horiAdvance >> 6);
-
-        if (fontGlyph.width_ > 0 && fontGlyph.height_ > 0)
-        {
-            int x, y;
-            if (!allocator_.Allocate(fontGlyph.width_ + 1, fontGlyph.height_ + 1, x, y))
-            {
-                if (!SetupNextTexture(allocator_.GetWidth(), allocator_.GetHeight()))
-                    return false;
-
-                if (!allocator_.Allocate(fontGlyph.width_ + 1, fontGlyph.height_ + 1, x, y))
-                    return false;
-            }
-
-            fontGlyph.x_ = x;
-            fontGlyph.y_ = y;
-
-            unsigned char* dest = 0;
-            unsigned pitch = 0;
-            if (image)
-            {
-                fontGlyph.page_ = 0;
-                dest = image->GetData() + fontGlyph.y_ * image->GetWidth() + fontGlyph.x_;
-                pitch = image->GetWidth();
-            }
-            else
-            {
-                fontGlyph.page_ = textures_.Size() - 1;
-                dest = new unsigned char[fontGlyph.width_ * fontGlyph.height_];
-                pitch = fontGlyph.width_;
-            }
-
-            FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
-            if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_MONO)
-            {
-                for (int y = 0; y < slot->bitmap.rows; ++y)
-                {
-                    unsigned char* src = slot->bitmap.buffer + slot->bitmap.pitch * y;
-                    unsigned char* rowDest = dest + y * pitch;
-
-                    for (int x = 0; x < slot->bitmap.width; ++x)
-                        rowDest[x] = (src[x >> 3] & (0x80 >> (x & 7))) ? 255 : 0;
-                }
-            }
-            else
-            {
-                for (int y = 0; y < slot->bitmap.rows; ++y)
-                {
-                    unsigned char* src = slot->bitmap.buffer + slot->bitmap.pitch * y;
-                    unsigned char* rowDest = dest + y * pitch;
-
-                    for (int x = 0; x < slot->bitmap.width; ++x)
-                        rowDest[x] = src[x];
-                }
-            }
-
-            if (!image)
-            {
-                textures_.Back()->SetData(0, fontGlyph.x_, fontGlyph.y_, fontGlyph.width_, fontGlyph.height_, dest);
-                delete [] dest;
-            }
-        }
-        else
-        {
-            fontGlyph.x_ = 0;
-            fontGlyph.y_ = 0;
-            fontGlyph.page_ = 0;
-        }
-    }
-    else
-    {
-        fontGlyph.width_ = 0;
-        fontGlyph.height_ = 0;
-        fontGlyph.offsetX_ = 0;
-        fontGlyph.offsetY_ = 0;
-        fontGlyph.advanceX_ = 0;
-        fontGlyph.page_ = 0;
-    }
-
-    glyphMapping_[charCode] = fontGlyph;
-
-    return true;
-}
-
-}

+ 0 - 71
Source/Atomic/UI/FontFaceFreeType.h

@@ -1,71 +0,0 @@
-//
-// Copyright (c) 2008-2015 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/FontFace.h"
-
-namespace Atomic
-{
-
-class FreeTypeLibrary;
-class Texture2D;
-
-/// Free type font face description.
-class ATOMIC_API FontFaceFreeType : public FontFace
-{
-public:
-    /// Construct.
-    FontFaceFreeType(Font* font);
-    /// Destruct.
-    ~FontFaceFreeType();
-
-    /// Load font face.
-    virtual bool Load(const unsigned char* fontData, unsigned fontDataSize, int pointSize);
-    /// Return pointer to the glyph structure corresponding to a character. Return null if glyph not found.
-    virtual const FontGlyph* GetGlyph(unsigned c);
-    /// Return if font face uses mutable glyphs.
-    virtual bool HasMutableGlyphs() const { return hasMutableGlyph_; }
-
-private:
-    /// Check can load all glyph in one texture, return true and texture size if can load.
-    bool CanLoadAllGlyphs(const PODVector<unsigned>& charCodes, int& textureWidth, int& textureHeight) const;
-    /// Setup next texture.
-    bool SetupNextTexture(int textureWidth, int textureHeight);
-    /// Load char glyph.
-    bool LoadCharGlyph(unsigned charCode, Image* image = 0);
-
-        /// FreeType library.
-    SharedPtr<FreeTypeLibrary> freeType_;
-    /// FreeType face. Non-null after creation only in dynamic mode.
-    void* face_;
-    /// Load mode.
-    int loadMode_;
-    /// Ascender.
-    int ascender_;
-    /// Has mutable glyph.
-    bool hasMutableGlyph_;
-    /// Glyph area allocator.
-    AreaAllocator allocator_;
-};
-
-}

+ 0 - 660
Source/Atomic/UI/LineEdit.cpp

@@ -1,660 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../Input/Input.h"
-#include "../UI/LineEdit.h"
-#include "../UI/Text.h"
-#include "../UI/UI.h"
-#include "../UI/UIEvents.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-StringHash VAR_DRAGDROPCONTENT("DragDropContent");
-
-extern const char* UI_CATEGORY;
-
-LineEdit::LineEdit(Context* context) :
-    BorderImage(context),
-    lastFont_(0),
-    lastFontSize_(0),
-    cursorPosition_(0),
-    dragBeginCursor_(M_MAX_UNSIGNED),
-    cursorBlinkRate_(1.0f),
-    cursorBlinkTimer_(0.0f),
-    maxLength_(0),
-    echoCharacter_(0),
-    cursorMovable_(true),
-    textSelectable_(true),
-    textCopyable_(true)
-{
-    clipChildren_ = true;
-    SetEnabled(true);
-    focusMode_ = FM_FOCUSABLE_DEFOCUSABLE;
-
-    text_ = CreateChild<Text>("LE_Text");
-    text_->SetInternal(true);
-    cursor_ = CreateChild<BorderImage>("LE_Cursor");
-    cursor_->SetInternal(true);
-    cursor_->SetPriority(1); // Show over text
-
-    SubscribeToEvent(this, E_FOCUSED, HANDLER(LineEdit, HandleFocused));
-    SubscribeToEvent(this, E_DEFOCUSED, HANDLER(LineEdit, HandleDefocused));
-    SubscribeToEvent(this, E_LAYOUTUPDATED, HANDLER(LineEdit, HandleLayoutUpdated));
-}
-
-LineEdit::~LineEdit()
-{
-}
-
-void LineEdit::RegisterObject(Context* context)
-{
-    context->RegisterFactory<LineEdit>(UI_CATEGORY);
-
-    COPY_BASE_ATTRIBUTES(BorderImage);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Clip Children", true);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Is Enabled", true);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Focus Mode", FM_FOCUSABLE_DEFOCUSABLE);
-    ACCESSOR_ATTRIBUTE("Max Length", GetMaxLength, SetMaxLength, unsigned, 0, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Is Cursor Movable", IsCursorMovable, SetCursorMovable, bool, true, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Is Text Selectable", IsTextSelectable, SetTextSelectable, bool, true, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Is Text Copyable", IsTextCopyable, SetTextCopyable, bool, true, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Cursor Blink Rate", GetCursorBlinkRate, SetCursorBlinkRate, float, 1.0f, AM_FILE);
-    ATTRIBUTE("Echo Character", int, echoCharacter_, 0, AM_FILE);
-}
-
-void LineEdit::ApplyAttributes()
-{
-    BorderImage::ApplyAttributes();
-
-    // Set the text's position to match clipping and indent width, so that text left edge is not left partially hidden
-    text_->SetPosition(GetIndentWidth() + clipBorder_.left_, clipBorder_.top_);
-
-    // Sync the text line
-    line_ = text_->GetText();
-}
-
-void LineEdit::Update(float timeStep)
-{
-    if (cursorBlinkRate_ > 0.0f)
-        cursorBlinkTimer_ = fmodf(cursorBlinkTimer_ + cursorBlinkRate_ * timeStep, 1.0f);
-
-    // Update cursor position if font has changed
-    if (text_->GetFont() != lastFont_ || text_->GetFontSize() != lastFontSize_)
-    {
-        lastFont_ = text_->GetFont();
-        lastFontSize_ = text_->GetFontSize();
-        UpdateCursor();
-    }
-
-    bool cursorVisible = HasFocus() ? cursorBlinkTimer_ < 0.5f : false;
-    cursor_->SetVisible(cursorVisible);
-}
-
-void LineEdit::OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
-{
-    if (button == MOUSEB_LEFT && cursorMovable_)
-    {
-        unsigned pos = GetCharIndex(position);
-        if (pos != M_MAX_UNSIGNED)
-        {
-            SetCursorPosition(pos);
-            text_->ClearSelection();
-        }
-    }
-}
-
-void LineEdit::OnDoubleClick(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
-{
-    if (button == MOUSEB_LEFT)
-        text_->SetSelection(0);
-}
-
-void LineEdit::OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
-{
-    UIElement::OnDragBegin(position, screenPosition, buttons, qualifiers, cursor);
-    
-    dragBeginCursor_ = GetCharIndex(position);
-}
-
-void LineEdit::OnDragMove(const IntVector2& position, const IntVector2& screenPosition, const IntVector2& deltaPos, int buttons, int qualifiers, Cursor* cursor)
-{
-    if (cursorMovable_ && textSelectable_)
-    {
-        unsigned start = dragBeginCursor_;
-        unsigned current = GetCharIndex(position);
-        if (start != M_MAX_UNSIGNED && current != M_MAX_UNSIGNED)
-        {
-            if (start < current)
-                text_->SetSelection(start, current - start);
-            else
-                text_->SetSelection(current, start - current);
-            SetCursorPosition(current);
-        }
-    }
-}
-
-bool LineEdit::OnDragDropTest(UIElement* source)
-{
-    if (source && editable_)
-    {
-        if (source->GetVars().Contains(VAR_DRAGDROPCONTENT))
-            return true;
-        StringHash sourceType = source->GetType();
-        return sourceType == LineEdit::GetTypeStatic() || sourceType == Text::GetTypeStatic();
-    }
-
-    return false;
-}
-
-bool LineEdit::OnDragDropFinish(UIElement* source)
-{
-    if (source && editable_)
-    {
-        // If the UI element in question has a drag-and-drop content string defined, use it instead of element text
-        if (source->GetVars().Contains(VAR_DRAGDROPCONTENT))
-        {
-            SetText(source->GetVar(VAR_DRAGDROPCONTENT).GetString());
-            return true;
-        }
-
-        StringHash sourceType = source->GetType();
-        if (sourceType == LineEdit::GetTypeStatic())
-        {
-            LineEdit* sourceLineEdit = static_cast<LineEdit*>(source);
-            SetText(sourceLineEdit->GetText());
-            return true;
-        }
-        else if (sourceType == Text::GetTypeStatic())
-        {
-            Text* sourceText = static_cast<Text*>(source);
-            SetText(sourceText->GetText());
-            return true;
-        }
-    }
-
-    return false;
-}
-
-void LineEdit::OnKey(int key, int buttons, int qualifiers)
-{
-    bool changed = false;
-    bool cursorMoved = false;
-
-    switch (key)
-    {
-    case 'X':
-    case 'C':
-        if (textCopyable_ && qualifiers & QUAL_CTRL)
-        {
-            unsigned start = text_->GetSelectionStart();
-            unsigned length = text_->GetSelectionLength();
-
-            if (text_->GetSelectionLength())
-                GetSubsystem<UI>()->SetClipboardText(line_.SubstringUTF8(start, length));
-
-            if (key == 'X' && editable_)
-            {
-                if (start + length < line_.LengthUTF8())
-                    line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
-                else
-                    line_ = line_.SubstringUTF8(0, start);
-                text_->ClearSelection();
-                cursorPosition_ = start;
-                changed = true;
-            }
-        }
-        break;
-
-    case 'V':
-        if (editable_ && textCopyable_ && qualifiers & QUAL_CTRL)
-        {
-            const String& clipBoard = GetSubsystem<UI>()->GetClipboardText();
-            if (!clipBoard.Empty())
-            {
-                // Remove selected text first
-                if(text_->GetSelectionLength() > 0)
-                {
-                    unsigned start = text_->GetSelectionStart();
-                    unsigned length = text_->GetSelectionLength();
-                    if (start + length < line_.LengthUTF8())
-                        line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
-                    else
-                        line_ = line_.SubstringUTF8(0, start);
-                    text_->ClearSelection();
-                    cursorPosition_ = start;
-                }
-                if (cursorPosition_ < line_.LengthUTF8())
-                    line_ = line_.SubstringUTF8(0, cursorPosition_) + clipBoard + line_.SubstringUTF8(cursorPosition_);
-                else
-                    line_ += clipBoard;
-                cursorPosition_ += clipBoard.LengthUTF8();
-                changed = true;
-            }
-        }
-        break;
-
-    case KEY_HOME:
-        qualifiers |= QUAL_CTRL;
-        // Fallthru
-
-    case KEY_LEFT:
-        if (cursorMovable_ && cursorPosition_ > 0)
-        {
-            if (textSelectable_ && qualifiers & QUAL_SHIFT && !text_->GetSelectionLength())
-                dragBeginCursor_ = cursorPosition_;
-
-            if (qualifiers & QUAL_CTRL)
-                cursorPosition_ = 0;
-            else if (text_->GetSelectionLength() && !(qualifiers & QUAL_SHIFT))
-                cursorPosition_ = text_->GetSelectionStart();
-            else
-                --cursorPosition_;
-            cursorMoved = true;
-
-            if (textSelectable_ && qualifiers & QUAL_SHIFT)
-            {
-                unsigned start = dragBeginCursor_;
-                unsigned current = cursorPosition_;
-                if (start < current)
-                    text_->SetSelection(start, current - start);
-                else
-                    text_->SetSelection(current, start - current);
-            }
-        }
-        if (!(qualifiers & QUAL_SHIFT))
-            text_->ClearSelection();
-        break;
-
-    case KEY_END:
-        qualifiers |= QUAL_CTRL;
-        // Fallthru
-
-    case KEY_RIGHT:
-        if (cursorMovable_ && cursorPosition_ < line_.LengthUTF8())
-        {
-            if (textSelectable_ && qualifiers & QUAL_SHIFT && !text_->GetSelectionLength())
-                dragBeginCursor_ = cursorPosition_;
-
-            if (qualifiers & QUAL_CTRL)
-                cursorPosition_ = line_.LengthUTF8();
-            else if (text_->GetSelectionLength() && !(qualifiers & QUAL_SHIFT))
-                cursorPosition_ = text_->GetSelectionStart() + text_->GetSelectionLength();
-            else
-                ++cursorPosition_;
-            cursorMoved = true;
-
-            if (textSelectable_ && qualifiers & QUAL_SHIFT)
-            {
-                unsigned start = dragBeginCursor_;
-                unsigned current = cursorPosition_;
-                if (start < current)
-                    text_->SetSelection(start, current - start);
-                else
-                    text_->SetSelection(current, start - current);
-            }
-        }
-        if (!(qualifiers & QUAL_SHIFT))
-            text_->ClearSelection();
-        break;
-
-    case KEY_DELETE:
-        if (editable_)
-        {
-            if (!text_->GetSelectionLength())
-            {
-                if (cursorPosition_ < line_.LengthUTF8())
-                {
-                    line_ = line_.SubstringUTF8(0, cursorPosition_) + line_.SubstringUTF8(cursorPosition_ + 1);
-                    changed = true;
-                }
-            }
-            else
-            {
-                // If a selection exists, erase it
-                unsigned start = text_->GetSelectionStart();
-                unsigned length = text_->GetSelectionLength();
-                if (start + length < line_.LengthUTF8())
-                    line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
-                else
-                    line_ = line_.SubstringUTF8(0, start);
-                text_->ClearSelection();
-                cursorPosition_ = start;
-                changed = true;
-            }
-        }
-        break;
-
-    case KEY_UP:
-    case KEY_DOWN:
-    case KEY_PAGEUP:
-    case KEY_PAGEDOWN:
-        {
-            using namespace UnhandledKey;
-
-            VariantMap& eventData = GetEventDataMap();
-            eventData[P_ELEMENT] = this;
-            eventData[P_KEY] = key;
-            eventData[P_BUTTONS] = buttons;
-            eventData[P_QUALIFIERS] = qualifiers;
-            SendEvent(E_UNHANDLEDKEY, eventData);
-        }
-        return;
-
-    case KEY_BACKSPACE:
-        if (editable_)
-        {
-            if (!text_->GetSelectionLength())
-            {
-                if (line_.LengthUTF8() && cursorPosition_)
-                {
-                    if (cursorPosition_ < line_.LengthUTF8())
-                        line_ = line_.SubstringUTF8(0, cursorPosition_ - 1) + line_.SubstringUTF8(cursorPosition_);
-                    else
-                        line_ = line_.SubstringUTF8(0, cursorPosition_ - 1);
-                    --cursorPosition_;
-                    changed = true;
-                }
-            }
-            else
-            {
-                // If a selection exists, erase it
-                unsigned start = text_->GetSelectionStart();
-                unsigned length = text_->GetSelectionLength();
-                if (start + length < line_.LengthUTF8())
-                    line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
-                else
-                    line_ = line_.SubstringUTF8(0, start);
-                text_->ClearSelection();
-                cursorPosition_ = start;
-                changed = true;
-            }
-        }
-        break;
-
-    case KEY_RETURN:
-    case KEY_RETURN2:
-    case KEY_KP_ENTER:
-        {
-            // If using the on-screen keyboard, defocus this element to hide it now
-            if (GetSubsystem<UI>()->GetUseScreenKeyboard() && HasFocus())
-                SetFocus(false);
-
-            using namespace TextFinished;
-
-            VariantMap& eventData = GetEventDataMap();
-            eventData[P_ELEMENT] = this;
-            eventData[P_TEXT] = line_;
-            SendEvent(E_TEXTFINISHED, eventData);
-            return;
-        }
-        break;
-    }
-
-    if (changed)
-    {
-        UpdateText();
-        UpdateCursor();
-    }
-    else if (cursorMoved)
-        UpdateCursor();
-}
-
-void LineEdit::OnTextInput(const String& text, int buttons, int qualifiers)
-{
-    if (!editable_)
-        return;
-
-    bool changed = false;
-
-    // If only CTRL is held down, do not edit
-    if ((qualifiers & (QUAL_CTRL | QUAL_ALT)) == QUAL_CTRL)
-        return;
-
-    // Send char as an event to allow changing it
-    using namespace CharEntry;
-
-    VariantMap& eventData = GetEventDataMap();
-    eventData[P_ELEMENT] = this;
-    eventData[P_TEXT] = text;
-    eventData[P_BUTTONS] = buttons;
-    eventData[P_QUALIFIERS] = qualifiers;
-    SendEvent(E_TEXTENTRY, eventData);
-
-    const String newText = eventData[P_TEXT].GetString().SubstringUTF8(0);
-    if (!newText.Empty() && (!maxLength_ || line_.LengthUTF8() + newText.LengthUTF8() <= maxLength_))
-    {
-        if (!text_->GetSelectionLength())
-        {
-            if (cursorPosition_ == line_.LengthUTF8())
-                line_ += newText;
-            else
-                line_ = line_.SubstringUTF8(0, cursorPosition_) + newText + line_.SubstringUTF8(cursorPosition_);
-            cursorPosition_ += newText.LengthUTF8();
-        }
-        else
-        {
-            // If a selection exists, erase it first
-            unsigned start = text_->GetSelectionStart();
-            unsigned length = text_->GetSelectionLength();
-            if (start + length < line_.LengthUTF8())
-                line_ = line_.SubstringUTF8(0, start) + newText + line_.SubstringUTF8(start + length);
-            else
-                line_ = line_.SubstringUTF8(0, start) + newText;
-            cursorPosition_ = start + newText.LengthUTF8();
-        }
-        changed = true;
-    }
-
-    if (changed)
-    {
-        text_->ClearSelection();
-        UpdateText();
-        UpdateCursor();
-    }
-}
-
-void LineEdit::SetText(const String& text)
-{
-    if (text != line_)
-    {
-        line_ = text;
-        cursorPosition_ = line_.LengthUTF8();
-        UpdateText();
-        UpdateCursor();
-    }
-}
-
-void LineEdit::SetCursorPosition(unsigned position)
-{
-    if (position > line_.LengthUTF8() || !cursorMovable_)
-        position = line_.LengthUTF8();
-
-    if (position != cursorPosition_)
-    {
-        cursorPosition_ = position;
-        UpdateCursor();
-    }
-}
-
-void LineEdit::SetCursorBlinkRate(float rate)
-{
-    cursorBlinkRate_ = Max(rate, 0.0f);
-
-    if (cursorBlinkRate_ == 0.0f)
-        cursorBlinkTimer_ = 0.0f;   // Cursor does not blink, i.e. always visible
-}
-
-void LineEdit::SetMaxLength(unsigned length)
-{
-    maxLength_ = length;
-}
-
-void LineEdit::SetEchoCharacter(unsigned c)
-{
-    echoCharacter_ = c;
-    UpdateText();
-}
-
-void LineEdit::SetCursorMovable(bool enable)
-{
-    cursorMovable_ = enable;
-}
-
-void LineEdit::SetTextSelectable(bool enable)
-{
-    textSelectable_ = enable;
-}
-
-void LineEdit::SetTextCopyable(bool enable)
-{
-    textCopyable_ = enable;
-}
-
-bool LineEdit::FilterImplicitAttributes(XMLElement& dest) const
-{
-    if (!BorderImage::FilterImplicitAttributes(dest))
-        return false;
-
-    XMLElement childElem = dest.GetChild("element");
-    if (!childElem)
-        return false;
-    if (!RemoveChildXML(childElem, "Name", "LE_Text"))
-        return false;
-    if (!RemoveChildXML(childElem, "Position"))
-        return false;
-
-    childElem = childElem.GetNext("element");
-    if (!childElem)
-        return false;
-    if (!RemoveChildXML(childElem, "Name", "LE_Cursor"))
-        return false;
-    if (!RemoveChildXML(childElem, "Priority", "1"))
-        return false;
-    if (!RemoveChildXML(childElem, "Position"))
-        return false;
-    if (!RemoveChildXML(childElem, "Is Visible"))
-        return false;
-
-    return true;
-}
-
-void LineEdit::UpdateText()
-{
-    unsigned utf8Length = line_.LengthUTF8();
-
-    if (!echoCharacter_)
-        text_->SetText(line_);
-    else
-    {
-        String echoText;
-        for (unsigned i = 0; i < utf8Length; ++i)
-            echoText.AppendUTF8(echoCharacter_);
-        text_->SetText(echoText);
-    }
-    if (cursorPosition_ > utf8Length)
-    {
-        cursorPosition_ = utf8Length;
-        UpdateCursor();
-    }
-
-    using namespace TextChanged;
-
-    VariantMap& eventData = GetEventDataMap();
-    eventData[P_ELEMENT] = this;
-    eventData[P_TEXT] = line_;
-    SendEvent(E_TEXTCHANGED, eventData);
-}
-
-void LineEdit::UpdateCursor()
-{
-    int x = text_->GetCharPosition(cursorPosition_).x_;
-
-    text_->SetPosition(GetIndentWidth() + clipBorder_.left_, clipBorder_.top_);
-    cursor_->SetPosition(text_->GetPosition() + IntVector2(x, 0));
-    cursor_->SetSize(cursor_->GetWidth(), text_->GetRowHeight());
-
-    // Scroll if necessary
-    int sx = -GetChildOffset().x_;
-    int left = clipBorder_.left_;
-    int right = GetWidth() - clipBorder_.left_ - clipBorder_.right_ - cursor_->GetWidth();
-    if (x - sx > right)
-        sx = x - right;
-    if (x - sx < left)
-        sx = x - left;
-    if (sx < 0)
-        sx = 0;
-    SetChildOffset(IntVector2(-sx, 0));
-
-    // Restart blinking
-    cursorBlinkTimer_ = 0.0f;
-}
-
-unsigned LineEdit::GetCharIndex(const IntVector2& position)
-{
-    IntVector2 screenPosition = ElementToScreen(position);
-    IntVector2 textPosition = text_->ScreenToElement(screenPosition);
-
-    if (textPosition.x_ < 0)
-        return 0;
-
-    int numChars = text_->GetNumChars();
-    for (int i = numChars; i >= 0; --i)
-    {
-        if (textPosition.x_ >= text_->GetCharPosition(i).x_)
-            return i;
-    }
-
-    return M_MAX_UNSIGNED;
-}
-
-void LineEdit::HandleFocused(StringHash eventType, VariantMap& eventData)
-{
-    if (eventData[Focused::P_BYKEY].GetBool())
-    {
-        cursorPosition_ = line_.LengthUTF8();
-        text_->SetSelection(0);
-    }
-    UpdateCursor();
-
-    if (GetSubsystem<UI>()->GetUseScreenKeyboard())
-        GetSubsystem<Input>()->SetScreenKeyboardVisible(true);
-}
-
-void LineEdit::HandleDefocused(StringHash eventType, VariantMap& eventData)
-{
-    text_->ClearSelection();
-
-    if (GetSubsystem<UI>()->GetUseScreenKeyboard())
-        GetSubsystem<Input>()->SetScreenKeyboardVisible(false);
-}
-
-void LineEdit::HandleLayoutUpdated(StringHash eventType, VariantMap& eventData)
-{
-    UpdateCursor();
-}
-
-}

+ 0 - 153
Source/Atomic/UI/LineEdit.h

@@ -1,153 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/BorderImage.h"
-
-namespace Atomic
-{
-
-class Font;
-class Text;
-
-/// Single-line text editor %UI element.
-class ATOMIC_API LineEdit : public BorderImage
-{
-    OBJECT(LineEdit);
-
-public:
-    /// Construct.
-    LineEdit(Context* context);
-    /// Destruct.
-    virtual ~LineEdit();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// Apply attribute changes that can not be applied immediately.
-    virtual void ApplyAttributes();
-    /// Perform UI element update.
-    virtual void Update(float timeStep);
-    /// React to mouse click begin.
-    virtual void OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse doubleclick.
-    virtual void OnDoubleClick(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse drag begin.
-    virtual void OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse drag motion.
-    virtual void OnDragMove(const IntVector2& position, const IntVector2& screenPosition, const IntVector2& deltaPos, int buttons, int qualifiers, Cursor* cursor);
-    /// React to drag and drop test. Return true to signal that the drop is acceptable.
-    virtual bool OnDragDropTest(UIElement* source);
-    /// React to drag and drop finish. Return true to signal that the drop was accepted.
-    virtual bool OnDragDropFinish(UIElement* source);
-    /// React to a key press.
-    virtual void OnKey(int key, int buttons, int qualifiers);
-    /// React to text input event.
-    virtual void OnTextInput(const String& text, int buttons, int qualifiers);
-
-    /// Set text.
-    void SetText(const String& text);
-    /// Set cursor position.
-    void SetCursorPosition(unsigned position);
-    /// Set cursor blink rate. 0 disables blinking.
-    void SetCursorBlinkRate(float rate);
-    /// Set maximum text length. 0 for unlimited.
-    void SetMaxLength(unsigned length);
-    /// Set echo character for password entry and such. 0 (default) shows the actual text.
-    void SetEchoCharacter(unsigned c);
-    /// Set whether can move cursor with arrows or mouse, default true.
-    void SetCursorMovable(bool enable);
-    /// Set whether selections are allowed, default true.
-    void SetTextSelectable(bool enable);
-    /// Set whether copy-paste operations are allowed, default true.
-    void SetTextCopyable(bool enable);
-
-    /// Return text.
-    const String& GetText() const { return line_; }
-    /// Return cursor position.
-    unsigned GetCursorPosition() const { return cursorPosition_; }
-    /// Return cursor blink rate.
-    float GetCursorBlinkRate() const { return cursorBlinkRate_; }
-    /// Return maximum text length.
-    unsigned GetMaxLength() const { return maxLength_; }
-    /// Return echo character.
-    unsigned GetEchoCharacter() const { return echoCharacter_; }
-    /// Return whether can move cursor with arrows or mouse.
-    bool IsCursorMovable() const { return cursorMovable_; }
-    /// Return whether selections are allowed.
-    bool IsTextSelectable() const { return textSelectable_; }
-    /// Return whether copy-paste operations are allowed.
-    bool IsTextCopyable() const { return textCopyable_; }
-    /// Return text element.
-    Text* GetTextElement() const { return text_; }
-    /// Return cursor element.
-    BorderImage* GetCursor() const { return cursor_; }
-
-protected:
-    /// Filter implicit attributes in serialization process.
-    virtual bool FilterImplicitAttributes(XMLElement& dest) const;
-    /// Update displayed text.
-    void UpdateText();
-    /// Update cursor position and restart cursor blinking.
-    void UpdateCursor();
-    /// Return char index corresponding to position within element, or M_MAX_UNSIGNED if not found.
-    unsigned GetCharIndex(const IntVector2& position);
-
-    /// Text element.
-    SharedPtr<Text> text_;
-    /// Cursor element.
-    SharedPtr<BorderImage> cursor_;
-    /// Text line.
-    String line_;
-    /// Last used text font.
-    Font* lastFont_;
-    /// Last used text size.
-    int lastFontSize_;
-    /// Text edit cursor position.
-    unsigned cursorPosition_;
-    /// Drag begin cursor position.
-    unsigned dragBeginCursor_;
-    /// Cursor blink rate.
-    float cursorBlinkRate_;
-    /// Cursor blink timer.
-    float cursorBlinkTimer_;
-    /// Maximum text length.
-    unsigned maxLength_;
-    /// Echo character.
-    unsigned echoCharacter_;
-    /// Cursor movable flag.
-    bool cursorMovable_;
-    /// Text selectable flag.
-    bool textSelectable_;
-    /// Copy-paste enable flag.
-    bool textCopyable_;
-
-private:
-    /// Handle being focused.
-    void HandleFocused(StringHash eventType, VariantMap& eventData);
-    /// Handle being defocused.
-    void HandleDefocused(StringHash eventType, VariantMap& eventData);
-    /// Handle the element layout having been updated.
-    void HandleLayoutUpdated(StringHash eventType, VariantMap& eventData);
-};
-
-}

+ 0 - 1138
Source/Atomic/UI/ListView.cpp

@@ -1,1138 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../UI/CheckBox.h"
-#include "../Core/Context.h"
-#include "../Input/InputEvents.h"
-#include "../UI/ListView.h"
-#include "../IO/Log.h"
-#include "../Container/Sort.h"
-#include "../UI/Text.h"
-#include "../UI/UI.h"
-#include "../UI/UIEvents.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-static const char* highlightModes[] =
-{
-    "Never",
-    "Focus",
-    "Always",
-    0
-};
-
-static const StringHash expandedHash("Expanded");
-
-extern const char* UI_CATEGORY;
-
-bool GetItemExpanded(UIElement* item)
-{
-    return item ? item->GetVar(expandedHash).GetBool() : false;
-}
-
-void SetItemExpanded(UIElement* item, bool enable)
-{
-    item->SetVar(expandedHash, enable);
-}
-
-static const StringHash hierarchyParentHash("HierarchyParent");
-
-bool GetItemHierarchyParent(UIElement* item)
-{
-    return item ? item->GetVar(hierarchyParentHash).GetBool() : false;
-}
-
-void SetItemHierarchyParent(UIElement* item, bool enable)
-{
-    item->SetVar(hierarchyParentHash, enable);
-}
-
-/// Hierarchy container (used by ListView internally when in hierarchy mode).
-class HierarchyContainer : public UIElement
-{
-    OBJECT(HierarchyContainer);
-
-public:
-    /// Construct.
-    HierarchyContainer(Context* context, ListView* listView, UIElement* overlayContainer) :
-        UIElement(context),
-        listView_(listView),
-        overlayContainer_(overlayContainer)
-    {
-        SubscribeToEvent(this, E_LAYOUTUPDATED, HANDLER(HierarchyContainer, HandleLayoutUpdated));
-        SubscribeToEvent(overlayContainer->GetParent(), E_VIEWCHANGED, HANDLER(HierarchyContainer, HandleViewChanged));
-        SubscribeToEvent(E_UIMOUSECLICK, HANDLER(HierarchyContainer, HandleUIMouseClick));
-    }
-    
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// Handle layout updated by adjusting the position of the overlays.
-    void HandleLayoutUpdated(StringHash eventType, VariantMap& eventData)
-    {
-        // Adjust the container size for child clipping effect
-        overlayContainer_->SetSize(GetParent()->GetSize());
-
-        for (unsigned i = 0; i < children_.Size(); ++i)
-        {
-            const IntVector2& position = children_[i]->GetPosition();
-            CheckBox* overlay = static_cast<CheckBox*>(overlayContainer_->GetChild(i));
-            bool visible = children_[i]->IsVisible() && GetItemHierarchyParent(children_[i]);
-            overlay->SetVisible(visible);
-            if (visible)
-            {
-                overlay->SetPosition(position.x_, position.y_);
-                overlay->SetChecked(GetItemExpanded(children_[i]));
-            }
-        }
-    }
-
-    /// Handle view changed by scrolling the overlays in tandem.
-    void HandleViewChanged(StringHash eventType, VariantMap& eventData)
-    {
-        using namespace ViewChanged;
-
-        int x = eventData[P_X].GetInt();
-        int y = eventData[P_Y].GetInt();
-
-        IntRect panelBorder = GetParent()->GetClipBorder();
-        overlayContainer_->SetChildOffset(IntVector2(-x + panelBorder.left_, -y + panelBorder.top_));
-    }
-
-    /// Handle mouse click on overlays by toggling the expansion state of the corresponding item
-    void HandleUIMouseClick(StringHash eventType, VariantMap& eventData)
-    {
-        using namespace UIMouseClick;
-
-        UIElement* overlay = static_cast<UIElement*>(eventData[UIMouseClick::P_ELEMENT].GetPtr());
-        if (overlay)
-        {
-            const Vector<SharedPtr<UIElement> >& children = overlayContainer_->GetChildren();
-            Vector<SharedPtr<UIElement> >::ConstIterator i = children.Find(SharedPtr<UIElement>(overlay));
-            if (i != children.End())
-                listView_->ToggleExpand(i - children.Begin());
-        }
-    }
-
-    /// Insert a child element into a specific position in the child list.
-    void InsertChild(unsigned index, UIElement* element)
-    {
-        // Insert the overlay at the same index position to the overlay container
-        CheckBox* overlay = static_cast<CheckBox*>(overlayContainer_->CreateChild(CheckBox::GetTypeStatic(), String::EMPTY, index));
-        overlay->SetStyle("HierarchyListViewOverlay");
-        int baseIndent = listView_->GetBaseIndent();
-        int indent = element->GetIndent() - baseIndent - 1;
-        overlay->SetIndent(indent);
-        overlay->SetFixedWidth((indent + 1) * element->GetIndentSpacing());
-
-        // Then insert the element as child as per normal
-        UIElement::InsertChild(index, element);
-    }
-
-private:
-    // Parent list view.
-    ListView* listView_;
-    // Container for overlay checkboxes.
-    UIElement* overlayContainer_;
-};
-
-void HierarchyContainer::RegisterObject(Context* context)
-{
-    COPY_BASE_ATTRIBUTES(UIElement);
-}
-
-ListView::ListView(Context* context) :
-    ScrollView(context),
-    highlightMode_(HM_FOCUS),
-    multiselect_(false),
-    hierarchyMode_(true),    // Init to true here so that the setter below takes effect
-    baseIndent_(0),
-    clearSelectionOnDefocus_(false),
-    selectOnClickEnd_(false)
-{
-    resizeContentWidth_ = true;
-
-    // By default list view is set to non-hierarchy mode
-    SetHierarchyMode(false);
-
-    SubscribeToEvent(E_UIMOUSEDOUBLECLICK, HANDLER(ListView, HandleUIMouseDoubleClick));
-    SubscribeToEvent(E_FOCUSCHANGED, HANDLER(ListView, HandleItemFocusChanged));
-    SubscribeToEvent(this, E_DEFOCUSED, HANDLER(ListView, HandleFocusChanged));
-    SubscribeToEvent(this, E_FOCUSED, HANDLER(ListView, HandleFocusChanged));
-    
-    UpdateUIClickSubscription();
-}
-
-ListView::~ListView()
-{
-}
-
-void ListView::RegisterObject(Context* context)
-{
-    context->RegisterFactory<ListView>(UI_CATEGORY);
-
-    HierarchyContainer::RegisterObject(context);
-
-    COPY_BASE_ATTRIBUTES(ScrollView);
-    ENUM_ACCESSOR_ATTRIBUTE("Highlight Mode", GetHighlightMode, SetHighlightMode, HighlightMode, highlightModes, HM_FOCUS, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Multiselect", GetMultiselect, SetMultiselect, bool, false, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Hierarchy Mode", GetHierarchyMode, SetHierarchyMode, bool, false, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Base Indent", GetBaseIndent, SetBaseIndent, int, 0, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Clear Sel. On Defocus", GetClearSelectionOnDefocus, SetClearSelectionOnDefocus, bool, false, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Select On Click End", GetSelectOnClickEnd, SetSelectOnClickEnd, bool, false, AM_FILE);
-}
-
-void ListView::OnKey(int key, int buttons, int qualifiers)
-{
-    // If no selection, can not move with keys
-    unsigned numItems = GetNumItems();
-    unsigned selection = GetSelection();
-
-    // If either shift or ctrl held down, add to selection if multiselect enabled
-    bool additive = multiselect_ && qualifiers & (QUAL_SHIFT | QUAL_CTRL);
-    int delta = M_MAX_INT;
-    int pageDirection = 1;
-
-    if (numItems)
-    {
-        if (selection != M_MAX_UNSIGNED && qualifiers & QUAL_CTRL && key == KEY_C)
-        {
-            CopySelectedItemsToClipboard();
-            return;
-        }
-
-        switch (key)
-        {
-        case KEY_LEFT:
-        case KEY_RIGHT:
-            if (selection != M_MAX_UNSIGNED && hierarchyMode_)
-            {
-                Expand(selection, key == KEY_RIGHT);
-                return;
-            }
-            break;
-
-        case KEY_RETURN:
-        case KEY_RETURN2:
-        case KEY_KP_ENTER:
-            if (selection != M_MAX_UNSIGNED && hierarchyMode_)
-            {
-                ToggleExpand(selection);
-                return;
-            }
-            break;
-
-        case KEY_UP:
-            delta = -1;
-            break;
-
-        case KEY_DOWN:
-            delta = 1;
-            break;
-
-        case KEY_PAGEUP:
-            pageDirection = -1;
-            // Fallthru
-
-        case KEY_PAGEDOWN:
-            {
-                // Convert page step to pixels and see how many items have to be skipped to reach that many pixels
-                if (selection == M_MAX_UNSIGNED)
-                    selection = 0;      // Assume as if first item is selected
-                int stepPixels = ((int)(pageStep_ * scrollPanel_->GetHeight())) - contentElement_->GetChild(selection)->GetHeight();
-                unsigned newSelection = selection;
-                unsigned okSelection = selection;
-                unsigned invisible = 0;
-                while (newSelection < numItems)
-                {
-                    UIElement* item = GetItem(newSelection);
-                    int height = 0;
-                    if (item->IsVisible())
-                    {
-                        height = item->GetHeight();
-                        okSelection = newSelection;
-                    }
-                    else
-                        ++invisible;
-                    if (stepPixels < height)
-                        break;
-                    stepPixels -= height;
-                    newSelection += pageDirection;
-                }
-                delta = okSelection - selection - pageDirection * invisible;
-            }
-            break;
-
-        case KEY_HOME:
-            delta = -(int)GetNumItems();
-            break;
-
-        case KEY_END:
-            delta = GetNumItems();
-            break;
-        }
-    }
-
-    if (delta != M_MAX_INT)
-    {
-        ChangeSelection(delta, additive);
-        return;
-    }
-
-    using namespace UnhandledKey;
-
-    VariantMap& eventData = GetEventDataMap();
-    eventData[P_ELEMENT] = this;
-    eventData[P_KEY] = key;
-    eventData[P_BUTTONS] = buttons;
-    eventData[P_QUALIFIERS] = qualifiers;
-    SendEvent(E_UNHANDLEDKEY, eventData);
-}
-
-void ListView::OnResize()
-{
-    ScrollView::OnResize();
-
-    // When in hierarchy mode also need to resize the overlay container
-    if (hierarchyMode_)
-        overlayContainer_->SetSize(scrollPanel_->GetSize());
-}
-
-void ListView::AddItem(UIElement* item)
-{
-    InsertItem(M_MAX_UNSIGNED, item);
-}
-
-void ListView::InsertItem(unsigned index, UIElement* item, UIElement* parentItem)
-{
-    if (!item || item->GetParent() == contentElement_)
-        return;
-
-    // Enable input so that clicking the item can be detected
-    item->SetEnabled(true);
-    item->SetSelected(false);
-
-    unsigned numItems = contentElement_->GetNumChildren();
-    if (hierarchyMode_)
-    {
-        int baseIndent = baseIndent_;
-        if (parentItem)
-        {
-            baseIndent = parentItem->GetIndent();
-            SetItemHierarchyParent(parentItem, true);
-
-            // Adjust the index to ensure it is within the children index limit of the parent item
-            unsigned indexLimit = FindItem(parentItem);
-            if (index <= indexLimit)
-                index = indexLimit + 1;
-            else
-            {
-                while (++indexLimit < numItems)
-                {
-                    if (contentElement_->GetChild(indexLimit)->GetIndent() <= baseIndent)
-                        break;
-                }
-                if (index > indexLimit)
-                    index = indexLimit;
-            }
-        }
-        item->SetIndent(baseIndent + 1);
-        SetItemExpanded(item, item->IsVisible());
-
-        // Use the 'overrided' version to insert the child item
-        static_cast<HierarchyContainer*>(contentElement_.Get())->InsertChild(index, item);
-    }
-    else
-    {
-        if (index > numItems)
-            index = numItems;
-
-        contentElement_->InsertChild(index, item);
-    }
-
-    // If necessary, shift the following selections
-    if (!selections_.Empty())
-    {
-        for (unsigned i = 0; i < selections_.Size(); ++i)
-        {
-            if (selections_[i] >= index)
-                ++selections_[i];
-        }
-
-        UpdateSelectionEffect();
-    }
-}
-
-void ListView::RemoveItem(UIElement* item, unsigned index)
-{
-    if (!item)
-        return;
-
-    unsigned numItems = GetNumItems();
-    for (unsigned i = index; i < numItems; ++i)
-    {
-        if (GetItem(i) == item)
-        {
-            item->SetSelected(false);
-            selections_.Remove(i);
-
-            unsigned removed = 1;
-            if (hierarchyMode_)
-            {
-                // Remove any child items in hierarchy mode
-                if (GetItemHierarchyParent(item))
-                {
-                    int baseIndent = item->GetIndent();
-                    for (unsigned j = i + 1; ; ++j)
-                    {
-                        UIElement* childItem = GetItem(i + 1);
-                        if (!childItem)
-                            break;
-                        if (childItem->GetIndent() > baseIndent)
-                        {
-                            childItem->SetSelected(false);
-                            selections_.Erase(j);
-                            contentElement_->RemoveChildAtIndex(i + 1);
-                            overlayContainer_->RemoveChildAtIndex(i + 1);
-                            ++removed;
-                        }
-                        else
-                            break;
-                    }
-                }
-
-                // Check if the parent of removed item still has other children
-                if (i > 0)
-                {
-                    int baseIndent = item->GetIndent();
-                    UIElement* prevKin = GetItem(i - 1);        // Could be parent or sibling
-                    if (prevKin->GetIndent() < baseIndent)
-                    {
-                        UIElement* nextKin = GetItem(i + 1);    // Could be sibling or parent-sibling or 0 if index out of bound
-                        if (!nextKin || nextKin->GetIndent() < baseIndent)
-                        {
-                            // If we reach here then the parent has no other children
-                            SetItemHierarchyParent(prevKin, false);
-                        }
-                    }
-                }
-
-                // Remove the overlay at the same index
-                overlayContainer_->RemoveChildAtIndex(i);
-            }
-
-            // If necessary, shift the following selections
-            if (!selections_.Empty())
-            {
-                for (unsigned j = 0; j < selections_.Size(); ++j)
-                {
-                    if (selections_[j] > i)
-                        selections_[j] -= removed;
-                }
-
-                UpdateSelectionEffect();
-            }
-
-            contentElement_->RemoveChildAtIndex(i);
-            break;
-        }
-    }
-}
-
-void ListView::RemoveItem(unsigned index)
-{
-    RemoveItem(GetItem(index), index);
-}
-
-void ListView::RemoveAllItems()
-{
-    contentElement_->DisableLayoutUpdate();
-
-    ClearSelection();
-    contentElement_->RemoveAllChildren();
-    if (hierarchyMode_)
-        overlayContainer_->RemoveAllChildren();
-
-    contentElement_->EnableLayoutUpdate();
-    contentElement_->UpdateLayout();
-}
-
-void ListView::SetSelection(unsigned index)
-{
-    PODVector<unsigned> indices;
-    indices.Push(index);
-    SetSelections(indices);
-    EnsureItemVisibility(index);
-}
-
-void ListView::SetSelections(const PODVector<unsigned>& indices)
-{
-    // Make a weak pointer to self to check for destruction as a response to events
-    WeakPtr<ListView> self(this);
-
-    unsigned numItems = GetNumItems();
-
-    // Remove first items that should no longer be selected
-    for (PODVector<unsigned>::Iterator i = selections_.Begin(); i != selections_.End();)
-    {
-        unsigned index = *i;
-        if (!indices.Contains(index))
-        {
-            i = selections_.Erase(i);
-
-            using namespace ItemSelected;
-
-            VariantMap& eventData = GetEventDataMap();
-            eventData[P_ELEMENT] = this;
-            eventData[P_SELECTION] = index;
-            SendEvent(E_ITEMDESELECTED, eventData);
-
-            if (self.Expired())
-                return;
-        }
-        else
-            ++i;
-    }
-
-    bool added = false;
-
-    // Then add missing items
-    for (PODVector<unsigned>::ConstIterator i = indices.Begin(); i != indices.End(); ++i)
-    {
-        unsigned index = *i;
-        if (index < numItems)
-        {
-            // In singleselect mode, resend the event even for the same selection
-            bool duplicate = selections_.Contains(index);
-            if (!duplicate || !multiselect_)
-            {
-                if (!duplicate)
-                {
-                    selections_.Push(index);
-                    added = true;
-                }
-
-                using namespace ItemSelected;
-
-                VariantMap& eventData = GetEventDataMap();
-                eventData[P_ELEMENT] = this;
-                eventData[P_SELECTION] = *i;
-                SendEvent(E_ITEMSELECTED, eventData);
-
-                if (self.Expired())
-                    return;
-            }
-        }
-        // If no multiselect enabled, allow setting only one item
-        if (!multiselect_)
-            break;
-    }
-
-    // Re-sort selections if necessary
-    if (added)
-        Sort(selections_.Begin(), selections_.End());
-
-    UpdateSelectionEffect();
-    SendEvent(E_SELECTIONCHANGED);
-}
-
-void ListView::AddSelection(unsigned index)
-{
-    // Make a weak pointer to self to check for destruction as a response to events
-    WeakPtr<ListView> self(this);
-
-    if (!multiselect_)
-        SetSelection(index);
-    else
-    {
-        if (index >= GetNumItems())
-            return;
-
-        if (!selections_.Contains(index))
-        {
-            selections_.Push(index);
-
-            using namespace ItemSelected;
-
-            VariantMap& eventData = GetEventDataMap();
-            eventData[P_ELEMENT] = this;
-            eventData[P_SELECTION] = index;
-            SendEvent(E_ITEMSELECTED, eventData);
-
-            if (self.Expired())
-                return;
-
-            Sort(selections_.Begin(), selections_.End());
-        }
-
-        EnsureItemVisibility(index);
-        UpdateSelectionEffect();
-        SendEvent(E_SELECTIONCHANGED);
-    }
-}
-
-void ListView::RemoveSelection(unsigned index)
-{
-    if (index >= GetNumItems())
-        return;
-
-    if (selections_.Remove(index))
-    {
-        using namespace ItemSelected;
-
-        VariantMap& eventData = GetEventDataMap();
-        eventData[P_ELEMENT] = this;
-        eventData[P_SELECTION] = index;
-        SendEvent(E_ITEMDESELECTED, eventData);
-    }
-
-    EnsureItemVisibility(index);
-    UpdateSelectionEffect();
-    SendEvent(E_SELECTIONCHANGED);
-}
-
-void ListView::ToggleSelection(unsigned index)
-{
-    unsigned numItems = GetNumItems();
-    if (index >= numItems)
-        return;
-
-    if (selections_.Contains(index))
-        RemoveSelection(index);
-    else
-        AddSelection(index);
-}
-
-void ListView::ChangeSelection(int delta, bool additive)
-{
-    unsigned numItems = GetNumItems();
-    if (selections_.Empty())
-    {
-        // Select first item if there is no selection yet
-        if (numItems > 0)
-            SetSelection(0);
-        if (abs(delta) == 1)
-            return;
-    }
-    if (!multiselect_)
-        additive = false;
-
-    // If going downwards, use the last selection as a base. Otherwise use first
-    unsigned selection = delta > 0 ? selections_.Back() : selections_.Front();
-    int direction = delta > 0 ? 1 : -1;
-    unsigned newSelection = selection;
-    unsigned okSelection = selection;
-    PODVector<unsigned> indices = selections_;
-
-    while (delta != 0)
-    {
-        newSelection += direction;
-        if (newSelection >= numItems)
-            break;
-
-        UIElement* item = GetItem(newSelection);
-        if (item->IsVisible())
-        {
-            indices.Push(okSelection = newSelection);
-            delta -= direction;
-        }
-    }
-
-    if (!additive)
-        SetSelection(okSelection);
-    else
-        SetSelections(indices);
-}
-
-void ListView::ClearSelection()
-{
-    SetSelections(PODVector<unsigned>());
-}
-
-void ListView::SetHighlightMode(HighlightMode mode)
-{
-    highlightMode_ = mode;
-    UpdateSelectionEffect();
-}
-
-void ListView::SetMultiselect(bool enable)
-{
-    multiselect_ = enable;
-}
-
-void ListView::SetHierarchyMode(bool enable)
-{
-    if (enable == hierarchyMode_)
-        return;
-
-    hierarchyMode_ = enable;
-    UIElement* container;
-    if (enable)
-    {
-        overlayContainer_ = new UIElement(context_);
-        overlayContainer_->SetName("LV_OverlayContainer");
-        overlayContainer_->SetInternal(true);
-        AddChild(overlayContainer_);
-        overlayContainer_->SetSortChildren(false);
-        overlayContainer_->SetClipChildren(true);
-
-        container = new HierarchyContainer(context_, this, overlayContainer_);
-    }
-    else
-    {
-        if (overlayContainer_)
-        {
-            RemoveChild(overlayContainer_);
-            overlayContainer_.Reset();
-        }
-
-        container = new UIElement(context_);
-    }
-
-    container->SetName("LV_ItemContainer");
-    container->SetInternal(true);
-    SetContentElement(container);
-    container->SetEnabled(true);
-    container->SetSortChildren(false);
-}
-
-void ListView::SetBaseIndent(int baseIndent)
-{
-    baseIndent_ = baseIndent;
-    UpdateLayout();
-}
-
-void ListView::SetClearSelectionOnDefocus(bool enable)
-{
-    if (enable != clearSelectionOnDefocus_)
-    {
-        clearSelectionOnDefocus_ = enable;
-        if (clearSelectionOnDefocus_ && !HasFocus())
-            ClearSelection();
-    }
-}
-
-void ListView::SetSelectOnClickEnd(bool enable)
-{
-    if (enable != selectOnClickEnd_)
-    {
-        selectOnClickEnd_ = enable;
-        UpdateUIClickSubscription();
-    }
-}
-
-void ListView::Expand(unsigned index, bool enable, bool recursive)
-{
-    if (!hierarchyMode_)
-        return;
-
-    unsigned numItems = GetNumItems();
-    if (index >= numItems)
-        return;
-
-    UIElement* item = GetItem(index++);
-    SetItemExpanded(item, enable);
-    int baseIndent = item->GetIndent();
-
-    PODVector<bool> expanded(baseIndent + 1);
-    expanded[baseIndent] = enable;
-
-    contentElement_->DisableLayoutUpdate();
-
-    while (index < numItems)
-    {
-        item = GetItem(index++);
-        int indent = item->GetIndent();
-        if (indent <= baseIndent)
-            break;
-
-        // Propagate the state to children when it is recursive
-        if (recursive)
-            SetItemExpanded(item, enable);
-
-        // Use the parent expanded flag to influence the visibility of its children
-        bool visible = enable && expanded[indent - 1];
-        item->SetVisible(visible);
-
-        if (indent >= (int)expanded.Size())
-            expanded.Resize(indent + 1);
-        expanded[indent] = visible && GetItemExpanded(item);
-    }
-
-    contentElement_->EnableLayoutUpdate();
-    contentElement_->UpdateLayout();
-}
-
-void ListView::ToggleExpand(unsigned index, bool recursive)
-{
-    if (!hierarchyMode_)
-        return;
-
-    unsigned numItems = GetNumItems();
-    if (index >= numItems)
-        return;
-
-    UIElement* item = GetItem(index);
-    Expand(index, !GetItemExpanded(item), recursive);
-}
-
-unsigned ListView::GetNumItems() const
-{
-    return contentElement_->GetNumChildren();
-}
-
-UIElement* ListView::GetItem(unsigned index) const
-{
-    return contentElement_->GetChild(index);
-}
-
-PODVector<UIElement*> ListView::GetItems() const
-{
-    PODVector<UIElement*> items;
-    contentElement_->GetChildren(items);
-    return items;
-}
-
-unsigned ListView::FindItem(UIElement* item) const
-{
-    if (!item)
-        return M_MAX_UNSIGNED;
-
-    // Early-out by checking if the item belongs to the listview hierarchy at all
-    if (item->GetParent() != contentElement_)
-        return M_MAX_UNSIGNED;
-
-    const Vector<SharedPtr<UIElement> >& children = contentElement_->GetChildren();
-
-    // Binary search for list item based on screen coordinate Y
-    if (contentElement_->GetLayoutMode() == LM_VERTICAL && item->GetHeight())
-    {
-        int itemY = item->GetScreenPosition().y_;
-        int left = 0;
-        int right = children.Size() - 1;
-        while (right >= left)
-        {
-            int mid = (left + right) / 2;
-            if (children[mid] == item)
-                return mid;
-            if (itemY < children[mid]->GetScreenPosition().y_)
-                right = mid - 1;
-            else
-                left = mid + 1;
-        }
-    }
-
-    // Fallback to linear search in case the coordinates/sizes were not yet initialized
-    for (unsigned i = 0; i < children.Size(); ++i)
-    {
-        if (children[i] == item)
-            return i;
-    }
-
-    return M_MAX_UNSIGNED;
-}
-
-unsigned ListView::GetSelection() const
-{
-    if (selections_.Empty())
-        return M_MAX_UNSIGNED;
-    else
-        return GetSelections().Front();
-}
-
-UIElement* ListView::GetSelectedItem() const
-{
-    return contentElement_->GetChild(GetSelection());
-}
-
-PODVector<UIElement*> ListView::GetSelectedItems() const
-{
-    PODVector<UIElement*> ret;
-
-    for (PODVector<unsigned>::ConstIterator i = selections_.Begin(); i != selections_.End(); ++i)
-    {
-        UIElement* item = GetItem(*i);
-        if (item)
-            ret.Push(item);
-    }
-
-    return ret;
-}
-
-void ListView::CopySelectedItemsToClipboard() const
-{
-    String selectedText;
-
-    for (PODVector<unsigned>::ConstIterator i = selections_.Begin(); i != selections_.End(); ++i)
-    {
-        // Only handle Text UI element
-        Text* text = dynamic_cast<Text*>(GetItem(*i));
-        if (text)
-            selectedText.Append(text->GetText()).Append("\n");
-    }
-
-    GetSubsystem<UI>()->SetClipboardText(selectedText);
-}
-
-bool ListView::IsSelected(unsigned index) const
-{
-    return selections_.Contains(index);
-}
-
-bool ListView::IsExpanded(unsigned index) const
-{
-    return GetItemExpanded(contentElement_->GetChild(index));
-}
-
-bool ListView::FilterImplicitAttributes(XMLElement& dest) const
-{
-    if (!ScrollView::FilterImplicitAttributes(dest))
-        return false;
-
-    XMLElement childElem = dest.GetChild("element");    // Horizontal scroll bar
-    if (!childElem)
-        return false;
-    childElem = childElem.GetNext("element");           // Vertical scroll bar
-    if (!childElem)
-        return false;
-    childElem = childElem.GetNext("element");           // Scroll panel
-    if (!childElem)
-        return false;
-
-    XMLElement containerElem = childElem.GetChild("element");   // Item container
-    if (!containerElem)
-        return false;
-    if (!RemoveChildXML(containerElem, "Name", "LV_ItemContainer"))
-        return false;
-    if (!RemoveChildXML(containerElem, "Is Enabled", "true"))
-        return false;
-    if (!RemoveChildXML(containerElem, "Layout Mode", "Vertical"))
-        return false;
-    if (!RemoveChildXML(containerElem, "Size"))
-        return false;
-
-    if (hierarchyMode_)
-    {
-        containerElem = childElem.GetNext("element");           // Overlay container
-        if (!containerElem)
-            return false;
-        if (!RemoveChildXML(containerElem, "Name", "LV_OverlayContainer"))
-            return false;
-        if (!RemoveChildXML(containerElem, "Clip Children", "true"))
-            return false;
-        if (!RemoveChildXML(containerElem, "Size"))
-            return false;
-    }
-
-    return true;
-}
-
-void ListView::UpdateSelectionEffect()
-{
-    unsigned numItems = GetNumItems();
-    bool highlighted = highlightMode_ == HM_ALWAYS || HasFocus();
-
-    for (unsigned i = 0; i < numItems; ++i)
-    {
-        UIElement* item = GetItem(i);
-        if (highlightMode_ != HM_NEVER && selections_.Contains(i))
-            item->SetSelected(highlighted);
-        else
-            item->SetSelected(false);
-    }
-}
-
-void ListView::EnsureItemVisibility(unsigned index)
-{
-    EnsureItemVisibility(GetItem(index));
-}
-
-void ListView::EnsureItemVisibility(UIElement* item)
-{
-    if (!item || !item->IsVisible())
-        return;
-
-    IntVector2 newView = GetViewPosition();
-    IntVector2 currentOffset = item->GetPosition() - newView;
-    const IntRect& clipBorder = scrollPanel_->GetClipBorder();
-    IntVector2 windowSize(scrollPanel_->GetWidth() - clipBorder.left_ - clipBorder.right_, scrollPanel_->GetHeight() -
-        clipBorder.top_ - clipBorder.bottom_);
-
-    if (currentOffset.y_ < 0)
-        newView.y_ += currentOffset.y_;
-    if (currentOffset.y_ + item->GetHeight() > windowSize.y_)
-        newView.y_ += currentOffset.y_ + item->GetHeight() - windowSize.y_;
-
-    SetViewPosition(newView);
-}
-
-void ListView::HandleUIMouseClick(StringHash eventType, VariantMap& eventData)
-{
-    // Disregard the click end if a drag is going on
-    if (selectOnClickEnd_ && GetSubsystem<UI>()->IsDragging())
-        return;
-
-    int button = eventData[UIMouseClick::P_BUTTON].GetInt();
-    int buttons = eventData[UIMouseClick::P_BUTTONS].GetInt();
-    int qualifiers = eventData[UIMouseClick::P_QUALIFIERS].GetInt();
-
-    UIElement* element = static_cast<UIElement*>(eventData[UIMouseClick::P_ELEMENT].GetPtr());
-
-    // Check if the clicked element belongs to the list
-    unsigned i = FindItem(element);
-    if (i >= GetNumItems())
-        return;
-
-    // If not editable, repeat the previous selection. This will send an event and allow eg. a dropdownlist to close
-    if (!editable_)
-    {
-        SetSelections(selections_);
-        return;
-    }
-
-    if (button == MOUSEB_LEFT)
-    {
-        // Single selection
-        if (!multiselect_ || !qualifiers)
-            SetSelection(i);
-
-        // Check multiselect with shift & ctrl
-        if (multiselect_)
-        {
-            if (qualifiers & QUAL_SHIFT)
-            {
-                if (selections_.Empty())
-                    SetSelection(i);
-                else
-                {
-                    unsigned first = selections_.Front();
-                    unsigned last = selections_.Back();
-                    PODVector<unsigned> newSelections = selections_;
-                    if (i == first || i == last)
-                    {
-                        for (unsigned j = first; j <= last; ++j)
-                            newSelections.Push(j);
-                    }
-                    else if (i < first)
-                    {
-                        for (unsigned j = i; j <= first; ++j)
-                            newSelections.Push(j);
-                    }
-                    else if (i < last)
-                    {
-                        if ((abs((int)i - (int)first)) <= (abs((int)i - (int)last)))
-                        {
-                            for (unsigned j = first; j <= i; ++j)
-                                newSelections.Push(j);
-                        }
-                        else
-                        {
-                            for (unsigned j = i; j <= last; ++j)
-                                newSelections.Push(j);
-                        }
-                    }
-                    else if (i > last)
-                    {
-                        for (unsigned j = last; j <= i; ++j)
-                            newSelections.Push(j);
-                    }
-                    SetSelections(newSelections);
-                }
-            }
-            else if (qualifiers & QUAL_CTRL)
-                ToggleSelection(i);
-        }
-    }
-    
-    // Propagate the click as an event. Also include right-clicks
-    VariantMap& clickEventData = GetEventDataMap();
-    clickEventData[ItemClicked::P_ELEMENT] = this;
-    clickEventData[ItemClicked::P_ITEM] = element;
-    clickEventData[ItemClicked::P_SELECTION] = i;
-    clickEventData[ItemClicked::P_BUTTON] = button;
-    clickEventData[ItemClicked::P_BUTTONS] = buttons;
-    clickEventData[ItemClicked::P_QUALIFIERS] = qualifiers;
-    SendEvent(E_ITEMCLICKED, clickEventData);
-}
-
-void ListView::HandleUIMouseDoubleClick(StringHash eventType, VariantMap& eventData)
-{
-    int button = eventData[UIMouseClick::P_BUTTON].GetInt();
-    int buttons = eventData[UIMouseClick::P_BUTTONS].GetInt();
-    int qualifiers = eventData[UIMouseClick::P_QUALIFIERS].GetInt();
-
-    UIElement* element = static_cast<UIElement*>(eventData[UIMouseClick::P_ELEMENT].GetPtr());
-    // Check if the clicked element belongs to the list
-    unsigned i = FindItem(element);
-    if (i >= GetNumItems())
-        return;
-
-    VariantMap& clickEventData = GetEventDataMap();
-    clickEventData[ItemDoubleClicked::P_ELEMENT] = this;
-    clickEventData[ItemDoubleClicked::P_ITEM] = element;
-    clickEventData[ItemDoubleClicked::P_SELECTION] = i;
-    clickEventData[ItemDoubleClicked::P_BUTTON] = button;
-    clickEventData[ItemDoubleClicked::P_BUTTONS] = buttons;
-    clickEventData[ItemDoubleClicked::P_QUALIFIERS] = qualifiers;
-    SendEvent(E_ITEMDOUBLECLICKED, clickEventData);
-}
-
-
-void ListView::HandleItemFocusChanged(StringHash eventType, VariantMap& eventData)
-{
-    using namespace FocusChanged;
-
-    UIElement* element = static_cast<UIElement*>(eventData[P_ELEMENT].GetPtr());
-    while (element)
-    {
-        // If the focused element or its parent is in the list, scroll the list to make the item visible
-        UIElement* parent = element->GetParent();
-        if (parent == contentElement_)
-        {
-            EnsureItemVisibility(element);
-            return;
-        }
-        element = parent;
-    }
-}
-
-void ListView::HandleFocusChanged(StringHash eventType, VariantMap& eventData)
-{
-    scrollPanel_->SetSelected(eventType == E_FOCUSED);
-    if (clearSelectionOnDefocus_ && eventType == E_DEFOCUSED)
-        ClearSelection();
-    else if (highlightMode_ == HM_FOCUS)
-        UpdateSelectionEffect();
-}
-
-void ListView::UpdateUIClickSubscription()
-{
-    UnsubscribeFromEvent(E_UIMOUSECLICK);
-    UnsubscribeFromEvent(E_UIMOUSECLICKEND);
-    SubscribeToEvent(selectOnClickEnd_ ? E_UIMOUSECLICKEND : E_UIMOUSECLICK, HANDLER(ListView, HandleUIMouseClick));
-}
-
-}

+ 0 - 180
Source/Atomic/UI/ListView.h

@@ -1,180 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/ScrollView.h"
-
-namespace Atomic
-{
-
-/// %ListView selection highlight mode.
-enum HighlightMode
-{
-    /// Never highlight selections.
-    HM_NEVER,
-    /// Highlight when focused.
-    HM_FOCUS,
-    /// Highlight always.
-    HM_ALWAYS
-};
-
-/// Scrollable list %UI element.
-class ATOMIC_API ListView : public ScrollView
-{
-    OBJECT(ListView);
-
-public:
-    /// Construct.
-    ListView(Context* context);
-    /// Destruct.
-    virtual ~ListView();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// React to a key press.
-    virtual void OnKey(int key, int buttons, int qualifiers);
-    /// React to resize.
-    virtual void OnResize();
-
-    /// Add item to the end of the list.
-    void AddItem(UIElement* item);
-    /// \brief Insert item at a specific index. In hierarchy mode, the optional parameter will be used to determine the child's indent level in respect to its parent.
-    /// If index is greater than the total items then the new item is inserted at the end of the list.
-    /// In hierarchy mode, if index is greater than the index of last children of the specified parent item then the new item is inserted next to the last children.
-    /// And if the index is lesser than the index of the parent item itself then the new item is inserted before the first child item.
-    void InsertItem(unsigned index, UIElement* item, UIElement* parentItem = 0);
-    /// Remove specific item, starting search at the specified index if provided. In hierarchy mode will also remove any children.
-    void RemoveItem(UIElement* item, unsigned index = 0);
-    /// Remove item at index. In hierarchy mode will also remove any children.
-    void RemoveItem(unsigned index);
-    /// Remove all items.
-    void RemoveAllItems();
-    /// Set selection.
-    void SetSelection(unsigned index);
-    /// Set multiple selected items. If multiselect disabled, sets only the first.
-    void SetSelections(const PODVector<unsigned>& indices);
-    /// Add item to the selection, multiselect mode only.
-    void AddSelection(unsigned index);
-    /// Remove item from the selection.
-    void RemoveSelection(unsigned index);
-    /// Toggle selection of an item.
-    void ToggleSelection(unsigned index);
-    /// Move selection by a delta and clamp at list ends. If additive (multiselect only), will add to the existing selection.
-    void ChangeSelection(int delta, bool additive = false);
-    /// Clear selection.
-    void ClearSelection();
-    /// Set selected items' highlight mode.
-    void SetHighlightMode(HighlightMode mode);
-    /// Enable multiselect.
-    void SetMultiselect(bool enable);
-    /// \brief Enable hierarchy mode. Allows items to have parent-child relationship at different indent level and the ability to expand/collapse child items.
-    /// All items in the list will be lost during mode change.
-    void SetHierarchyMode(bool enable);
-    /// Set base indent, i.e. the indent level of the ultimate parent item.
-    void SetBaseIndent(int baseIndent);
-    /// Enable clearing of selection on defocus.
-    void SetClearSelectionOnDefocus(bool enable);
-    /// Enable reacting to click end instead of click start for item selection. Default false.
-    void SetSelectOnClickEnd(bool enable);
-
-    /// Expand item at index. Only has effect in hierarchy mode.
-    void Expand(unsigned index, bool enable, bool recursive = false);
-    /// Toggle item's expanded flag at index. Only has effect in hierarchy mode.
-    void ToggleExpand(unsigned index, bool recursive = false);
-
-    /// Return number of items.
-    unsigned GetNumItems() const;
-    /// Return item at index.
-    UIElement* GetItem(unsigned index) const;
-    /// Return all items.
-    PODVector<UIElement*> GetItems() const;
-    /// Return index of item, or M_MAX_UNSIGNED If not found.
-    unsigned FindItem(UIElement* item) const;
-    /// Return first selected index, or M_MAX_UNSIGNED if none selected.
-    unsigned GetSelection() const;
-    /// Return all selected indices.
-    const PODVector<unsigned>& GetSelections() const { return selections_; }
-    /// Copy selected items to system clipboard. Currently only applicable to Text items.
-    void CopySelectedItemsToClipboard() const;
-    /// Return first selected item, or null if none selected.
-    UIElement* GetSelectedItem() const;
-    /// Return all selected items.
-    PODVector<UIElement*> GetSelectedItems() const;
-    /// Return whether an item at index is seleccted.
-    bool IsSelected(unsigned index) const;
-    /// Return whether an item at index has its children expanded (in hierachy mode only).
-    bool IsExpanded(unsigned index) const;
-    /// Return highlight mode.
-    HighlightMode GetHighlightMode() const { return highlightMode_; }
-    /// Return whether multiselect enabled.
-    bool GetMultiselect() const { return multiselect_; }
-    /// Return whether selection is cleared on defocus.
-    bool GetClearSelectionOnDefocus() const { return clearSelectionOnDefocus_; }
-    /// Return whether reacts to click end instead of click start for item selection.
-    bool GetSelectOnClickEnd() const { return selectOnClickEnd_; }
-    /// Return whether hierarchy mode enabled.
-    bool GetHierarchyMode() const { return hierarchyMode_; }
-    /// Return base indent.
-    int GetBaseIndent() const { return baseIndent_; }
-    /// Ensure full visibility of the item.
-    void EnsureItemVisibility(unsigned index);
-    /// Ensure full visibility of the item.
-    void EnsureItemVisibility(UIElement* item);
-
-protected:
-    /// Filter implicit attributes in serialization process.
-    virtual bool FilterImplicitAttributes(XMLElement& dest) const;
-    /// Update selection effect when selection or focus changes.
-    void UpdateSelectionEffect();
-
-    /// Current selection.
-    PODVector<unsigned> selections_;
-    /// Highlight mode.
-    HighlightMode highlightMode_;
-    /// Multiselect flag.
-    bool multiselect_;
-    /// Hierarchy mode flag.
-    bool hierarchyMode_;
-    /// Base indent, used in hierarchy mode only.
-    int baseIndent_;
-    /// Overlay container, used in hierarchy mode only.
-    SharedPtr<UIElement> overlayContainer_;
-    /// Clear selection on defocus flag.
-    bool clearSelectionOnDefocus_;
-    /// React to click end instead of click start flag.
-    bool selectOnClickEnd_;
-
-private:
-    /// Handle global UI mouseclick to check for selection change.
-    void HandleUIMouseClick(StringHash eventType, VariantMap& eventData);
-    /// Handle global UI mouse doubleclick.
-    void HandleUIMouseDoubleClick(StringHash eventType, VariantMap& eventData);
-    /// Handle global focus change to check whether an invisible item was focused.
-    void HandleItemFocusChanged(StringHash eventType, VariantMap& eventData);
-    /// Handle focus changed.
-    void HandleFocusChanged(StringHash eventType, VariantMap& eventData);
-    /// Update subscription to UI click events
-    void UpdateUIClickSubscription();
-};
-
-}

+ 0 - 439
Source/Atomic/UI/Menu.cpp

@@ -1,439 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../Input/InputEvents.h"
-#include "../IO/Log.h"
-#include "../UI/Menu.h"
-#include "../UI/UI.h"
-#include "../UI/UIEvents.h"
-#include "../UI/Window.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-const StringHash VAR_SHOW_POPUP("ShowPopup");
-extern StringHash VAR_ORIGIN;
-
-extern const char* UI_CATEGORY;
-
-Menu::Menu(Context* context) :
-    Button(context),
-    popupOffset_(IntVector2::ZERO),
-    showPopup_(false),
-    acceleratorKey_(0),
-    acceleratorQualifiers_(0),
-    autoPopup_(true)
-{
-    focusMode_ = FM_NOTFOCUSABLE;
-
-    SubscribeToEvent(this, E_PRESSED, HANDLER(Menu, HandlePressedReleased));
-    SubscribeToEvent(this, E_RELEASED, HANDLER(Menu, HandlePressedReleased));
-    SubscribeToEvent(E_UIMOUSECLICK, HANDLER(Menu, HandleFocusChanged));
-    SubscribeToEvent(E_FOCUSCHANGED, HANDLER(Menu, HandleFocusChanged));
-}
-
-Menu::~Menu()
-{
-    if (popup_ && showPopup_)
-        ShowPopup(false);
-}
-
-void Menu::RegisterObject(Context* context)
-{
-    context->RegisterFactory<Menu>(UI_CATEGORY);
-
-    COPY_BASE_ATTRIBUTES(Button);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Focus Mode", FM_NOTFOCUSABLE);
-    ACCESSOR_ATTRIBUTE("Popup Offset", GetPopupOffset, SetPopupOffset, IntVector2, IntVector2::ZERO, AM_FILE);
-}
-
-void Menu::Update(float timeStep)
-{
-    Button::Update(timeStep);
-    
-    if (popup_ && showPopup_)
-    {
-        const Vector<SharedPtr<UIElement> >& children = popup_->GetChildren();
-        for (unsigned i = 0; i < children.Size(); ++i)
-        {
-            Menu* menu = dynamic_cast<Menu*>(children[i].Get());
-            if (menu && !menu->autoPopup_ && !menu->IsHovering())
-                menu->autoPopup_ = true;
-        }
-    }
-}
-
-void Menu::OnHover(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
-{
-    Button::OnHover(position, screenPosition, buttons, qualifiers, cursor);
-
-    Menu* sibling = static_cast<Menu*>(parent_->GetChild(VAR_SHOW_POPUP, true));
-    if (popup_ && !showPopup_)
-    {
-        // Check if popup is shown by one of the siblings
-        if (sibling)
-        {
-            // "Move" the popup from sibling menu to this menu
-            sibling->ShowPopup(false);
-            ShowPopup(true);
-            return;
-        }
-
-        if (autoPopup_)
-        {
-            // Show popup when parent menu has its popup shown
-            Menu* parentMenu = static_cast<Menu*>(parent_->GetVar(VAR_ORIGIN).GetPtr());
-            if (parentMenu && parentMenu->showPopup_)
-                ShowPopup(true);
-        }
-    }
-    else
-    {
-        // Hide child menu popup when its parent is no longer being hovered
-        if (sibling && sibling != this)
-            sibling->ShowPopup(false);
-    }
-}
-
-void Menu::OnShowPopup()
-{
-}
-
-bool Menu::LoadXML(const XMLElement& source, XMLFile* styleFile, bool setInstanceDefault)
-{
-    // Get style override if defined
-    String styleName = source.GetAttribute("style");
-
-    // Apply the style first, if the style file is available
-    if (styleFile)
-    {
-        // If not defined, use type name
-        if (styleName.Empty())
-            styleName = GetTypeName();
-
-        SetStyle(styleName, styleFile);
-    }
-    // The 'style' attribute value in the style file cannot be equals to original's applied style to prevent infinite loop
-    else if (!styleName.Empty() && styleName != appliedStyle_)
-    {
-        // Attempt to use the default style file
-        styleFile = GetDefaultStyle();
-
-        if (styleFile)
-        {
-            // Remember the original applied style
-            String appliedStyle(appliedStyle_);
-            SetStyle(styleName, styleFile);
-            appliedStyle_ = appliedStyle;
-        }
-    }
-
-    // Then load rest of the attributes from the source
-    if (!Serializable::LoadXML(source, setInstanceDefault))
-        return false;
-
-    unsigned nextInternalChild = 0;
-
-    // Load child elements. Internal elements are not to be created as they already exist
-    XMLElement childElem = source.GetChild("element");
-    while (childElem)
-    {
-        bool internalElem = childElem.GetBool("internal");
-        bool popupElem = childElem.GetBool("popup");
-        String typeName = childElem.GetAttribute("type");
-        if (typeName.Empty())
-            typeName = "UIElement";
-        unsigned index = childElem.HasAttribute("index") ? childElem.GetUInt("index") : M_MAX_UNSIGNED;
-        UIElement* child = 0;
-
-        if (!internalElem)
-        {
-            if (!popupElem)
-                child = CreateChild(typeName, String::EMPTY, index);
-            else
-            {
-                // Do not add the popup element as a child even temporarily, as that can break layouts
-                SharedPtr<UIElement> popup = DynamicCast<UIElement>(context_->CreateObject(typeName));
-                if (!popup)
-                    LOGERROR("Could not create popup element type " + typeName);
-                else
-                {
-                    child = popup;
-                    SetPopup(popup);
-                }
-            }
-        }
-        else
-        {
-            // An internal popup element should already exist
-            if (popupElem)
-                child = popup_;
-            else
-            {
-                for (unsigned i = nextInternalChild; i < children_.Size(); ++i)
-                {
-                    if (children_[i]->IsInternal() && children_[i]->GetTypeName() == typeName)
-                    {
-                        child = children_[i];
-                        nextInternalChild = i + 1;
-                        break;
-                    }
-                }
-
-                if (!child)
-                    LOGWARNING("Could not find matching internal child element of type " + typeName + " in " + GetTypeName());
-            }
-        }
-
-        if (child)
-        {
-            if (!styleFile)
-                styleFile = GetDefaultStyle();
-
-            // As popup is not a child element in itself, the parental chain to acquire the default style file is broken for popup's child elements
-            // To recover from this, popup needs to have the default style set in its own instance so the popup's child elements can find it later
-            if (popupElem)
-                child->SetDefaultStyle(styleFile);
-
-            if (!child->LoadXML(childElem, styleFile, setInstanceDefault))
-                return false;
-        }
-
-        childElem = childElem.GetNext("element");
-    }
-
-    ApplyAttributes();
-
-    return true;
-}
-
-bool Menu::SaveXML(XMLElement& dest) const
-{
-    if (!Button::SaveXML(dest))
-        return false;
-
-    // Save the popup element as a "virtual" child element
-    if (popup_)
-    {
-        XMLElement childElem = dest.CreateChild("element");
-        childElem.SetBool("popup", true);
-        if (!popup_->SaveXML(childElem))
-            return false;
-
-        // Filter popup implicit attributes
-        if (!FilterPopupImplicitAttributes(childElem))
-        {
-            LOGERROR("Could not remove popup implicit attributes");
-            return false;
-        }
-    }
-
-    return true;
-}
-
-void Menu::SetPopup(UIElement* popup)
-{
-    if (popup == this)
-        return;
-
-    // Currently only allow popup 'window'
-    if (popup->GetType() != Window::GetTypeStatic())
-    {
-        LOGERROR("Could not set popup element of type " + popup->GetTypeName() + ", only support popup window for now");
-        return;
-    }
-
-    if (popup_ && !popup)
-        ShowPopup(false);
-
-    popup_ = popup;
-
-    // Detach from current parent (if any) to only show when it is time
-    if (popup_)
-        popup_->Remove();
-}
-
-void Menu::SetPopupOffset(const IntVector2& offset)
-{
-    popupOffset_ = offset;
-}
-
-void Menu::SetPopupOffset(int x, int y)
-{
-    popupOffset_ = IntVector2(x, y);
-}
-
-void Menu::ShowPopup(bool enable)
-{
-    if (!popup_)
-        return;
-
-    if (enable)
-    {
-        OnShowPopup();
-
-        popup_->SetVar(VAR_ORIGIN, this);
-        static_cast<Window*>(popup_.Get())->SetModal(true);
-
-        popup_->SetPosition(GetScreenPosition() + popupOffset_);
-        popup_->SetVisible(true);
-        // BringToFront() is unreliable in this case as it takes into account only input-enabled elements.
-        // Rather just force priority to max
-        popup_->SetPriority(M_MAX_INT);
-    }
-    else
-    {
-        OnHidePopup();
-
-        // If the popup has child menus, hide their popups as well
-        PODVector<UIElement*> children;
-        popup_->GetChildren(children, true);
-        for (PODVector<UIElement*>::ConstIterator i = children.Begin(); i != children.End(); ++i)
-        {
-            Menu* menu = dynamic_cast<Menu*>(*i);
-            if (menu)
-                menu->ShowPopup(false);
-        }
-
-        static_cast<Window*>(popup_.Get())->SetModal(false);
-        const_cast<VariantMap&>(popup_->GetVars()).Erase(VAR_ORIGIN);
-
-        popup_->SetVisible(false);
-        popup_->Remove();
-    }
-    SetVar(VAR_SHOW_POPUP, enable);
-
-    showPopup_ = enable;
-    selected_ = enable;
-}
-
-void Menu::SetAccelerator(int key, int qualifiers)
-{
-    acceleratorKey_ = key;
-    acceleratorQualifiers_ = qualifiers;
-
-    if (key)
-        SubscribeToEvent(E_KEYDOWN, HANDLER(Menu, HandleKeyDown));
-    else
-        UnsubscribeFromEvent(E_KEYDOWN);
-}
-
-bool Menu::FilterPopupImplicitAttributes(XMLElement& dest) const
-{
-    if (!RemoveChildXML(dest, "Position"))
-        return false;
-    if (!RemoveChildXML(dest, "Is Visible"))
-        return false;
-
-    return true;
-}
-
-void Menu::HandlePressedReleased(StringHash eventType, VariantMap& eventData)
-{
-    // If this menu shows a sublevel popup, react to button press. Else react to release
-    if (eventType == E_PRESSED)
-    {
-        if (!popup_)
-            return;
-    }
-    if (eventType == E_RELEASED)
-    {
-        if (popup_)
-            return;
-    }
-
-    // Manual handling of the popup, so switch off the auto popup flag
-    autoPopup_ = false;
-    // Toggle popup visibility if exists
-    ShowPopup(!showPopup_);
-
-    // Send event on each click if no popup, or whenever the popup is opened
-    if (!popup_ || showPopup_)
-    {
-        using namespace MenuSelected;
-
-        VariantMap& newEventData = GetEventDataMap();
-        newEventData[P_ELEMENT] = this;
-        SendEvent(E_MENUSELECTED, newEventData);
-    }
-}
-
-void Menu::HandleFocusChanged(StringHash eventType, VariantMap& eventData)
-{
-    if (!showPopup_)
-        return;
-
-    using namespace FocusChanged;
-
-    UIElement* element = static_cast<UIElement*>(eventData[P_ELEMENT].GetPtr());
-    UIElement* root = GetRoot();
-
-    // If another element was focused due to the menu button being clicked, do not hide the popup
-    if (eventType == E_FOCUSCHANGED && static_cast<UIElement*>(eventData[P_CLICKEDELEMENT].GetPtr()))
-        return;
-
-    // If clicked emptiness or defocused, hide the popup
-    if (!element)
-    {
-        ShowPopup(false);
-        return;
-    }
-
-    // Otherwise see if the clicked element has either the menu item or the popup in its parent chain.
-    // In that case, do not hide
-    while (element)
-    {
-        if (element == this || element == popup_)
-            return;
-        if (element->GetParent() == root)
-            element = static_cast<UIElement*>(element->GetVar(VAR_ORIGIN).GetPtr());
-        else
-            element = element->GetParent();
-    }
-
-    ShowPopup(false);
-}
-
-void Menu::HandleKeyDown(StringHash eventType, VariantMap& eventData)
-{
-    if (!enabled_)
-        return;
-
-    using namespace KeyDown;
-
-    // Activate if accelerator key pressed
-    if (eventData[P_KEY].GetInt() == acceleratorKey_ && (acceleratorQualifiers_ == QUAL_ANY || eventData[P_QUALIFIERS].GetInt() ==
-        acceleratorQualifiers_) && eventData[P_REPEAT].GetBool() == false)
-    {
-        // Ignore if UI has modal element
-        if (GetSubsystem<UI>()->HasModalElement())
-            return;
-
-        HandlePressedReleased(eventType, eventData);
-    }
-}
-
-}

+ 0 - 106
Source/Atomic/UI/Menu.h

@@ -1,106 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/Button.h"
-
-namespace Atomic
-{
-
-/// %Menu %UI element that optionally shows a popup.
-class ATOMIC_API Menu : public Button
-{
-    OBJECT(Menu);
-
-    using UIElement::LoadXML;
-
-public:
-    /// Construct.
-    Menu(Context* context);
-    /// Destruct.
-    virtual ~Menu();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// Load from XML data with style. Return true if successful.
-    virtual bool LoadXML(const XMLElement& source, XMLFile* styleFile, bool setInstanceDefault = false);
-    /// Save as XML data. Return true if successful.
-    virtual bool SaveXML(XMLElement& dest) const;
-
-    /// Perform UI element update.
-    virtual void Update(float timeStep);
-    /// React to mouse hover.
-    virtual void OnHover(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
-    /// React to the popup being shown.
-    virtual void OnShowPopup();
-    /// React to the popup being hidden.
-    virtual void OnHidePopup() {}
-
-    /// Set popup element to show on selection.
-    void SetPopup(UIElement* element);
-    /// Set popup element offset.
-    void SetPopupOffset(const IntVector2& offset);
-    /// Set popup element offset.
-    void SetPopupOffset(int x, int y);
-    /// Force the popup to show or hide.
-    void ShowPopup(bool enable);
-    /// Set accelerator key (set zero key code to disable.)
-    void SetAccelerator(int key, int qualifiers);
-
-    /// Return popup element.
-    UIElement* GetPopup() const { return popup_; }
-    /// Return popup element offset.
-    const IntVector2& GetPopupOffset() const { return popupOffset_; }
-    /// Return whether popup is open.
-    bool GetShowPopup() const { return showPopup_; }
-    /// Return accelerator key code, 0 if disabled.
-    int GetAcceleratorKey() const { return acceleratorKey_; }
-    /// Return accelerator qualifiers.
-    int GetAcceleratorQualifiers() const { return acceleratorQualifiers_; }
-
-protected:
-    /// Filter implicit attributes in serialization process.
-    virtual bool FilterPopupImplicitAttributes(XMLElement& dest) const;
-    /// Popup element.
-    SharedPtr<UIElement> popup_;
-    /// Popup element offset.
-    IntVector2 popupOffset_;
-    /// Show popup flag.
-    bool showPopup_;
-    /// Accelerator key code.
-    int acceleratorKey_;
-    /// Accelerator qualifiers.
-    int acceleratorQualifiers_;
-
-private:
-    /// Handle press and release for selection and toggling popup visibility.
-    void HandlePressedReleased(StringHash eventType, VariantMap& eventData);
-    /// Handle global focus change to check for hiding the popup.
-    void HandleFocusChanged(StringHash eventType, VariantMap& eventData);
-    /// Handle keypress for checking accelerator.
-    void HandleKeyDown(StringHash eventType, VariantMap& eventData);
-    /// Auto popup flag.
-    bool autoPopup_;
-};
-
-}

+ 0 - 144
Source/Atomic/UI/MessageBox.cpp

@@ -1,144 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../UI/Button.h"
-#include "../Core/Context.h"
-#include "../Graphics/Graphics.h"
-#include "../IO/Log.h"
-#include "../UI/MessageBox.h"
-#include "../Resource/ResourceCache.h"
-#include "../UI/Text.h"
-#include "../UI/UI.h"
-#include "../UI/UIEvents.h"
-#include "../UI/Window.h"
-#include "../Resource/XMLFile.h"
-
-namespace Atomic
-{
-
-MessageBox::MessageBox(Context* context, const String& messageString, const String& titleString, XMLFile* layoutFile, XMLFile* styleFile) :
-    Object(context),
-    titleText_(0),
-    messageText_(0),
-    okButton_(0)
-{
-    // If layout file is not given, use the default message box layout
-    if (!layoutFile)
-    {
-        ResourceCache* cache = GetSubsystem<ResourceCache>();
-        layoutFile = cache->GetResource<XMLFile>("UI/MessageBox.xml");
-        if (!layoutFile)    // Error is already logged
-            return;         // Note: windowless MessageBox should not be used!
-    }
-
-    UI* ui = GetSubsystem<UI>();
-    window_ = ui->LoadLayout(layoutFile, styleFile);
-    if (!window_)   // Error is already logged
-        return;
-    ui->GetRoot()->AddChild(window_);
-
-    // Set the title and message strings if they are given
-    titleText_ = dynamic_cast<Text*>(window_->GetChild("TitleText", true));
-    if (titleText_ && !titleString.Empty())
-        titleText_->SetText(titleString);
-    messageText_ = dynamic_cast<Text*>(window_->GetChild("MessageText", true));
-    if (messageText_ && !messageString.Empty())
-        messageText_->SetText(messageString);
-
-    // Center window after the message is set
-    Window* window = dynamic_cast<Window*>(window_.Get());
-    if (window)
-    {
-        Graphics* graphics = GetSubsystem<Graphics>();  // May be null if headless
-        if (graphics)
-        {
-            const IntVector2& size = window->GetSize();
-            window->SetPosition((graphics->GetWidth() - size.x_) / 2, (graphics->GetHeight() - size.y_) / 2);
-        }
-        else
-            LOGWARNING("Instantiating a modal window in headless mode!");
-
-        window->SetModal(true);
-        SubscribeToEvent(window, E_MODALCHANGED, HANDLER(MessageBox, HandleMessageAcknowledged));
-    }
-
-    // Bind the buttons (if any in the loaded UI layout) to event handlers
-    okButton_ = dynamic_cast<Button*>(window_->GetChild("OkButton", true));
-    if (okButton_)
-    {
-        ui->SetFocusElement(okButton_);
-        SubscribeToEvent(okButton_, E_RELEASED, HANDLER(MessageBox, HandleMessageAcknowledged));
-    }
-    Button* cancelButton = dynamic_cast<Button*>(window_->GetChild("CancelButton", true));
-    if (cancelButton)
-        SubscribeToEvent(cancelButton, E_RELEASED, HANDLER(MessageBox, HandleMessageAcknowledged));
-    Button* closeButton = dynamic_cast<Button*>(window_->GetChild("CloseButton", true));
-    if (closeButton)
-        SubscribeToEvent(closeButton, E_RELEASED, HANDLER(MessageBox, HandleMessageAcknowledged));
-}
-
-MessageBox::~MessageBox()
-{
-    if (window_)
-        window_->Remove();
-}
-
-void MessageBox::RegisterObject(Context* context)
-{
-    context->RegisterFactory<MessageBox>();
-}
-
-void MessageBox::SetTitle(const String& text)
-{
-    if (titleText_)
-        titleText_->SetText(text);
-}
-
-void MessageBox::SetMessage(const String& text)
-{
-    if (messageText_)
-        messageText_->SetText(text);
-}
-
-const String& MessageBox::GetTitle() const
-{
-    return titleText_ ? titleText_->GetText() : String::EMPTY;
-}
-
-const String& MessageBox::GetMessage() const
-{
-    return messageText_ ? messageText_->GetText() : String::EMPTY;
-}
-
-void MessageBox::HandleMessageAcknowledged(StringHash eventType, VariantMap& eventData)
-{
-    using namespace MessageACK;
-
-    VariantMap& newEventData = GetEventDataMap();
-    newEventData[P_OK] = eventData[Released::P_ELEMENT] == okButton_;
-    SendEvent(E_MESSAGEACK, newEventData);
-
-    this->ReleaseRef();
-}
-
-}

+ 0 - 74
Source/Atomic/UI/MessageBox.h

@@ -1,74 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../Core/Object.h"
-
-namespace Atomic
-{
-
-class Button;
-class Text;
-class UIElement;
-class XMLFile;
-
-/// Message box dialog.
-class ATOMIC_API MessageBox : public Object
-{
-    OBJECT(MessageBox);
-
-public:
-    /// Construct. If layout file is not given, use the default message box layout. If style file is not given, use the default style file from root UI element.
-    MessageBox(Context* context, const String& messageString = String::EMPTY, const String& titleString = String::EMPTY, XMLFile* layoutFile = 0, XMLFile* styleFile = 0);
-    /// Destruct.
-    virtual ~MessageBox();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// Set title text. No-ops if there is no title text element.
-    void SetTitle(const String& text);
-    /// Set message text. No-ops if there is no message text element.
-    void SetMessage(const String& text);
-
-    /// Return title text. Return empty string if there is no title text element.
-    const String& GetTitle() const;
-    /// Return message text. Return empty string if there is no message text element.
-    const String& GetMessage() const;
-    /// Return dialog window.
-    UIElement* GetWindow() const { return window_; }
-
-private:
-    /// Handle events that dismiss the message box.
-    void HandleMessageAcknowledged(StringHash eventType, VariantMap& eventData);
-
-    /// UI element containing the whole UI layout. Typically it is a Window element type.
-    SharedPtr<UIElement> window_;
-    /// Title text element.
-    Text* titleText_;
-    /// Message text element.
-    Text* messageText_;
-    /// OK button element.
-    Button* okButton_;
-};
-
-}

+ 0 - 322
Source/Atomic/UI/ScrollBar.cpp

@@ -1,322 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../UI/Button.h"
-#include "../Core/Context.h"
-#include "../Input/InputEvents.h"
-#include "../UI/ScrollBar.h"
-#include "../UI/Slider.h"
-#include "../UI/UIEvents.h"
-
-namespace Atomic
-{
-
-static const float DEFAULT_SCROLL_STEP = 0.1f;
-static const float DEFAULT_REPEAT_DELAY = 0.4f;
-static const float DEFAULT_REPEAT_RATE = 20.0f;
-
-extern const char* orientations[];
-extern const char* UI_CATEGORY;
-
-ScrollBar::ScrollBar(Context* context) :
-    UIElement(context),
-    scrollStep_(DEFAULT_SCROLL_STEP),
-    stepFactor_(1.0f),
-    leftRect_(IntRect::ZERO),
-    rightRect_(IntRect::ZERO),
-    upRect_(IntRect::ZERO),
-    downRect_(IntRect::ZERO)
-{
-    SetEnabled(true);
-
-    backButton_ = CreateChild<Button>("SB_Back");
-    backButton_->SetInternal(true);
-    backButton_->SetRepeat(DEFAULT_REPEAT_DELAY, DEFAULT_REPEAT_RATE);
-    backButton_->SetFocusMode(FM_NOTFOCUSABLE);
-    slider_ = CreateChild<Slider>("SB_Slider");
-    slider_->SetInternal(true);
-    slider_->SetRepeatRate(DEFAULT_REPEAT_RATE);
-    forwardButton_ = CreateChild<Button>("SB_Forward");
-    forwardButton_->SetInternal(true);
-    forwardButton_->SetRepeat(DEFAULT_REPEAT_DELAY, DEFAULT_REPEAT_RATE);
-    forwardButton_->SetFocusMode(FM_NOTFOCUSABLE);
-
-    SubscribeToEvent(backButton_, E_PRESSED, HANDLER(ScrollBar, HandleBackButtonPressed));
-    SubscribeToEvent(forwardButton_, E_PRESSED, HANDLER(ScrollBar, HandleForwardButtonPressed));
-    SubscribeToEvent(slider_, E_SLIDERCHANGED, HANDLER(ScrollBar, HandleSliderChanged));
-    SubscribeToEvent(slider_, E_SLIDERPAGED, HANDLER(ScrollBar, HandleSliderPaged));
-
-    // Set default orientation
-    SetOrientation(O_HORIZONTAL);
-}
-
-ScrollBar::~ScrollBar()
-{
-}
-
-void ScrollBar::RegisterObject(Context* context)
-{
-    context->RegisterFactory<ScrollBar>(UI_CATEGORY);
-
-    COPY_BASE_ATTRIBUTES(UIElement);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Is Enabled", true);
-    ENUM_ACCESSOR_ATTRIBUTE("Orientation", GetOrientation, SetOrientation, Orientation, orientations, O_HORIZONTAL, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Range", GetRange, SetRange, float, 1.0f, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Value", GetValue, SetValue, float, 0.0f, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Scroll Step", GetScrollStep, SetScrollStep, float, DEFAULT_SCROLL_STEP, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Step Factor", GetStepFactor, SetStepFactor, float, 1.0f, AM_FILE);
-    ATTRIBUTE("Left Image Rect", IntRect, leftRect_, IntRect::ZERO, AM_FILE);
-    ATTRIBUTE("Right Image Rect", IntRect, rightRect_, IntRect::ZERO, AM_FILE);
-    ATTRIBUTE("Up Image Rect", IntRect, upRect_, IntRect::ZERO, AM_FILE);
-    ATTRIBUTE("Down Image Rect", IntRect, downRect_, IntRect::ZERO, AM_FILE);
-}
-
-void ScrollBar::ApplyAttributes()
-{
-    UIElement::ApplyAttributes();
-
-    // Reapply orientation to the button images
-    if (slider_->GetOrientation() == O_HORIZONTAL)
-    {
-        backButton_->SetImageRect(leftRect_);
-        forwardButton_->SetImageRect(rightRect_);
-    }
-    else
-    {
-        backButton_->SetImageRect(upRect_);
-        forwardButton_->SetImageRect(downRect_);
-    }
-}
-
-void ScrollBar::OnResize()
-{
-    if (slider_->GetOrientation() == O_HORIZONTAL)
-    {
-        int height = GetHeight();
-        int sliderWidth = Max(GetWidth() - 2 * height, 0);
-
-        backButton_->SetSize(height, height);
-        slider_->SetSize(sliderWidth, height);
-        forwardButton_->SetSize(height, height);
-
-        backButton_->SetPosition(0, 0);
-        slider_->SetPosition(height, 0);
-        forwardButton_->SetPosition(height + sliderWidth, 0);
-    }
-    else
-    {
-        int width = GetWidth();
-        int sliderHeight = Max(GetHeight() - 2 * width, 0);
-
-        backButton_->SetSize(width, width);
-        slider_->SetSize(width, sliderHeight);
-        forwardButton_->SetSize(width, width);
-
-        backButton_->SetPosition(0, 0);
-        slider_->SetPosition(0, width);
-        forwardButton_->SetPosition(0, sliderHeight + width);
-    }
-}
-
-void ScrollBar::OnSetEditable()
-{
-    slider_->SetEditable(editable_);
-}
-
-void ScrollBar::SetOrientation(Orientation orientation)
-{
-    slider_->SetOrientation(orientation);
-
-    if (orientation == O_HORIZONTAL)
-    {
-        backButton_->SetImageRect(leftRect_);
-        forwardButton_->SetImageRect(rightRect_);
-    }
-    else
-    {
-        backButton_->SetImageRect(upRect_);
-        forwardButton_->SetImageRect(downRect_);
-    }
-
-    OnResize();
-}
-
-void ScrollBar::SetRange(float range)
-{
-    slider_->SetRange(range);
-}
-
-void ScrollBar::SetValue(float value)
-{
-    slider_->SetValue(value);
-}
-
-void ScrollBar::ChangeValue(float delta)
-{
-    slider_->ChangeValue(delta);
-}
-
-void ScrollBar::SetScrollStep(float step)
-{
-    scrollStep_ = Max(step, 0.0f);
-}
-
-void ScrollBar::SetStepFactor(float factor)
-{
-    stepFactor_ = Max(factor, M_EPSILON);
-}
-
-void ScrollBar::StepBack()
-{
-    slider_->SetValue(slider_->GetValue() - GetEffectiveScrollStep());
-}
-
-void ScrollBar::StepForward()
-{
-    slider_->SetValue(slider_->GetValue() + GetEffectiveScrollStep());
-}
-
-Orientation ScrollBar::GetOrientation() const
-{
-    return slider_->GetOrientation();
-}
-
-float ScrollBar::GetRange() const
-{
-    return slider_->GetRange();
-}
-
-float ScrollBar::GetValue() const
-{
-    return slider_->GetValue();
-}
-
-float ScrollBar::GetEffectiveScrollStep() const
-{
-    return scrollStep_ * stepFactor_;
-}
-
-bool ScrollBar::FilterImplicitAttributes(XMLElement& dest) const
-{
-    if (!UIElement::FilterImplicitAttributes(dest))
-        return false;
-
-    if (!RemoveChildXML(dest, "Layout Mode"))
-        return false;
-
-    XMLElement childElem = dest.GetChild("element");
-    if (!FilterButtonImplicitAttributes(childElem, "SB_Back"))
-        return false;
-
-    childElem = childElem.GetNext("element");
-    if (!childElem)
-        return false;
-    if (!RemoveChildXML(childElem, "Name", "SB_Slider"))
-        return false;
-    if (!RemoveChildXML(childElem, "Repeat Rate", String(DEFAULT_REPEAT_RATE)))
-        return false;
-    if (!RemoveChildXML(childElem, "Orientation"))
-        return false;
-    if (!RemoveChildXML(childElem, "Range"))
-        return false;
-    if (!RemoveChildXML(childElem, "Value"))
-        return false;
-
-    childElem = childElem.GetNext("element");
-    if (!FilterButtonImplicitAttributes(childElem, "SB_Forward"))
-        return false;
-
-    return true;
-}
-
-bool ScrollBar::FilterButtonImplicitAttributes(XMLElement& dest, const String& name) const
-{
-    if (!dest)
-        return false;
-    if (!RemoveChildXML(dest, "Name", name))
-        return false;
-    if (!RemoveChildXML(dest, "Repeat Delay", String(DEFAULT_REPEAT_DELAY)))
-        return false;
-    if (!RemoveChildXML(dest, "Repeat Rate", String(DEFAULT_REPEAT_RATE)))
-        return false;
-    if (!RemoveChildXML(dest, "Image Rect"))
-        return false;
-    if (!RemoveChildXML(dest, "Min Size"))
-        return false;
-    if (!RemoveChildXML(dest, "Max Size"))
-        return false;
-    if (!RemoveChildXML(dest, "Focus Mode", "NotFocusable"))
-        return false;
-
-    return true;
-}
-
-void ScrollBar::HandleBackButtonPressed(StringHash eventType, VariantMap& eventData)
-{
-    if (editable_)
-        StepBack();
-}
-
-void ScrollBar::HandleForwardButtonPressed(StringHash eventType, VariantMap& eventData)
-{
-    if (editable_)
-        StepForward();
-}
-
-void ScrollBar::HandleSliderChanged(StringHash eventType, VariantMap& eventData)
-{
-    // Send the event forward
-    VariantMap& newEventData = GetEventDataMap();
-    newEventData[ScrollBarChanged::P_ELEMENT] = this;
-    newEventData[ScrollBarChanged::P_VALUE] = slider_->GetValue();
-    SendEvent(E_SCROLLBARCHANGED, newEventData);
-}
-
-void ScrollBar::HandleSliderPaged(StringHash eventType, VariantMap& eventData)
-{
-    using namespace SliderPaged;
-
-    // Synthesize hover event to the forward/back buttons
-    if (eventData[P_OFFSET].GetInt() < 0)
-        backButton_->OnHover(IntVector2::ZERO, backButton_->ElementToScreen(IntVector2::ZERO), 0, 0, 0);
-    else
-        forwardButton_->OnHover(IntVector2::ZERO, forwardButton_->ElementToScreen(IntVector2::ZERO), 0, 0, 0);
-
-    // Synthesize click / release events to the buttons
-    if (eventData[P_PRESSED].GetBool())
-    {
-        if (eventData[P_OFFSET].GetInt() < 0)
-            backButton_->OnClickBegin(IntVector2::ZERO, backButton_->ElementToScreen(IntVector2::ZERO), MOUSEB_LEFT, MOUSEB_LEFT, 0, 0);
-        else
-            forwardButton_->OnClickBegin(IntVector2::ZERO, forwardButton_->ElementToScreen(IntVector2::ZERO), MOUSEB_LEFT, MOUSEB_LEFT, 0, 0);
-    }
-    else
-    {
-        if (eventData[P_OFFSET].GetInt() < 0)
-            backButton_->OnClickEnd(IntVector2::ZERO, backButton_->ElementToScreen(IntVector2::ZERO), MOUSEB_LEFT, 0, 0, 0, backButton_);
-        else
-            forwardButton_->OnClickEnd(IntVector2::ZERO, forwardButton_->ElementToScreen(IntVector2::ZERO), MOUSEB_LEFT, 0, 0, 0, forwardButton_);
-    }
-}
-
-}

+ 0 - 125
Source/Atomic/UI/ScrollBar.h

@@ -1,125 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/UIElement.h"
-
-namespace Atomic
-{
-
-class Button;
-class Slider;
-
-/// Scroll bar %UI element with forward and back buttons.
-class ATOMIC_API ScrollBar : public UIElement
-{
-    OBJECT(ScrollBar);
-    
-public:
-    /// Construct.
-    ScrollBar(Context* context);
-    /// Destruct.
-    virtual ~ScrollBar();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-    
-    /// Apply attribute changes that can not be applied immediately.
-    virtual void ApplyAttributes();
-    /// React to resize.
-    virtual void OnResize();
-    /// React to editable status change.
-    virtual void OnSetEditable();
-    
-    /// Set orientation type.
-    void SetOrientation(Orientation orientation);
-    /// Set slider range maximum value (minimum value is always 0.)
-    void SetRange(float range);
-    /// Set slider current value.
-    void SetValue(float value);
-    /// Change slider current value by a delta.
-    void ChangeValue(float delta);
-    /// Set button scroll step.
-    void SetScrollStep(float step);
-    /// Set button step factor, can be used to adjust the step for constant pixel size.
-    void SetStepFactor(float factor);
-    /// Scroll back one step.
-    void StepBack();
-    /// Scroll forward one step.
-    void StepForward();
-    
-    /// Return scrollbar orientation.
-    Orientation GetOrientation() const;
-    /// Return slider range.
-    float GetRange() const;
-    /// Return slider current value.
-    float GetValue() const;
-    /// Return button scroll step.
-    float GetScrollStep() const { return scrollStep_; }
-    /// Return button step factor.
-    float GetStepFactor() const { return stepFactor_; }
-    /// Return scroll step multiplied by factor.
-    float GetEffectiveScrollStep() const;
-    /// Return back button element.
-    Button* GetBackButton() const { return backButton_; }
-    /// Return forward button element.
-    Button* GetForwardButton() const { return forwardButton_; }
-    /// Return slider element.
-    Slider* GetSlider() const { return slider_; }
-    
-protected:
-    /// Filter implicit attributes in serialization process.
-    virtual bool FilterImplicitAttributes(XMLElement& dest) const;
-    /// Filter implicit attributes in serialization process for internal button.
-    bool FilterButtonImplicitAttributes(XMLElement& dest, const String& name) const;
-
-    /// Back button.
-    SharedPtr<Button> backButton_;
-    /// Forward button.
-    SharedPtr<Button> forwardButton_;
-    /// Slider.
-    SharedPtr<Slider> slider_;
-    /// Scroll step.
-    float scrollStep_;
-    /// Step factor.
-    float stepFactor_;
-    /// Left button image rect.
-    IntRect leftRect_;
-    /// Right button image rect.
-    IntRect rightRect_;
-    /// Up button image rect.
-    IntRect upRect_;
-    /// Down button image rect.
-    IntRect downRect_;
-    
-private:
-    /// Handle back button pressed.
-    void HandleBackButtonPressed(StringHash eventType, VariantMap& eventData);
-    /// Handle forward button pressed.
-    void HandleForwardButtonPressed(StringHash eventType, VariantMap& eventData);
-    /// Handle slider movement.
-    void HandleSliderChanged(StringHash eventType, VariantMap& eventData);
-    /// Handle slider touch and click on "paging" area.
-    void HandleSliderPaged(StringHash eventType, VariantMap& eventData);
-};
-
-}

+ 0 - 702
Source/Atomic/UI/ScrollView.cpp

@@ -1,702 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../UI/BorderImage.h"
-#include "../Input/InputEvents.h"
-#include "../UI/ScrollBar.h"
-#include "../UI/ScrollView.h"
-#include "../UI/Slider.h"
-#include "../UI/UI.h"
-#include "../UI/UIEvents.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-static const float STEP_FACTOR = 300.0f;
-
-extern const char* UI_CATEGORY;
-
-ScrollView::ScrollView(Context* context) :
-    UIElement(context),
-    viewPosition_(IntVector2::ZERO),
-    viewSize_(IntVector2::ZERO),
-    viewPositionAttr_(IntVector2::ZERO),
-    touchScrollSpeed_(Vector2::ZERO),
-    touchScrollSpeedMax_(Vector2::ZERO),
-    pageStep_(1.0f),
-    scrollBarsAutoVisible_(true),
-    ignoreEvents_(false),
-    resizeContentWidth_(false),
-    scrollDeceleration_(30.0f),
-    scrollSnapEpsilon_(M_EPSILON),
-    scrollTouchDown_(false),
-    barScrolling_(false),
-    scrollChildrenDisable_(false),
-    autoDisableChildren_(false),
-    autoDisableThreshold_(25.0f),
-    touchDistanceSum_(0.0f)
-{
-    clipChildren_ = true;
-    SetEnabled(true);
-    focusMode_ = FM_FOCUSABLE_DEFOCUSABLE;
-
-    horizontalScrollBar_ = CreateChild<ScrollBar>("SV_HorizontalScrollBar");
-    horizontalScrollBar_->SetInternal(true);
-    horizontalScrollBar_->SetAlignment(HA_LEFT, VA_BOTTOM);
-    horizontalScrollBar_->SetOrientation(O_HORIZONTAL);
-    verticalScrollBar_ = CreateChild<ScrollBar>("SV_VerticalScrollBar");
-    verticalScrollBar_->SetInternal(true);
-    verticalScrollBar_->SetAlignment(HA_RIGHT, VA_TOP);
-    verticalScrollBar_->SetOrientation(O_VERTICAL);
-    scrollPanel_ = CreateChild<BorderImage>("SV_ScrollPanel");
-    scrollPanel_->SetInternal(true);
-    scrollPanel_->SetEnabled(true);
-    scrollPanel_->SetClipChildren(true);
-
-    SubscribeToEvent(horizontalScrollBar_, E_SCROLLBARCHANGED, HANDLER(ScrollView, HandleScrollBarChanged));
-    SubscribeToEvent(horizontalScrollBar_, E_VISIBLECHANGED, HANDLER(ScrollView, HandleScrollBarVisibleChanged));
-    SubscribeToEvent(verticalScrollBar_, E_SCROLLBARCHANGED, HANDLER(ScrollView, HandleScrollBarChanged));
-    SubscribeToEvent(verticalScrollBar_, E_VISIBLECHANGED, HANDLER(ScrollView, HandleScrollBarVisibleChanged));
-    SubscribeToEvent(E_TOUCHMOVE, HANDLER(ScrollView, HandleTouchMove));
-    SubscribeToEvent(E_TOUCHBEGIN, HANDLER(ScrollView, HandleTouchMove));
-    SubscribeToEvent(E_TOUCHEND, HANDLER(ScrollView, HandleTouchMove));
-
-}
-
-ScrollView::~ScrollView()
-{
-}
-
-void ScrollView::RegisterObject(Context* context)
-{
-    context->RegisterFactory<ScrollView>(UI_CATEGORY);
-
-    COPY_BASE_ATTRIBUTES(UIElement);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Clip Children", true);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Is Enabled", true);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Focus Mode", FM_FOCUSABLE_DEFOCUSABLE);
-    ACCESSOR_ATTRIBUTE("View Position", GetViewPosition, SetViewPositionAttr, IntVector2, IntVector2::ZERO, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Scroll Step", GetScrollStep, SetScrollStep, float, 0.1f, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Page Step", GetPageStep, SetPageStep, float, 1.0f, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Auto Show/Hide Scrollbars", GetScrollBarsAutoVisible, SetScrollBarsAutoVisible, bool, true, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Scroll Deceleration", GetScrollDeceleration, SetScrollDeceleration, float, 30.0f, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Scroll Snap Epsilon", GetScrollSnapEpsilon, SetScrollSnapEpsilon, float, 1.0f, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Auto Disable Children", GetAutoDisableChildren, SetAutoDisableChildren, bool, false, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Auto Disable Threshold", GetAutoDisableThreshold, SetAutoDisableThreshold, float, 25.0f, AM_FILE);
-}
-
-void ScrollView::Update(float timeStep)
-{
-    // Update touch scrolling here if necessary
-    if (touchScrollSpeed_ == Vector2::ZERO && touchScrollSpeedMax_ == Vector2::ZERO && !barScrolling_)
-        return;
-
-    // Check if we should not scroll:
-    // - ScrollView is not visible, is not enabled, or doesn't have focus
-    // - The element being dragged is not a child of the ScrollView, or is one of our scrollbars
-    if (!IsVisible() || !IsEnabled() || !HasFocus())
-    {
-        touchScrollSpeed_ = Vector2::ZERO;
-        touchScrollSpeedMax_ = Vector2::ZERO;
-        return;
-    }
-
-    if (GetSubsystem<UI>()->IsDragging())
-    {
-        Vector<UIElement*> dragElements = GetSubsystem<UI>()->GetDragElements();
-
-        for (unsigned i = 0; i< dragElements.Size(); i++)
-        {
-            UIElement* dragElement = dragElements[i];
-            int dragButtons = dragElement->GetDragButtonCombo();
-
-            if (dragButtons != MOUSEB_LEFT)
-                continue;
-
-            UIElement* dragParent = dragElement->GetParent();
-            bool dragElementIsChild = false;
-
-            while (dragParent)
-            {
-                if (dragParent == this)
-                {
-                    dragElementIsChild = true;
-                    break;
-                }
-                dragParent = dragParent->GetParent();
-            }
-
-            if (!dragElementIsChild || dragElement == horizontalScrollBar_->GetSlider() || dragElement == verticalScrollBar_->GetSlider())
-            {
-                touchScrollSpeed_ = Vector2::ZERO;
-                touchScrollSpeedMax_ = Vector2::ZERO;
-                return;
-            }
-        }
-    }
-
-    // Update view position
-    IntVector2 newPosition = viewPosition_;
-    newPosition.x_ += (int)touchScrollSpeed_.x_;
-    newPosition.y_ += (int)touchScrollSpeed_.y_;
-    SetViewPosition(newPosition);
-
-    // Smooth deceleration
-    ScrollSmooth(timeStep);
-}
-
-void ScrollView::ApplyAttributes()
-{
-    UIElement::ApplyAttributes();
-
-    // Set the scrollbar orientations again and perform size update now that the style is known
-    horizontalScrollBar_->SetOrientation(O_HORIZONTAL);
-    verticalScrollBar_->SetOrientation(O_VERTICAL);
-
-    // If the scroll panel has a child, it should be the content element, which has some special handling
-    if (scrollPanel_->GetNumChildren())
-        SetContentElement(scrollPanel_->GetChild(0));
-
-    OnResize();
-
-    // Reapply view position with proper content element and size
-    SetViewPosition(viewPositionAttr_);
-}
-
-void ScrollView::OnWheel(int delta, int buttons, int qualifiers)
-{
-    if (delta > 0)
-        verticalScrollBar_->StepBack();
-    if (delta < 0)
-        verticalScrollBar_->StepForward();
-}
-
-void ScrollView::OnKey(int key, int buttons, int qualifiers)
-{
-    switch (key)
-    {
-    case KEY_LEFT:
-        if (horizontalScrollBar_->IsVisible())
-        {
-            if (qualifiers & QUAL_CTRL)
-                horizontalScrollBar_->SetValue(0.0f);
-            else
-                horizontalScrollBar_->StepBack();
-        }
-        break;
-
-    case KEY_RIGHT:
-        if (horizontalScrollBar_->IsVisible())
-        {
-            if (qualifiers & QUAL_CTRL)
-                horizontalScrollBar_->SetValue(horizontalScrollBar_->GetRange());
-            else
-                horizontalScrollBar_->StepForward();
-        }
-        break;
-
-    case KEY_HOME:
-        qualifiers |= QUAL_CTRL;
-        // Fallthru
-
-    case KEY_UP:
-        if (verticalScrollBar_->IsVisible())
-        {
-            if (qualifiers & QUAL_CTRL)
-                verticalScrollBar_->SetValue(0.0f);
-            else
-                verticalScrollBar_->StepBack();
-        }
-        break;
-
-    case KEY_END:
-        qualifiers |= QUAL_CTRL;
-        // Fallthru
-
-    case KEY_DOWN:
-        if (verticalScrollBar_->IsVisible())
-        {
-            if (qualifiers & QUAL_CTRL)
-                verticalScrollBar_->SetValue(verticalScrollBar_->GetRange());
-            else
-                verticalScrollBar_->StepForward();
-        }
-        break;
-
-    case KEY_PAGEUP:
-        if (verticalScrollBar_->IsVisible())
-            verticalScrollBar_->ChangeValue(-pageStep_);
-        break;
-
-    case KEY_PAGEDOWN:
-        if (verticalScrollBar_->IsVisible())
-            verticalScrollBar_->ChangeValue(pageStep_);
-        break;
-    }
-}
-
-void ScrollView::OnResize()
-{
-    UpdatePanelSize();
-    UpdateViewSize();
-
-    // If scrollbar autovisibility is enabled, check whether scrollbars should be visible.
-    // This may force another update of the panel size
-    if (scrollBarsAutoVisible_)
-    {
-        ignoreEvents_ = true;
-        horizontalScrollBar_->SetVisible(horizontalScrollBar_->GetRange() > M_EPSILON);
-        verticalScrollBar_->SetVisible(verticalScrollBar_->GetRange() > M_EPSILON);
-        ignoreEvents_ = false;
-
-        UpdatePanelSize();
-    }
-}
-
-void ScrollView::SetContentElement(UIElement* element)
-{
-    if (element == contentElement_)
-        return;
-
-    if (contentElement_)
-    {
-        scrollPanel_->RemoveChild(contentElement_);
-        UnsubscribeFromEvent(contentElement_, E_RESIZED);
-    }
-    contentElement_ = element;
-    if (contentElement_)
-    {
-        scrollPanel_->AddChild(contentElement_);
-        SubscribeToEvent(contentElement_, E_RESIZED, HANDLER(ScrollView, HandleElementResized));
-    }
-
-    OnResize();
-}
-
-void ScrollView::SetViewPosition(const IntVector2& position)
-{
-    UpdateView(position);
-    UpdateScrollBars();
-}
-
-void ScrollView::SetViewPosition(int x, int y)
-{
-    SetViewPosition(IntVector2(x, y));
-}
-
-void ScrollView::SetScrollBarsVisible(bool horizontal, bool vertical)
-{
-    scrollBarsAutoVisible_ = false;
-    horizontalScrollBar_->SetVisible(horizontal);
-    verticalScrollBar_->SetVisible(vertical);
-}
-
-void ScrollView::SetScrollBarsAutoVisible(bool enable)
-{
-    if (enable != scrollBarsAutoVisible_)
-    {
-        scrollBarsAutoVisible_ = enable;
-        // Check whether scrollbars should be visible now
-        if (enable)
-            OnResize();
-        else
-        {
-            horizontalScrollBar_->SetVisible(true);
-            verticalScrollBar_->SetVisible(true);
-        }
-    }
-}
-
-void ScrollView::SetScrollStep(float step)
-{
-    horizontalScrollBar_->SetScrollStep(step);
-    verticalScrollBar_->SetScrollStep(step);
-}
-
-void ScrollView::SetPageStep(float step)
-{
-    pageStep_ = Max(step, 0.0f);
-}
-
-float ScrollView::GetScrollStep() const
-{
-    return horizontalScrollBar_->GetScrollStep();
-}
-
-void ScrollView::SetViewPositionAttr(const IntVector2& value)
-{
-    viewPositionAttr_ = value;
-    SetViewPosition(value);
-}
-
-bool ScrollView::FilterImplicitAttributes(XMLElement& dest) const
-{
-    if (!UIElement::FilterImplicitAttributes(dest))
-        return false;
-
-    XMLElement childElem = dest.GetChild("element");
-    if (!FilterScrollBarImplicitAttributes(childElem, "SV_HorizontalScrollBar"))
-        return false;
-    if (!RemoveChildXML(childElem, "Vert Alignment", "Bottom"))
-        return false;
-
-    childElem = childElem.GetNext("element");
-    if (!FilterScrollBarImplicitAttributes(childElem, "SV_VerticalScrollBar"))
-        return false;
-    if (!RemoveChildXML(childElem, "Horiz Alignment", "Right"))
-        return false;
-
-    childElem = childElem.GetNext("element");
-    if (!childElem)
-        return false;
-    if (!RemoveChildXML(childElem, "Name", "SV_ScrollPanel"))
-        return false;
-    if (!RemoveChildXML(childElem, "Is Enabled", "true"))
-        return false;
-    if (!RemoveChildXML(childElem, "Clip Children", "true"))
-        return false;
-    if (!RemoveChildXML(childElem, "Size"))
-        return false;
-
-    return true;
-}
-
-bool ScrollView::FilterScrollBarImplicitAttributes(XMLElement& dest, const String& name) const
-{
-    if (!dest)
-        return false;
-    if (!RemoveChildXML(dest, "Name", name))
-        return false;
-    if (!RemoveChildXML(dest, "Orientation"))
-        return false;
-    if (!RemoveChildXML(dest, "Range"))
-        return false;
-    if (!RemoveChildXML(dest, "Step Factor"))
-        return false;
-    if (scrollBarsAutoVisible_)
-    {
-        if (!RemoveChildXML(dest, "Is Visible"))
-            return false;
-    }
-
-    return true;
-}
-
-void ScrollView::UpdatePanelSize()
-{
-    // Ignore events in case content element resizes itself along with the panel
-    // (content element resize triggers our OnResize(), so it could lead to infinite recursion)
-    ignoreEvents_ = true;
-
-    IntVector2 panelSize = GetSize();
-    if (verticalScrollBar_->IsVisible())
-        panelSize.x_ -= verticalScrollBar_->GetWidth();
-    if (horizontalScrollBar_->IsVisible())
-        panelSize.y_ -= horizontalScrollBar_->GetHeight();
-
-    scrollPanel_->SetSize(panelSize);
-    horizontalScrollBar_->SetWidth(scrollPanel_->GetWidth());
-    verticalScrollBar_->SetHeight(scrollPanel_->GetHeight());
-
-    if (resizeContentWidth_ && contentElement_)
-    {
-        IntRect panelBorder = scrollPanel_->GetClipBorder();
-        contentElement_->SetWidth(scrollPanel_->GetWidth() - panelBorder.left_ - panelBorder.right_);
-        UpdateViewSize();
-    }
-
-    ignoreEvents_ = false;
-}
-
-void ScrollView::UpdateViewSize()
-{
-    IntVector2 size(IntVector2::ZERO);
-    if (contentElement_)
-        size = contentElement_->GetSize();
-    IntRect panelBorder = scrollPanel_->GetClipBorder();
-
-    viewSize_.x_ = Max(size.x_, scrollPanel_->GetWidth() - panelBorder.left_ - panelBorder.right_);
-    viewSize_.y_ = Max(size.y_, scrollPanel_->GetHeight() - panelBorder.top_ - panelBorder.bottom_);
-
-    UpdateView(viewPosition_);
-    UpdateScrollBars();
-}
-
-void ScrollView::UpdateScrollBars()
-{
-    ignoreEvents_ = true;
-
-    IntVector2 size = scrollPanel_->GetSize();
-    IntRect panelBorder = scrollPanel_->GetClipBorder();
-    size.x_ -= panelBorder.left_ + panelBorder.right_;
-    size.y_ -= panelBorder.top_ + panelBorder.bottom_;
-
-    if (size.x_ > 0 && viewSize_.x_ > 0)
-    {
-        float range = (float)viewSize_.x_ / (float)size.x_ - 1.0f;
-        horizontalScrollBar_->SetRange(range);
-        horizontalScrollBar_->SetValue((float)viewPosition_.x_ / (float)size.x_);
-        horizontalScrollBar_->SetStepFactor(STEP_FACTOR / (float)size.x_);
-    }
-    if (size.y_ > 0 && viewSize_.y_ > 0)
-    {
-        float range = (float)viewSize_.y_ / (float)size.y_ - 1.0f;
-        verticalScrollBar_->SetRange(range);
-        verticalScrollBar_->SetValue((float)viewPosition_.y_ / (float)size.y_);
-        verticalScrollBar_->SetStepFactor(STEP_FACTOR / (float)size.y_);
-    }
-
-    ignoreEvents_ = false;
-}
-
-void ScrollView::UpdateView(const IntVector2& position)
-{
-    IntVector2 oldPosition = viewPosition_;
-    IntRect panelBorder = scrollPanel_->GetClipBorder();
-    IntVector2 panelSize(scrollPanel_->GetWidth() - panelBorder.left_ - panelBorder.right_, scrollPanel_->GetHeight() -
-        panelBorder.top_ - panelBorder.bottom_);
-
-    viewPosition_.x_ = Clamp(position.x_, 0, viewSize_.x_ - panelSize.x_);
-    viewPosition_.y_ = Clamp(position.y_, 0, viewSize_.y_ - panelSize.y_);
-    scrollPanel_->SetChildOffset(IntVector2(-viewPosition_.x_ + panelBorder.left_, -viewPosition_.y_ + panelBorder.top_));
-
-    if (viewPosition_ != oldPosition)
-    {
-        using namespace ViewChanged;
-
-        VariantMap& eventData = GetEventDataMap();
-        eventData[P_ELEMENT] = this;
-        eventData[P_X] = viewPosition_.x_;
-        eventData[P_Y] = viewPosition_.y_;
-        SendEvent(E_VIEWCHANGED, eventData);
-    }
-}
-
-void ScrollView::HandleScrollBarChanged(StringHash eventType, VariantMap& eventData)
-{
-    if (!ignoreEvents_)
-    {
-        IntVector2 size = scrollPanel_->GetSize();
-        IntRect panelBorder = scrollPanel_->GetClipBorder();
-        size.x_ -= panelBorder.left_ + panelBorder.right_;
-        size.y_ -= panelBorder.top_ + panelBorder.bottom_;
-
-        UpdateView(IntVector2(
-            (int)(horizontalScrollBar_->GetValue() * (float)size.x_),
-            (int)(verticalScrollBar_->GetValue() * (float)size.y_)
-        ));
-    }
-}
-
-void ScrollView::HandleScrollBarVisibleChanged(StringHash eventType, VariantMap& eventData)
-{
-    // Need to recalculate panel size when scrollbar visibility changes
-    if (!ignoreEvents_)
-        OnResize();
-}
-
-void ScrollView::HandleElementResized(StringHash eventType, VariantMap& eventData)
-{
-    if (!ignoreEvents_)
-        OnResize();
-}
-
-void ScrollView::HandleTouchMove(StringHash eventType, VariantMap& eventData)
-{
-    using namespace TouchMove;
-
-    if (eventType == E_TOUCHMOVE && !barScrolling_)
-    {
-        scrollTouchDown_ = true;
-        // Take new scrolling speed if it's faster than the current accumulated value
-        float dX = (float)-eventData[P_DX].GetInt();
-        float dY = (float)-eventData[P_DY].GetInt();
-
-        if (Abs(dX) > Abs(touchScrollSpeed_.x_))
-            touchScrollSpeed_.x_ = dX;
-        if (Abs(dY) > Abs(touchScrollSpeed_.y_))
-            touchScrollSpeed_.y_ = dY;
-
-        // Auto disable children
-        touchDistanceSum_ += dX * dX + dY * dY;
-        if (autoDisableChildren_ && touchDistanceSum_ >= autoDisableThreshold_)
-        {
-            if (visible_ && !scrollChildrenDisable_)
-            {
-                scrollChildrenDisable_ = true;
-                scrollPanel_->SetDeepEnabled(false);
-            }
-        }
-
-        touchScrollSpeedMax_.x_ = dX;
-        touchScrollSpeedMax_.y_ = dY;
-    }
-    else if (eventType == E_TOUCHBEGIN)
-    {
-        int X = eventData[P_X].GetInt();
-        int Y = eventData[P_Y].GetInt();
-        IntVector2 pos = IntVector2(X, Y);
-
-        // Prevent conflict between touch scroll and scrollbar scroll
-        if (horizontalScrollBar_->IsVisible() && horizontalScrollBar_->IsInsideCombined(pos, true))
-            barScrolling_ = true;
-
-        if (verticalScrollBar_->IsVisible() && verticalScrollBar_->IsInsideCombined(pos, true))
-            barScrolling_ = true;
-
-        // Stop the smooth scrolling
-        touchScrollSpeed_ = Vector2::ZERO;
-        touchScrollSpeedMax_ = Vector2::ZERO;
-    }
-    else if (eventType == E_TOUCHEND)
-    {
-        // 'Flick' action
-        // Release any auto disabled children
-        if (scrollChildrenDisable_)
-        {
-            touchDistanceSum_ = 0.0f;
-            scrollChildrenDisable_ = false;
-            scrollPanel_->ResetDeepEnabled();
-        }
-
-        barScrolling_ = false;
-        scrollTouchDown_ = false;
-        if (Abs(touchScrollSpeedMax_.x_) > scrollSnapEpsilon_ )
-            touchScrollSpeed_.x_ = touchScrollSpeedMax_.x_;
-        else
-            touchScrollSpeed_.x_ = 0;
-
-        if (Abs(touchScrollSpeedMax_.y_) > scrollSnapEpsilon_ )
-            touchScrollSpeed_.y_ = touchScrollSpeedMax_.y_;
-        else
-            touchScrollSpeed_.y_ = 0;
-        touchScrollSpeedMax_ = Vector2::ZERO;
-    }
-}
-
-void ScrollView::ScrollSmooth(float timeStep)
-{
-    // Decay the momentum
-    if (touchScrollSpeedMax_.x_ >= scrollSnapEpsilon_)
-    {
-        touchScrollSpeedMax_.x_ -= scrollDeceleration_ * timeStep;
-        touchScrollSpeedMax_.x_ = touchScrollSpeedMax_.x_ > 0 ? touchScrollSpeedMax_.x_ : 0;
-    }
-    else if (touchScrollSpeedMax_.x_ <= -scrollSnapEpsilon_)
-    {
-        touchScrollSpeedMax_.x_ += scrollDeceleration_ * timeStep;
-        touchScrollSpeedMax_.x_ = touchScrollSpeedMax_.x_ < 0 ? touchScrollSpeedMax_.x_ : 0;
-    }
-    else
-        touchScrollSpeedMax_.x_ = 0;
-
-    if (touchScrollSpeedMax_.y_ >= scrollSnapEpsilon_)
-    {
-        touchScrollSpeedMax_.y_ -= scrollDeceleration_ * timeStep;
-        touchScrollSpeedMax_.y_ = touchScrollSpeedMax_.y_ > 0 ? touchScrollSpeedMax_.y_ : 0;
-    }
-    else if (touchScrollSpeedMax_.y_ <= -scrollSnapEpsilon_)
-    {
-        touchScrollSpeedMax_.y_ += scrollDeceleration_ * timeStep;
-        touchScrollSpeedMax_.y_ = touchScrollSpeedMax_.y_ < 0 ? touchScrollSpeedMax_.y_ : 0;
-    }
-    else
-        touchScrollSpeedMax_.y_ = 0;
-
-    // Control vs flick
-    if (scrollTouchDown_)
-    {
-        // Finger is held down: control = instant stop
-        touchScrollSpeed_ = Vector2::ZERO;
-    }
-    else
-    {
-        // Finger is released: flick = smooth deceleration
-        if (touchScrollSpeed_.x_ >= scrollSnapEpsilon_)
-        {
-            touchScrollSpeed_.x_ -= scrollDeceleration_ * timeStep;
-            if (touchScrollSpeed_.x_ < 0)
-            {
-                touchScrollSpeed_.x_ = 0;
-            }
-
-            if (horizontalScrollBar_->GetValue() >= horizontalScrollBar_->GetRange() - M_EPSILON)
-            {
-                // Stop movement when we reach end of scroll
-                touchScrollSpeed_.x_ = 0;
-            }
-        }
-        else if (touchScrollSpeed_.x_ < -scrollSnapEpsilon_)
-        {
-            touchScrollSpeed_.x_ += scrollDeceleration_ * timeStep;
-            if (touchScrollSpeed_.x_ > 0)
-            {
-                touchScrollSpeed_.x_ = 0;
-            }
-
-            if (horizontalScrollBar_->GetValue() <= M_EPSILON)
-            {
-                // Stop movement when we reach end of scroll
-                touchScrollSpeed_.x_ = 0;
-            }
-        }
-        else
-            touchScrollSpeed_.x_ = 0;
-
-        if (touchScrollSpeed_.y_ >= scrollSnapEpsilon_)
-        {
-            touchScrollSpeed_.y_ -= scrollDeceleration_ * timeStep;
-            if (touchScrollSpeed_.y_ < 0)
-            {
-                touchScrollSpeed_.y_ = 0;
-            }
-
-            if (verticalScrollBar_->GetValue() >= verticalScrollBar_->GetRange() - M_EPSILON)
-            {
-                // Stop movement when we reach end of scroll
-                touchScrollSpeed_.y_ = 0;
-            }
-        }
-        else if (touchScrollSpeed_.y_ < -scrollSnapEpsilon_)
-        {
-            touchScrollSpeed_.y_ += scrollDeceleration_ * timeStep;
-            if (touchScrollSpeed_.y_ > 0)
-            {
-                touchScrollSpeed_.y_ = 0;
-            }
-
-            if (verticalScrollBar_->GetValue() <= M_EPSILON)
-            {
-                // Stop movement when we reach end of scroll
-                touchScrollSpeed_.y_ = 0;
-            }
-        }
-        else
-            touchScrollSpeed_.y_ = 0;
-    }
-}
-
-}

+ 0 - 178
Source/Atomic/UI/ScrollView.h

@@ -1,178 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/UIElement.h"
-
-namespace Atomic
-{
-
-class BorderImage;
-class ScrollBar;
-
-/// Scrollable %UI element for showing a (possibly large) child element.
-class ATOMIC_API ScrollView : public UIElement
-{
-    OBJECT(ScrollView);
-
-public:
-    /// Construct.
-    ScrollView(Context* context);
-    /// Destruct.
-    virtual ~ScrollView();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// Perform UI element update.
-    virtual void Update(float timeStep);
-    /// Apply attribute changes that can not be applied immediately.
-    virtual void ApplyAttributes();
-    /// React to mouse wheel.
-    virtual void OnWheel(int delta, int buttons, int qualifiers);
-    /// React to a key press.
-    virtual void OnKey(int key, int buttons, int qualifiers);
-    /// React to resize.
-    virtual void OnResize();
-
-    /// Set content element.
-    void SetContentElement(UIElement* element);
-    /// Set view offset from the top-left corner.
-    void SetViewPosition(const IntVector2& position);
-    /// Set view offset from the top-left corner.
-    void SetViewPosition(int x, int y);
-    /// Set scrollbars' visibility manually. Disables scrollbar autoshow/hide.
-    void SetScrollBarsVisible(bool horizontal, bool vertical);
-    /// Set whether to automatically show/hide scrollbars. Default true.
-    void SetScrollBarsAutoVisible(bool enable);
-    /// Set arrow key scroll step. Also sets it on the scrollbars.
-    void SetScrollStep(float step);
-    /// Set arrow key page step.
-    void SetPageStep(float step);
-    /// Set scroll deceleration.
-    void SetScrollDeceleration(float deceleration) { scrollDeceleration_ = deceleration; }
-    /// Set scroll snap epsilon
-    void SetScrollSnapEpsilon(float snap) { scrollSnapEpsilon_ = snap; }
-    /// Set whether child elements should be disabled while touch scrolling.
-    void SetAutoDisableChildren(bool disable) { autoDisableChildren_ = disable; };
-    /// Set how much touch movement is needed to trigger child element disabling.
-    void SetAutoDisableThreshold(float amount) { autoDisableThreshold_ = amount; };
-
-    /// Return view offset from the top-left corner.
-    const IntVector2& GetViewPosition() const { return viewPosition_; }
-    /// Return content element.
-    UIElement* GetContentElement() const { return contentElement_; }
-    /// Return horizontal scroll bar.
-    ScrollBar* GetHorizontalScrollBar() const { return horizontalScrollBar_; }
-    /// Return vertical scroll bar.
-    ScrollBar* GetVerticalScrollBar() const { return verticalScrollBar_; }
-    /// Return scroll panel.
-    BorderImage* GetScrollPanel() const { return scrollPanel_; }
-    /// Return whether scrollbars are automatically shown/hidden.
-    bool GetScrollBarsAutoVisible() const { return scrollBarsAutoVisible_; }
-    /// Return arrow key scroll step.
-    float GetScrollStep() const;
-    /// Return arrow key page step.
-    float GetPageStep() const { return pageStep_; }
-    /// Return scroll deceleration.
-    float GetScrollDeceleration() const { return scrollDeceleration_; }
-    /// Return scroll snap epsilon
-    float GetScrollSnapEpsilon() const { return scrollSnapEpsilon_; }
-    /// Return whether child element will be disabled while touch scrolling.
-    bool GetAutoDisableChildren() const { return autoDisableChildren_; }
-    /// Return how much touch movement is needed to trigger child element disabling.
-    float GetAutoDisableThreshold() const { return autoDisableThreshold_; }
-
-    /// Set view position attribute.
-    void SetViewPositionAttr(const IntVector2& value);
-
-protected:
-    /// Filter implicit attributes in serialization process.
-    virtual bool FilterImplicitAttributes(XMLElement& dest) const;
-    /// Filter implicit attributes in serialization process for internal scroll bar.
-    bool FilterScrollBarImplicitAttributes(XMLElement& dest, const String& name) const;
-    /// Resize panel based on scrollbar visibility.
-    void UpdatePanelSize();
-    /// Recalculate view size, validate view position and update scrollbars.
-    void UpdateViewSize();
-    /// Update the scrollbars' ranges and positions.
-    void UpdateScrollBars();
-    /// Limit and update the view with a new position.
-    void UpdateView(const IntVector2& position);
-
-    /// Content element.
-    SharedPtr<UIElement> contentElement_;
-    /// Horizontal scroll bar.
-    SharedPtr<ScrollBar> horizontalScrollBar_;
-    /// Vertical scroll bar.
-    SharedPtr<ScrollBar> verticalScrollBar_;
-    /// Scroll panel element.
-    SharedPtr<BorderImage> scrollPanel_;
-    /// Current view offset from the top-left corner.
-    IntVector2 viewPosition_;
-    /// Total view size.
-    IntVector2 viewSize_;
-    /// View offset attribute.
-    IntVector2 viewPositionAttr_;
-    /// Accumulated touch scroll speed.
-    Vector2 touchScrollSpeed_;
-    /// Max touch scroll speed.
-    Vector2 touchScrollSpeedMax_;
-    /// Arrow key page step.
-    float pageStep_;
-    /// Automatically show/hide scrollbars flag.
-    bool scrollBarsAutoVisible_;
-    /// Ignore scrollbar events flag. Used to prevent possible endless loop when resizing.
-    bool ignoreEvents_;
-    /// Resize content widget width to match panel. Internal flag, used by the ListView class.
-    bool resizeContentWidth_;
-    /// Scroll deceleration
-    float scrollDeceleration_;
-    /// Scroll snap epsilon
-    float scrollSnapEpsilon_;
-    /// Used to trigger scroll smoothing when false;
-    bool scrollTouchDown_;
-    /// Used to prevent touch scroll - scroll bar conflict
-    bool barScrolling_;
-    /// Used to determine if child elements should be disabled while touch scrolling, to prevent their trigger.
-    bool autoDisableChildren_;
-    /// Used to determine if children have been disabled.
-    bool scrollChildrenDisable_;
-    /// Distance moved with touch scrolling
-    float touchDistanceSum_;
-    /// Threshold to trigger auto disable children
-    float autoDisableThreshold_;
-
-private:
-    /// Handle scrollbar value changed.
-    void HandleScrollBarChanged(StringHash eventType, VariantMap& eventData);
-    /// Handle scrollbar visibility changed.
-    void HandleScrollBarVisibleChanged(StringHash eventType, VariantMap& eventData);
-    /// Handle content element resized.
-    void HandleElementResized(StringHash eventType, VariantMap& eventData);
-    /// Handle touch move event for scrolling.
-    void HandleTouchMove(StringHash eventType, VariantMap& eventData);
-    /// Handle the scroll smoothing.
-    void ScrollSmooth(float timeStep);
-};
-
-}

+ 0 - 279
Source/Atomic/UI/Slider.cpp

@@ -1,279 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../Input/InputEvents.h"
-#include "../IO/Log.h"
-#include "../UI/Slider.h"
-#include "../UI/UIEvents.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-const char* orientations[] =
-{
-    "Horizontal",
-    "Vertical",
-    0
-};
-
-extern const char* UI_CATEGORY;
-
-Slider::Slider(Context* context) :
-    BorderImage(context),
-    orientation_(O_HORIZONTAL),
-    range_(1.0f),
-    value_(0.0f),
-    dragSlider_(false),
-    repeatRate_(0.0f)
-{
-    SetEnabled(true);
-    knob_ = CreateChild<BorderImage>("S_Knob");
-    knob_->SetInternal(true);
-
-    UpdateSlider();
-}
-
-Slider::~Slider()
-{
-}
-
-void Slider::RegisterObject(Context* context)
-{
-    context->RegisterFactory<Slider>(UI_CATEGORY);
-
-    COPY_BASE_ATTRIBUTES(BorderImage);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Is Enabled", true);
-    ENUM_ACCESSOR_ATTRIBUTE("Orientation", GetOrientation, SetOrientation, Orientation, orientations, O_HORIZONTAL, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Range", GetRange, SetRange, float, 1.0f, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Value", GetValue, SetValue, float, 0.0f, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Repeat Rate", GetRepeatRate, SetRepeatRate, float, 0.0f, AM_FILE);
-}
-
-void Slider::Update(float timeStep)
-{
-    if (dragSlider_)
-        hovering_ = true;
-
-    // Propagate hover effect to the slider knob
-    knob_->SetHovering(hovering_);
-    knob_->SetSelected(hovering_);
-}
-
-void Slider::OnHover(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
-{
-    BorderImage::OnHover(position, screenPosition, buttons, qualifiers, cursor);
-
-    // Show hover effect if inside the slider knob
-    hovering_ = knob_->IsInside(screenPosition, true);
-
-    // If not hovering on the knob, send it as page event
-    if (!hovering_)
-        Page(position, buttons & MOUSEB_LEFT);
-}
-
-void Slider::OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
-{
-    selected_ = true;
-    hovering_ = knob_->IsInside(screenPosition, true);
-    if (!hovering_ && button == MOUSEB_LEFT)
-        Page(position, true);
-}
-
-void Slider::OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement)
-{
-    hovering_ = knob_->IsInside(screenPosition, true);
-    if (!hovering_ && button == MOUSEB_LEFT)
-        Page(position, false);
-}
-
-void Slider::OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
-{
-    UIElement::OnDragBegin(position, screenPosition, buttons, qualifiers, cursor);
-
-    if (buttons == MOUSEB_LEFT)
-    {
-        dragBeginCursor_ = position;
-        dragBeginPosition_ = knob_->GetPosition();
-        dragSlider_ = knob_->IsInside(screenPosition, true);
-    }
-}
-
-void Slider::OnDragMove(const IntVector2& position, const IntVector2& screenPosition, const IntVector2& deltaPos, int buttons, int qualifiers, Cursor* cursor)
-{
-    if (!editable_ || !dragSlider_ || GetSize() == knob_->GetSize())
-        return;
-
-    float newValue = value_;
-    IntVector2 delta = position - dragBeginCursor_;
-
-    if (orientation_ == O_HORIZONTAL)
-    {
-        int newX = Clamp(dragBeginPosition_.x_ + delta.x_, 0, GetWidth() - knob_->GetWidth());
-        knob_->SetPosition(newX, 0);
-        newValue = (float)newX * range_ / (float)(GetWidth() - knob_->GetWidth());
-    }
-    else
-    {
-        int newY = Clamp(dragBeginPosition_.y_ + delta.y_, 0, GetHeight() - knob_->GetHeight());
-        knob_->SetPosition(0, newY);
-        newValue = (float)newY * range_ / (float)(GetHeight() - knob_->GetHeight());
-    }
-
-    SetValue(newValue);
-}
-
-void Slider::OnDragEnd(const IntVector2& position, const IntVector2& screenPosition, int dragButtons, int buttons, Cursor* cursor)
-{
-    UIElement::OnDragEnd(position, screenPosition, dragButtons, buttons, cursor);
-
-    if (dragButtons == MOUSEB_LEFT)
-    {
-        dragSlider_ = false;
-        selected_ = false;
-    }
-}
-
-void Slider::OnResize()
-{
-    UpdateSlider();
-}
-
-void Slider::SetOrientation(Orientation type)
-{
-    orientation_ = type;
-    UpdateSlider();
-}
-
-void Slider::SetRange(float range)
-{
-    range = Max(range, 0.0f);
-    if (range != range_)
-    {
-        range_ = range;
-        UpdateSlider();
-    }
-}
-
-void Slider::SetValue(float value)
-{
-    value = Clamp(value, 0.0f, range_);
-    if (value != value_)
-    {
-        value_ = value;
-        UpdateSlider();
-
-        using namespace SliderChanged;
-
-        VariantMap& eventData = GetEventDataMap();
-        eventData[P_ELEMENT] = this;
-        eventData[P_VALUE] = value_;
-        SendEvent(E_SLIDERCHANGED, eventData);
-    }
-}
-
-void Slider::ChangeValue(float delta)
-{
-    SetValue(value_ + delta);
-}
-
-void Slider::SetRepeatRate(float rate)
-{
-    repeatRate_ = Max(rate, 0.0f);
-}
-
-bool Slider::FilterImplicitAttributes(XMLElement& dest) const
-{
-    if (!BorderImage::FilterImplicitAttributes(dest))
-        return false;
-
-    XMLElement childElem = dest.GetChild("element");
-    if (!childElem)
-        return false;
-    if (!RemoveChildXML(childElem, "Name", "S_Knob"))
-        return false;
-    if (!RemoveChildXML(childElem, "Position"))
-        return false;
-    if (!RemoveChildXML(childElem, "Size"))
-        return false;
-
-    return true;
-}
-
-void Slider::UpdateSlider()
-{
-    const IntRect& border = knob_->GetBorder();
-
-    if (range_ > 0.0f)
-    {
-        if (orientation_ == O_HORIZONTAL)
-        {
-            int sliderLength = (int)Max((float)GetWidth() / (range_ + 1.0f), (float)(border.left_ + border.right_));
-            float sliderPos = (float)(GetWidth() - sliderLength) * value_ / range_;
-            knob_->SetSize(sliderLength, GetHeight());
-            knob_->SetPosition(Clamp((int)(sliderPos + 0.5f), 0, GetWidth() - knob_->GetWidth()), 0);
-        }
-        else
-        {
-            int sliderLength = (int)Max((float)GetHeight() / (range_ + 1.0f), (float)(border.top_ + border.bottom_));
-            float sliderPos = (float)(GetHeight() - sliderLength) * value_ / range_;
-            knob_->SetSize(GetWidth(), sliderLength);
-            knob_->SetPosition(0, Clamp((int)(sliderPos + 0.5f), 0, GetHeight() - knob_->GetHeight()));
-        }
-    }
-    else
-    {
-        knob_->SetSize(GetSize());
-        knob_->SetPosition(0, 0);
-    }
-}
-
-void Slider::Page(const IntVector2& position, bool pressed)
-{
-    if (!editable_)
-        return;
-
-    IntVector2 offsetXY = position - knob_->GetPosition() - knob_->GetSize() / 2;
-    int offset = orientation_ == O_HORIZONTAL ? offsetXY.x_ : offsetXY.y_;
-    float length = (float)(orientation_ == O_HORIZONTAL ? GetWidth() : GetHeight());
-
-    using namespace SliderPaged;
-
-    VariantMap& eventData = GetEventDataMap();
-    eventData[P_ELEMENT] = this;
-    eventData[P_OFFSET] = offset;
-
-    // Start transmitting repeated pages after the initial press
-    if (selected_ && pressed && repeatRate_ > 0.0f && repeatTimer_.GetMSec(false) >= Lerp(1000.0f / repeatRate_, 0, Abs(offset) / length))
-        repeatTimer_.Reset();
-    else
-        pressed = false;
-
-    eventData[P_PRESSED] = pressed;
-
-    SendEvent(E_SLIDERPAGED, eventData);
-}
-
-}

+ 0 - 110
Source/Atomic/UI/Slider.h

@@ -1,110 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/BorderImage.h"
-
-namespace Atomic
-{
-
-/// %Slider bar %UI element.
-class ATOMIC_API Slider : public BorderImage
-{
-    OBJECT(Slider);
-    
-public:
-    /// Construct.
-    Slider(Context* context);
-    /// Destruct.
-    virtual ~Slider();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-    
-    /// Perform UI element update.
-    virtual void Update(float timeStep);
-    /// React to mouse hover.
-    virtual void OnHover(const IntVector2& position, const IntVector2& screenPosition,  int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse click begin.
-    virtual void OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse click end.
-    virtual void OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement);
-    /// React to mouse drag begin.
-    virtual void OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse drag motion.
-    virtual void OnDragMove(const IntVector2& position, const IntVector2& screenPosition, const IntVector2& deltaPos, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse drag end.
-    virtual void OnDragEnd(const IntVector2& position, const IntVector2& screenPosition, int dragButtons, int buttons, Cursor* cursor);
-    /// React to resize.
-    virtual void OnResize();
-
-    /// Set orientation type.
-    void SetOrientation(Orientation orientation);
-    /// Set slider range maximum value (minimum value is always 0.)
-    void SetRange(float range);
-    /// Set slider current value.
-    void SetValue(float value);
-    /// Change value by a delta.
-    void ChangeValue(float delta);
-    /// Set paging minimum repeat rate (number of events per second).
-    void SetRepeatRate(float rate);
-
-    /// Return orientation type.
-    Orientation GetOrientation() const { return orientation_; }
-    /// Return slider range.
-    float GetRange() const { return range_; }
-    /// Return slider current value.
-    float GetValue() const { return value_; }
-    /// Return knob element.
-    BorderImage* GetKnob() const { return knob_; }
-    /// Return paging minimum repeat rate (number of events per second).
-    float GetRepeatRate() const { return repeatRate_; }
-
-protected:
-    /// Filter implicit attributes in serialization process.
-    virtual bool FilterImplicitAttributes(XMLElement& dest) const;
-    /// Update slider knob position & size.
-    void UpdateSlider();
-    /// Send slider page event.
-    void Page(const IntVector2& position, bool pressed);
-
-    /// Slider knob.
-    SharedPtr<BorderImage> knob_;
-    /// Orientation.
-    Orientation orientation_;
-    /// Slider range.
-    float range_;
-    /// Slider current value.
-    float value_;
-    /// Internal flag of whether the slider is being dragged.
-    bool dragSlider_;
-    /// Original mouse cursor position at drag begin.
-    IntVector2 dragBeginCursor_;
-    /// Original slider position at drag begin.
-    IntVector2 dragBeginPosition_;
-    /// Paging repeat rate.
-    float repeatRate_;
-    /// Paging minimum repeat timer.
-    Timer repeatTimer_;
-};
-
-}

+ 0 - 278
Source/Atomic/UI/Sprite.cpp

@@ -1,278 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../Resource/ResourceCache.h"
-#include "../UI/Sprite.h"
-#include "../Graphics/Texture2D.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-extern const char* blendModeNames[];
-extern const char* horizontalAlignments[];
-extern const char* verticalAlignments[];
-extern const char* UI_CATEGORY;
-
-Sprite::Sprite(Context* context) :
-    UIElement(context),
-    floatPosition_(Vector2::ZERO),
-    hotSpot_(IntVector2::ZERO),
-    scale_(Vector2::ONE),
-    rotation_(0.0f),
-    imageRect_(IntRect::ZERO),
-    blendMode_(BLEND_REPLACE)
-{
-}
-
-Sprite::~Sprite()
-{
-}
-
-void Sprite::RegisterObject(Context* context)
-{
-    context->RegisterFactory<Sprite>(UI_CATEGORY);
-
-    ACCESSOR_ATTRIBUTE("Name", GetName, SetName, String, String::EMPTY, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Position", GetPosition, SetPosition, Vector2, Vector2::ZERO, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Size", GetSize, SetSize, IntVector2, IntVector2::ZERO, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Hotspot", GetHotSpot, SetHotSpot, IntVector2, IntVector2::ZERO, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Scale", GetScale, SetScale, Vector2, Vector2::ONE, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Rotation", GetRotation, SetRotation, float, 0.0f, AM_FILE);
-    MIXED_ACCESSOR_ATTRIBUTE("Texture", GetTextureAttr, SetTextureAttr, ResourceRef, ResourceRef(Texture2D::GetTypeStatic()), AM_FILE);
-    ACCESSOR_ATTRIBUTE("Image Rect", GetImageRect, SetImageRect, IntRect, IntRect::ZERO, AM_FILE);
-    ENUM_ACCESSOR_ATTRIBUTE("Blend Mode", GetBlendMode, SetBlendMode, BlendMode, blendModeNames, 0, AM_FILE);
-    ENUM_ACCESSOR_ATTRIBUTE("Horiz Alignment", GetHorizontalAlignment, SetHorizontalAlignment, HorizontalAlignment, horizontalAlignments, HA_LEFT, AM_FILE);
-    ENUM_ACCESSOR_ATTRIBUTE("Vert Alignment", GetVerticalAlignment, SetVerticalAlignment, VerticalAlignment, verticalAlignments, VA_TOP, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Priority", GetPriority, SetPriority, int, 0, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Opacity", GetOpacity, SetOpacity, float, 1.0f, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Color", GetColorAttr, SetColor, Color, Color::WHITE, AM_FILE);
-    ATTRIBUTE("Top Left Color", Color, color_[0], Color::WHITE, AM_FILE);
-    ATTRIBUTE("Top Right Color", Color, color_[1], Color::WHITE, AM_FILE);
-    ATTRIBUTE("Bottom Left Color", Color, color_[2], Color::WHITE, AM_FILE);
-    ATTRIBUTE("Bottom Right Color", Color, color_[3], Color::WHITE, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Is Visible", IsVisible, SetVisible, bool, true, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Use Derived Opacity", GetUseDerivedOpacity, SetUseDerivedOpacity, bool, true, AM_FILE);
-    ATTRIBUTE("Variables", VariantMap, vars_, Variant::emptyVariantMap, AM_FILE);
-}
-
-bool Sprite::IsWithinScissor(const IntRect& currentScissor)
-{
-    /// \todo Implement properly, for now just checks visibility flag
-    return visible_;
-}
-
-const IntVector2& Sprite::GetScreenPosition() const
-{
-    // This updates screen position for a sprite
-    GetTransform();
-    return screenPosition_;
-}
-
-void Sprite::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor)
-{
-    bool allOpaque = true;
-    if (GetDerivedOpacity() < 1.0f || color_[C_TOPLEFT].a_ < 1.0f || color_[C_TOPRIGHT].a_ < 1.0f ||
-        color_[C_BOTTOMLEFT].a_ < 1.0f || color_[C_BOTTOMRIGHT].a_ < 1.0f)
-        allOpaque = false;
-
-    const IntVector2& size = GetSize();
-    UIBatch batch(this, blendMode_ == BLEND_REPLACE && !allOpaque ? BLEND_ALPHA : blendMode_, currentScissor, texture_, &vertexData);
-
-    batch.AddQuad(GetTransform(), 0, 0, size.x_, size.y_, imageRect_.left_, imageRect_.top_, imageRect_.right_ -
-        imageRect_.left_, imageRect_.bottom_ - imageRect_.top_);
-
-    UIBatch::AddOrMerge(batch, batches);
-
-    // Reset hovering for next frame
-    hovering_ = false;
-}
-
-void Sprite::OnPositionSet()
-{
-    // If the integer position was set (layout update?), copy to the float position
-    floatPosition_ = Vector2((float)position_.x_, (float)position_.y_);
-}
-
-void Sprite::SetPosition(const Vector2& position)
-{
-    if (position != floatPosition_)
-    {
-        floatPosition_ = position;
-        // Copy to the integer position
-        position_ = IntVector2((int)position.x_, (int)position.y_);
-        MarkDirty();
-    }
-}
-
-void Sprite::SetPosition(float x, float y)
-{
-    SetPosition(Vector2(x, y));
-}
-
-void Sprite::SetHotSpot(const IntVector2& hotSpot)
-{
-    if (hotSpot != hotSpot_)
-    {
-        hotSpot_ = hotSpot;
-        MarkDirty();
-    }
-}
-
-void Sprite::SetHotSpot(int x, int y)
-{
-    SetHotSpot(IntVector2(x, y));
-}
-
-void Sprite::SetScale(const Vector2& scale)
-{
-    if (scale != scale_)
-    {
-        scale_ = scale;
-        MarkDirty();
-    }
-}
-
-void Sprite::SetScale(float x, float y)
-{
-    SetScale(Vector2(x, y));
-}
-
-void Sprite::SetScale(float scale)
-{
-    SetScale(Vector2(scale, scale));
-}
-
-void Sprite::SetRotation(float angle)
-{
-    if (angle != rotation_)
-    {
-        rotation_ = angle;
-        MarkDirty();
-    }
-}
-
-void Sprite::SetTexture(Texture* texture)
-{
-    texture_ = texture;
-    if (imageRect_ == IntRect::ZERO)
-        SetFullImageRect();
-}
-
-void Sprite::SetImageRect(const IntRect& rect)
-{
-    if (rect != IntRect::ZERO)
-        imageRect_ = rect;
-}
-
-void Sprite::SetFullImageRect()
-{
-    if (texture_)
-        SetImageRect(IntRect(0, 0, texture_->GetWidth(), texture_->GetHeight()));
-}
-
-void Sprite::SetBlendMode(BlendMode mode)
-{
-    blendMode_ = mode;
-}
-
-const Matrix3x4& Sprite::GetTransform() const
-{
-    if (positionDirty_)
-    {
-        Vector2 pos = floatPosition_;
-
-        Matrix3x4 parentTransform;
-
-        if (parent_)
-        {
-            Sprite* parentSprite = dynamic_cast<Sprite*>(parent_);
-            if (parentSprite)
-                parentTransform = parentSprite->GetTransform();
-            else
-            {
-                const IntVector2& parentScreenPos = parent_->GetScreenPosition() + parent_->GetChildOffset();
-                parentTransform = Matrix3x4::IDENTITY;
-                parentTransform.SetTranslation(Vector3((float)parentScreenPos.x_, (float)parentScreenPos.y_, 0.0f));
-            }
-
-            switch (GetHorizontalAlignment())
-            {
-            case HA_LEFT:
-                break;
-
-            case HA_CENTER:
-                pos.x_ += (float)(parent_->GetSize().x_ / 2);
-                break;
-
-            case HA_RIGHT:
-                pos.x_ += (float)parent_->GetSize().x_;
-                break;
-            }
-            switch (GetVerticalAlignment())
-            {
-            case VA_TOP:
-                break;
-
-            case VA_CENTER:
-                pos.y_ += (float)(parent_->GetSize().y_ / 2);
-                break;
-
-            case VA_BOTTOM:
-                pos.y_ += (float)(parent_->GetSize().y_);
-                break;
-            }
-        }
-        else
-            parentTransform = Matrix3x4::IDENTITY;
-
-        Matrix3x4 hotspotAdjust(Matrix3x4::IDENTITY);
-        hotspotAdjust.SetTranslation(Vector3((float)-hotSpot_.x_, (float)-hotSpot_.y_, 0.0f));
-
-        Matrix3x4 mainTransform(Vector3(pos, 0.0f), Quaternion(rotation_, Vector3::FORWARD), Vector3(scale_, 1.0f));
-
-        transform_ = parentTransform * mainTransform * hotspotAdjust;
-        positionDirty_ = false;
-
-        // Calculate an approximate screen position for GetElementAt(), or pixel-perfect child elements
-        Vector3 topLeftCorner = transform_ * Vector3::ZERO;
-        screenPosition_ = IntVector2((int)topLeftCorner.x_, (int)topLeftCorner.y_);
-    }
-
-    return transform_;
-}
-
-void Sprite::SetTextureAttr(const ResourceRef& value)
-{
-    ResourceCache* cache = GetSubsystem<ResourceCache>();
-    SetTexture(cache->GetResource<Texture2D>(value.name_));
-}
-
-ResourceRef Sprite::GetTextureAttr() const
-{
-    return GetResourceRef(texture_, Texture2D::GetTypeStatic());
-}
-
-}

+ 0 - 119
Source/Atomic/UI/Sprite.h

@@ -1,119 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../Math/Matrix3x4.h"
-#include "../UI/UIElement.h"
-
-namespace Atomic
-{
-
-/// %UI element which allows sub-pixel positioning and size, as well as rotation. Only other Sprites should be added as child elements.
-class ATOMIC_API Sprite : public UIElement
-{
-    OBJECT(Sprite);
-
-public:
-    /// Construct.
-    Sprite(Context* context);
-    /// Destruct.
-    virtual ~Sprite();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// Return whether is visible and inside a scissor rectangle and should be rendered.
-    virtual bool IsWithinScissor(const IntRect& currentScissor);
-    /// Update and return screen position.
-    virtual const IntVector2& GetScreenPosition() const;
-    /// Return UI rendering batches.
-    virtual void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
-    /// React to position change.
-    virtual void OnPositionSet();
-
-    /// Set floating point position.
-    void SetPosition(const Vector2& position);
-    /// Set floating point position.
-    void SetPosition(float x, float y);
-    /// Set hotspot for positioning and rotation.
-    void SetHotSpot(const IntVector2& hotSpot);
-    /// Set hotspot for positioning and rotation.
-    void SetHotSpot(int x, int y);
-    /// Set scale. Scale also affects child sprites.
-    void SetScale(const Vector2& scale);
-    /// Set scale. Scale also affects child sprites.
-    void SetScale(float x, float y);
-    /// Set uniform scale. Scale also affects child sprites.
-    void SetScale(float scale);
-    /// Set rotation angle.
-    void SetRotation(float angle);
-    /// Set texture.
-    void SetTexture(Texture* texture);
-    /// Set part of texture to use as the image.
-    void SetImageRect(const IntRect& rect);
-    /// Use whole texture as the image.
-    void SetFullImageRect();
-    /// Set blend mode.
-    void SetBlendMode(BlendMode mode);
-
-    /// Return floating point position.
-    const Vector2& GetPosition() const { return floatPosition_; }
-    /// Return hotspot.
-    const IntVector2& GetHotSpot() const { return hotSpot_; }
-    /// Return scale.
-    const Vector2& GetScale() const { return scale_; }
-    /// Return rotation angle.
-    float GetRotation() const { return rotation_; }
-    /// Return texture.
-    Texture* GetTexture() const { return texture_; }
-    /// Return image rectangle.
-    const IntRect& GetImageRect() const { return imageRect_; }
-    /// Return blend mode.
-    BlendMode GetBlendMode() const { return blendMode_; }
-
-    /// Set texture attribute.
-    void SetTextureAttr(const ResourceRef& value);
-    /// Return texture attribute.
-    ResourceRef GetTextureAttr() const;
-    /// Update and return rendering transform, also used to transform child sprites.
-    const Matrix3x4& GetTransform() const;
-
-protected:
-    /// Floating point position.
-    Vector2 floatPosition_;
-    /// Hotspot for positioning and rotation.
-    IntVector2 hotSpot_;
-    /// Scale.
-    Vector2 scale_;
-    /// Rotation angle.
-    float rotation_;
-    /// Texture.
-    SharedPtr<Texture> texture_;
-    /// Image rectangle.
-    IntRect imageRect_;
-    /// Blend mode flag.
-    BlendMode blendMode_;
-    /// Transform matrix.
-    mutable Matrix3x4 transform_;
-};
-
-}

+ 0 - 714
Source/Atomic/UI/Text.cpp

@@ -1,714 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../UI/Font.h"
-#include "../UI/FontFace.h"
-#include "../IO/Log.h"
-#include "../Core/Profiler.h"
-#include "../Resource/ResourceCache.h"
-#include "../UI/Text.h"
-#include "../Graphics/Texture2D.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-const char* textEffects[] =
-{
-    "None",
-    "Shadow",
-    "Stroke",
-    0
-};
-
-static const float MIN_ROW_SPACING = 0.5f;
-
-extern const char* horizontalAlignments[];
-extern const char* UI_CATEGORY;
-
-Text::Text(Context* context) :
-    UIElement(context),
-    usedInText3D_(false),
-    fontSize_(DEFAULT_FONT_SIZE),
-    textAlignment_(HA_LEFT),
-    rowSpacing_(1.0f),
-    wordWrap_(false),
-    charLocationsDirty_(true),
-    selectionStart_(0),
-    selectionLength_(0),
-    selectionColor_(Color::TRANSPARENT),
-    hoverColor_(Color::TRANSPARENT),
-    textEffect_(TE_NONE),
-    effectColor_(Color::BLACK),
-    effectDepthBias_(0.0f),
-    rowHeight_(0)
-{
-    // By default Text does not derive opacity from parent elements
-    useDerivedOpacity_ = false;
-}
-
-Text::~Text()
-{
-}
-
-void Text::RegisterObject(Context* context)
-{
-    context->RegisterFactory<Text>(UI_CATEGORY);
-
-    COPY_BASE_ATTRIBUTES(UIElement);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Use Derived Opacity", false);
-    MIXED_ACCESSOR_ATTRIBUTE("Font", GetFontAttr, SetFontAttr, ResourceRef, ResourceRef(Font::GetTypeStatic()), AM_FILE);
-    ATTRIBUTE("Font Size", int, fontSize_, DEFAULT_FONT_SIZE, AM_FILE);
-    ATTRIBUTE("Text", String, text_, String::EMPTY, AM_FILE);
-    ENUM_ATTRIBUTE("Text Alignment", textAlignment_, horizontalAlignments, HA_LEFT, AM_FILE);
-    ATTRIBUTE("Row Spacing", float, rowSpacing_, 1.0f, AM_FILE);
-    ATTRIBUTE("Word Wrap", bool, wordWrap_, false, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Selection Color", GetSelectionColor, SetSelectionColor, Color, Color::TRANSPARENT, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Hover Color", GetHoverColor, SetHoverColor, Color, Color::TRANSPARENT, AM_FILE);
-    ENUM_ATTRIBUTE("Text Effect", textEffect_, textEffects, TE_NONE, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Effect Color", GetEffectColor, SetEffectColor, Color, Color::BLACK, AM_FILE);
-
-    // Change the default value for UseDerivedOpacity
-    context->GetAttribute<Text>("Use Derived Opacity")->defaultValue_ = false;
-}
-
-void Text::ApplyAttributes()
-{
-    UIElement::ApplyAttributes();
-
-    // Decode to Unicode now
-    unicodeText_.Clear();
-    for (unsigned i = 0; i < text_.Length();)
-        unicodeText_.Push(text_.NextUTF8Char(i));
-
-    fontSize_ = Max(fontSize_, 1);
-    ValidateSelection();
-    UpdateText();
-}
-
-void Text::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor)
-{
-    FontFace* face = font_ ? font_->GetFace(fontSize_) : (FontFace*)0;
-    if (!face)
-    {
-        hovering_ = false;
-        return;
-    }
-
-    // If face has changed or char locations are not valid anymore, update before rendering
-    if (charLocationsDirty_ || !fontFace_ || face != fontFace_)
-        UpdateCharLocations();
-    // If face uses mutable glyphs mechanism, reacquire glyphs before rendering to make sure they are in the texture
-    else if (face->HasMutableGlyphs())
-    {
-        for (unsigned i = 0; i < printText_.Size(); ++i)
-            face->GetGlyph(printText_[i]);
-    }
-
-    // Hovering and/or whole selection batch
-    if ((hovering_ && hoverColor_.a_ > 0.0) || (selected_ && selectionColor_.a_ > 0.0f))
-    {
-        bool both = hovering_ && selected_ && hoverColor_.a_ > 0.0 && selectionColor_.a_ > 0.0f;
-        UIBatch batch(this, BLEND_ALPHA, currentScissor, 0, &vertexData);
-        batch.SetColor(both ? selectionColor_.Lerp(hoverColor_, 0.5f) : (selected_ && selectionColor_.a_ > 0.0f ?
-            selectionColor_: hoverColor_));
-        batch.AddQuad(0, 0, GetWidth(), GetHeight(), 0, 0);
-        UIBatch::AddOrMerge(batch, batches);
-    }
-
-    // Partial selection batch
-    if (!selected_ && selectionLength_ && charLocations_.Size() >= selectionStart_ + selectionLength_ && selectionColor_.a_ > 0.0f)
-    {
-        UIBatch batch(this, BLEND_ALPHA, currentScissor, 0, &vertexData);
-        batch.SetColor(selectionColor_);
-
-        IntVector2 currentStart = charLocations_[selectionStart_].position_;
-        IntVector2 currentEnd = currentStart;
-        for (unsigned i = selectionStart_; i < selectionStart_ + selectionLength_; ++i)
-        {
-            // Check if row changes, and start a new quad in that case
-            if (charLocations_[i].size_ != IntVector2::ZERO)
-            {
-                if (charLocations_[i].position_.y_ != currentStart.y_)
-                {
-                    batch.AddQuad(currentStart.x_, currentStart.y_, currentEnd.x_ - currentStart.x_, currentEnd.y_ - currentStart.y_,
-                        0, 0);
-                    currentStart = charLocations_[i].position_;
-                    currentEnd = currentStart + charLocations_[i].size_;
-                }
-                else
-                {
-                    currentEnd.x_ += charLocations_[i].size_.x_;
-                    currentEnd.y_ = Max(currentStart.y_ + charLocations_[i].size_.y_, currentEnd.y_);
-                }
-            }
-        }
-        if (currentEnd != currentStart)
-        {
-            batch.AddQuad(currentStart.x_, currentStart.y_, currentEnd.x_ - currentStart.x_, currentEnd.y_ - currentStart.y_,
-                0, 0);
-        }
-
-        UIBatch::AddOrMerge(batch, batches);
-    }
-
-    // Text batch
-    TextEffect textEffect = font_->IsSDFFont() ? TE_NONE : textEffect_;
-    const Vector<SharedPtr<Texture2D> >& textures = face->GetTextures();
-    for (unsigned n = 0; n < textures.Size() && n < pageGlyphLocations_.Size(); ++n)
-    {
-        // One batch per texture/page
-        UIBatch pageBatch(this, BLEND_ALPHA, currentScissor, textures[n], &vertexData);
-
-        const PODVector<GlyphLocation>& pageGlyphLocation = pageGlyphLocations_[n];
-
-        switch (textEffect)
-        {
-        case TE_NONE:
-            ConstructBatch(pageBatch, pageGlyphLocation, 0, 0);
-            break;
-
-        case TE_SHADOW:
-            ConstructBatch(pageBatch, pageGlyphLocation, 1, 1, &effectColor_, effectDepthBias_);
-            ConstructBatch(pageBatch, pageGlyphLocation, 0, 0);
-            break;
-
-        case TE_STROKE:
-            ConstructBatch(pageBatch, pageGlyphLocation, -1, -1, &effectColor_, effectDepthBias_);
-            ConstructBatch(pageBatch, pageGlyphLocation, 0, -1, &effectColor_, effectDepthBias_);
-            ConstructBatch(pageBatch, pageGlyphLocation, 1, -1, &effectColor_, effectDepthBias_);
-            ConstructBatch(pageBatch, pageGlyphLocation, -1, 0, &effectColor_, effectDepthBias_);
-            ConstructBatch(pageBatch, pageGlyphLocation, 1, 0, &effectColor_, effectDepthBias_);
-            ConstructBatch(pageBatch, pageGlyphLocation, -1, 1, &effectColor_, effectDepthBias_);
-            ConstructBatch(pageBatch, pageGlyphLocation, 0, 1, &effectColor_, effectDepthBias_);
-            ConstructBatch(pageBatch, pageGlyphLocation, 1, 1, &effectColor_, effectDepthBias_);
-            ConstructBatch(pageBatch, pageGlyphLocation, 0, 0);
-            break;
-        }
-
-        UIBatch::AddOrMerge(pageBatch, batches);
-    }
-
-    // Reset hovering for next frame
-    hovering_ = false;
-}
-
-void Text::OnResize()
-{
-    if (wordWrap_)
-        UpdateText(true);
-    else
-        charLocationsDirty_ = true;
-}
-
-void Text::OnIndentSet()
-{
-    charLocationsDirty_ = true;
-}
-
-bool Text::SetFont(const String& fontName, int size)
-{
-    ResourceCache* cache = GetSubsystem<ResourceCache>();
-    return SetFont(cache->GetResource<Font>(fontName), size);
-}
-
-bool Text::SetFont(Font* font, int size)
-{
-    if (!font)
-    {
-        LOGERROR("Null font for Text");
-        return false;
-    }
-
-    if (font != font_ || size != fontSize_)
-    {
-        font_ = font;
-        fontSize_ = Max(size, 1);
-        UpdateText();
-    }
-
-    return true;
-}
-
-void Text::SetText(const String& text)
-{
-    text_ = text;
-
-    // Decode to Unicode now
-    unicodeText_.Clear();
-    for (unsigned i = 0; i < text_.Length();)
-        unicodeText_.Push(text_.NextUTF8Char(i));
-
-    ValidateSelection();
-    UpdateText();
-}
-
-void Text::SetTextAlignment(HorizontalAlignment align)
-{
-    if (align != textAlignment_)
-    {
-        textAlignment_ = align;
-        charLocationsDirty_ = true;
-    }
-}
-
-void Text::SetRowSpacing(float spacing)
-{
-    if (spacing != rowSpacing_)
-    {
-        rowSpacing_ = Max(spacing, MIN_ROW_SPACING);
-        UpdateText();
-    }
-}
-
-void Text::SetWordwrap(bool enable)
-{
-    if (enable != wordWrap_)
-    {
-        wordWrap_ = enable;
-        UpdateText();
-    }
-}
-
-void Text::SetSelection(unsigned start, unsigned length)
-{
-    selectionStart_ = start;
-    selectionLength_ = length;
-    ValidateSelection();
-}
-
-void Text::ClearSelection()
-{
-    selectionStart_ = 0;
-    selectionLength_ = 0;
-}
-
-void Text::SetSelectionColor(const Color& color)
-{
-    selectionColor_ = color;
-}
-
-void Text::SetHoverColor(const Color& color)
-{
-    hoverColor_ = color;
-}
-
-void Text::SetTextEffect(TextEffect textEffect)
-{
-    textEffect_ = textEffect;
-}
-
-void Text::SetEffectColor(const Color& effectColor)
-{
-    effectColor_ = effectColor;
-}
-
-void Text::SetUsedInText3D(bool usedInText3D)
-{
-    usedInText3D_ = usedInText3D;
-}
-
-void Text::SetEffectDepthBias(float bias)
-{
-    effectDepthBias_ = bias;
-}
-
-int Text::GetRowWidth(unsigned index) const
-{
-    return index < rowWidths_.Size() ? rowWidths_[index] : 0;
-}
-
-IntVector2 Text::GetCharPosition(unsigned index)
-{
-    if (charLocationsDirty_)
-        UpdateCharLocations();
-    if (charLocations_.Empty())
-        return IntVector2::ZERO;
-    // For convenience, return the position of the text ending if index exceeded
-    if (index > charLocations_.Size() - 1)
-        index = charLocations_.Size() - 1;
-    return charLocations_[index].position_;
-}
-
-IntVector2 Text::GetCharSize(unsigned index)
-{
-    if (charLocationsDirty_)
-        UpdateCharLocations();
-    if (charLocations_.Size() < 2)
-        return IntVector2::ZERO;
-    // For convenience, return the size of the last char if index exceeded (last size entry is zero)
-    if (index > charLocations_.Size() - 2)
-        index = charLocations_.Size() - 2;
-    return charLocations_[index].size_;
-}
-
-void Text::SetFontAttr(const ResourceRef& value)
-{
-    ResourceCache* cache = GetSubsystem<ResourceCache>();
-    font_ = cache->GetResource<Font>(value.name_);
-}
-
-ResourceRef Text::GetFontAttr() const
-{
-    return GetResourceRef(font_, Font::GetTypeStatic());
-}
-
-bool Text::FilterImplicitAttributes(XMLElement& dest) const
-{
-    if (!UIElement::FilterImplicitAttributes(dest))
-        return false;
-
-    if (!IsFixedWidth())
-    {
-        if (!RemoveChildXML(dest, "Size"))
-            return false;
-        if (!RemoveChildXML(dest, "Min Size"))
-            return false;
-        if (!RemoveChildXML(dest, "Max Size"))
-            return false;
-    }
-
-    return true;
-}
-
-void Text::UpdateText(bool onResize)
-{
-    rowWidths_.Clear();
-    printText_.Clear();
-
-    if (font_)
-    {
-        FontFace* face = font_->GetFace(fontSize_);
-        if (!face)
-            return;
-
-        rowHeight_ = face->GetRowHeight();
-
-        int width = 0;
-        int height = 0;
-        int rowWidth = 0;
-        int rowHeight = (int)(rowSpacing_ * rowHeight_);
-
-        // First see if the text must be split up
-        if (!wordWrap_)
-        {
-            printText_ = unicodeText_;
-            printToText_.Resize(printText_.Size());
-            for (unsigned i = 0; i < printText_.Size(); ++i)
-                printToText_[i] = i;
-        }
-        else
-        {
-            int maxWidth = GetWidth();
-            unsigned nextBreak = 0;
-            unsigned lineStart = 0;
-            printToText_.Clear();
-
-            for (unsigned i = 0; i < unicodeText_.Size(); ++i)
-            {
-                unsigned j;
-                unsigned c = unicodeText_[i];
-
-                if (c != '\n')
-                {
-                    bool ok = true;
-
-                    if (nextBreak <= i)
-                    {
-                        int futureRowWidth = rowWidth;
-                        for (j = i; j < unicodeText_.Size(); ++j)
-                        {
-                            unsigned d = unicodeText_[j];
-                            if (d == ' ' || d == '\n')
-                            {
-                                nextBreak = j;
-                                break;
-                            }
-                            const FontGlyph* glyph = face->GetGlyph(d);
-                            if (glyph)
-                            {
-                                futureRowWidth += glyph->advanceX_;
-                                if (j < unicodeText_.Size() - 1)
-                                    futureRowWidth += face->GetKerning(d, unicodeText_[j + 1]);
-                            }
-                            if (d == '-' && futureRowWidth <= maxWidth)
-                            {
-                                nextBreak = j + 1;
-                                break;
-                            }
-                            if (futureRowWidth > maxWidth)
-                            {
-                                ok = false;
-                                break;
-                            }
-                        }
-                    }
-
-                    if (!ok)
-                    {
-                        // If did not find any breaks on the line, copy until j, or at least 1 char, to prevent infinite loop
-                        if (nextBreak == lineStart)
-                        {
-                            while (i < j)
-                            {
-                                printText_.Push(unicodeText_[i]);
-                                printToText_.Push(i);
-                                ++i;
-                            }
-                        }
-                        // Eliminate spaces that have been copied before the forced break
-                        while (printText_.Size() && printText_.Back() == ' ')
-                        {
-                            printText_.Pop();
-                            printToText_.Pop();
-                        }
-                        printText_.Push('\n');
-                        printToText_.Push(Min((int)i, (int)unicodeText_.Size() - 1));
-                        rowWidth = 0;
-                        nextBreak = lineStart = i;
-                    }
-
-                    if (i < unicodeText_.Size())
-                    {
-                        // When copying a space, position is allowed to be over row width
-                        c = unicodeText_[i];
-                        const FontGlyph* glyph = face->GetGlyph(c);
-                        if (glyph)
-                        {
-                            rowWidth += glyph->advanceX_;
-                            if (i < unicodeText_.Size() - 1)
-                                rowWidth += face->GetKerning(c, unicodeText_[i + 1]);
-                        }
-                        if (rowWidth <= maxWidth)
-                        {
-                            printText_.Push(c);
-                            printToText_.Push(i);
-                        }
-                    }
-                }
-                else
-                {
-                    printText_.Push('\n');
-                    printToText_.Push(Min((int)i, (int)unicodeText_.Size() - 1));
-                    rowWidth = 0;
-                    nextBreak = lineStart = i;
-                }
-            }
-        }
-
-        rowWidth = 0;
-
-        for (unsigned i = 0; i < printText_.Size(); ++i)
-        {
-            unsigned c = printText_[i];
-
-            if (c != '\n')
-            {
-                const FontGlyph* glyph = face->GetGlyph(c);
-                if (glyph)
-                {
-                    rowWidth += glyph->advanceX_;
-                    if (i < printText_.Size() - 1)
-                        rowWidth += face->GetKerning(c, printText_[i + 1]);
-                }
-            }
-            else
-            {
-                width = Max(width, rowWidth);
-                height += rowHeight;
-                rowWidths_.Push(rowWidth);
-                rowWidth = 0;
-            }
-        }
-
-        if (rowWidth)
-        {
-            width = Max(width, rowWidth);
-            height += rowHeight;
-            rowWidths_.Push(rowWidth);
-        }
-
-        // Set at least one row height even if text is empty
-        if (!height)
-            height = rowHeight;
-
-        // Set minimum and current size according to the text size, but respect fixed width if set
-        if (!IsFixedWidth())
-        {
-            SetMinWidth(wordWrap_ ? 0 : width);
-            SetWidth(width);
-        }
-        SetFixedHeight(height);
-
-        charLocationsDirty_ = true;
-    }
-    else
-    {
-        // No font, nothing to render
-        pageGlyphLocations_.Clear();
-    }
-
-    // If wordwrap is on, parent may need layout update to correct for overshoot in size. However, do not do this when the
-    // update is a response to resize, as that could cause infinite recursion
-    if (wordWrap_ && !onResize)
-    {
-        UIElement* parent = GetParent();
-        if (parent && parent->GetLayoutMode() != LM_FREE)
-            parent->UpdateLayout();
-    }
-}
-
-void Text::UpdateCharLocations()
-{
-    // Remember the font face to see if it's still valid when it's time to render
-    FontFace* face = font_ ? font_->GetFace(fontSize_) : (FontFace*)0;
-    if (!face)
-        return;
-    fontFace_ = face;
-
-    int rowHeight = (int)(rowSpacing_ * rowHeight_);
-
-    // Store position & size of each character, and locations per texture page
-    unsigned numChars = unicodeText_.Size();
-    charLocations_.Resize(numChars + 1);
-    pageGlyphLocations_.Resize(face->GetTextures().Size());
-    for (unsigned i = 0; i < pageGlyphLocations_.Size(); ++i)
-        pageGlyphLocations_[i].Clear();
-
-    IntVector2 offset = font_->GetTotalGlyphOffset(fontSize_);
-
-    unsigned rowIndex = 0;
-    unsigned lastFilled = 0;
-    int x = GetRowStartPosition(rowIndex) + offset.x_;
-    int y = offset.y_;
-
-    for (unsigned i = 0; i < printText_.Size(); ++i)
-    {
-        CharLocation loc;
-        loc.position_ = IntVector2(x, y);
-
-        unsigned c = printText_[i];
-        if (c != '\n')
-        {
-            const FontGlyph* glyph = face->GetGlyph(c);
-            loc.size_ = IntVector2(glyph ? glyph->advanceX_ : 0, rowHeight_);
-            if (glyph)
-            {
-                // Store glyph's location for rendering. Verify that glyph page is valid
-                if (glyph->page_ < pageGlyphLocations_.Size())
-                    pageGlyphLocations_[glyph->page_].Push(GlyphLocation(x, y, glyph));
-                x += glyph->advanceX_;
-                if (i < printText_.Size() - 1)
-                    x += face->GetKerning(c, printText_[i + 1]);
-            }
-        }
-        else
-        {
-            loc.size_ = IntVector2::ZERO;
-            x = GetRowStartPosition(++rowIndex);
-            y += rowHeight;
-        }
-
-        // Fill gaps in case characters were skipped from printing
-        for (unsigned j = lastFilled; j <= printToText_[i]; ++j)
-            charLocations_[j] = loc;
-        lastFilled = printToText_[i] + 1;
-    }
-    // Store the ending position
-    charLocations_[numChars].position_ = IntVector2(x, y);
-    charLocations_[numChars].size_ = IntVector2::ZERO;
-
-    charLocationsDirty_ = false;
-}
-
-void Text::ValidateSelection()
-{
-    unsigned textLength = unicodeText_.Size();
-
-    if (textLength)
-    {
-        if (selectionStart_ >= textLength)
-            selectionStart_ = textLength - 1;
-        if (selectionStart_ + selectionLength_ > textLength)
-            selectionLength_ = textLength - selectionStart_;
-    }
-    else
-    {
-        selectionStart_ = 0;
-        selectionLength_ = 0;
-    }
-}
-
-int Text::GetRowStartPosition(unsigned rowIndex) const
-{
-    int rowWidth = 0;
-
-    if (rowIndex < rowWidths_.Size())
-        rowWidth = rowWidths_[rowIndex];
-
-    int ret = GetIndentWidth();
-
-    switch (textAlignment_)
-    {
-    case HA_LEFT:
-        break;
-    case HA_CENTER:
-        ret += (GetSize().x_ - rowWidth) / 2;
-        break;
-    case HA_RIGHT:
-        ret += GetSize().x_ - rowWidth;
-        break;
-    }
-
-    return ret;
-}
-
-void Text::ConstructBatch(UIBatch& pageBatch, const PODVector<GlyphLocation>& pageGlyphLocation, int dx, int dy, Color* color,
-    float depthBias)
-{
-    unsigned startDataSize = pageBatch.vertexData_->Size();
-
-    if (!color)
-        pageBatch.SetDefaultColor();
-    else
-        pageBatch.SetColor(*color);
-
-    for (unsigned i = 0; i < pageGlyphLocation.Size(); ++i)
-    {
-        const GlyphLocation& glyphLocation = pageGlyphLocation[i];
-        const FontGlyph& glyph = *glyphLocation.glyph_;
-        pageBatch.AddQuad(dx + glyphLocation.x_ + glyph.offsetX_, dy + glyphLocation.y_ + glyph.offsetY_, glyph.width_,
-            glyph.height_, glyph.x_, glyph.y_);
-    }
-
-    if (depthBias != 0.0f)
-    {
-        unsigned dataSize = pageBatch.vertexData_->Size();
-        for (unsigned i = startDataSize; i < dataSize; i += UI_VERTEX_SIZE)
-            pageBatch.vertexData_->At(i + 2) += depthBias;
-    }
-}
-
-}

+ 0 - 231
Source/Atomic/UI/Text.h

@@ -1,231 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/UIElement.h"
-
-namespace Atomic
-{
-
-static const int DEFAULT_FONT_SIZE = 12;
-
-class Font;
-class FontFace;
-struct FontGlyph;
-
-/// Text effect.
-enum TextEffect
-{
-    TE_NONE = 0,
-    TE_SHADOW,
-    TE_STROKE
-};
-
-/// Cached character location and size within text. Used for queries related to text editing.
-struct CharLocation
-{
-    /// Position.
-    IntVector2 position_;
-    /// Size.
-    IntVector2 size_;
-};
-
-/// Glyph and its location within the text. Used when preparing text rendering.
-struct GlyphLocation
-{
-    // Construct.
-    GlyphLocation(int x, int y, const FontGlyph* glyph) :
-        x_(x),
-        y_(y),
-        glyph_(glyph)
-    {
-    }
-
-    /// X coordinate.
-    int x_;
-    /// Y coordinate.
-    int y_;
-    /// Glyph.
-    const FontGlyph* glyph_;
-};
-
-/// %Text %UI element.
-class ATOMIC_API Text : public UIElement
-{
-    OBJECT(Text);
-
-    friend class Text3D;
-
-public:
-    /// Construct.
-    Text(Context* context);
-    /// Destruct.
-    virtual ~Text();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// Apply attribute changes that can not be applied immediately.
-    virtual void ApplyAttributes();
-    /// Return UI rendering batches.
-    virtual void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
-    /// React to resize.
-    virtual void OnResize();
-    /// React to indent change.
-    virtual void OnIndentSet();
-
-    /// Set font and font size and use signed distance field.
-    bool SetFont(const String& fontName, int size = DEFAULT_FONT_SIZE);
-    /// Set font and font size and use signed distance field.
-    bool SetFont(Font* font, int size = DEFAULT_FONT_SIZE);
-    /// Set text. Text is assumed to be either ASCII or UTF8-encoded.
-    void SetText(const String& text);
-    /// Set row alignment.
-    void SetTextAlignment(HorizontalAlignment align);
-    /// Set row spacing, 1.0 for original font spacing.
-    void SetRowSpacing(float spacing);
-    /// Set wordwrap. In wordwrap mode the text element will respect its current width. Otherwise it resizes itself freely.
-    void SetWordwrap(bool enable);
-    /// Set selection. When length is not provided, select until the text ends.
-    void SetSelection(unsigned start, unsigned length = M_MAX_UNSIGNED);
-    /// Clear selection.
-    void ClearSelection();
-    /// Set selection background color. Color with 0 alpha (default) disables.
-    void SetSelectionColor(const Color& color);
-    /// Set hover background color. Color with 0 alpha (default) disables.
-    void SetHoverColor(const Color& color);
-    /// Set text effect.
-    void SetTextEffect(TextEffect textEffect);
-    /// Set effect color.
-    void SetEffectColor(const Color& effectColor);
-
-    /// Return font.
-    Font* GetFont() const { return font_; }
-    /// Return font size.
-    int GetFontSize() const { return fontSize_; }
-    /// Return text.
-    const String& GetText() const { return text_; }
-    /// Return row alignment.
-    HorizontalAlignment GetTextAlignment() const { return textAlignment_; }
-    /// Return row spacing.
-    float GetRowSpacing() const { return rowSpacing_; }
-    /// Return wordwrap mode.
-    bool GetWordwrap() const { return wordWrap_; }
-    /// Return selection start.
-    unsigned GetSelectionStart() const { return selectionStart_; }
-    /// Return selection length.
-    unsigned GetSelectionLength() const { return selectionLength_; }
-    /// Return selection background color.
-    const Color& GetSelectionColor() const { return selectionColor_; }
-    /// Return hover background color.
-    const Color& GetHoverColor() const { return hoverColor_; }
-    /// Return text effect.
-    TextEffect GetTextEffect() const { return textEffect_; }
-    /// Return effect color.
-    const Color& GetEffectColor() const { return effectColor_; }
-    /// Return row height.
-    int GetRowHeight() const { return rowHeight_; }
-    /// Return number of rows.
-    unsigned GetNumRows() const { return rowWidths_.Size(); }
-    /// Return number of characters.
-    unsigned GetNumChars() const { return unicodeText_.Size(); }
-    /// Return width of row by index.
-    int GetRowWidth(unsigned index) const;
-    /// Return position of character by index relative to the text element origin.
-    IntVector2 GetCharPosition(unsigned index);
-    /// Return size of character by index.
-    IntVector2 GetCharSize(unsigned index);
-
-    /// Set used in Text3D.
-    void SetUsedInText3D(bool usedInText3D);
-    /// Set text effect Z bias. Zero by default, adjusted only in 3D mode.
-    void SetEffectDepthBias(float bias);
-    /// Return effect Z bias.
-    float GetEffectDepthBias() const { return effectDepthBias_; }
-    /// Set font attribute.
-    void SetFontAttr(const ResourceRef& value);
-    /// Return font attribute.
-    ResourceRef GetFontAttr() const;
-
-protected:
-    /// Filter implicit attributes in serialization process.
-    virtual bool FilterImplicitAttributes(XMLElement& dest) const;
-    /// Update text when text, font or spacing changed.
-    void UpdateText(bool onResize = false);
-    /// Update cached character locations after text update, or when text alignment or indent has changed.
-    void UpdateCharLocations();
-    /// Validate text selection to be within the text.
-    void ValidateSelection();
-    /// Return row start X position.
-    int GetRowStartPosition(unsigned rowIndex) const;
-    /// Contruct batch.
-    void ConstructBatch(UIBatch& pageBatch, const PODVector<GlyphLocation>& pageGlyphLocation, int dx = 0, int dy = 0, Color* color = 0, float depthBias = 0.0f);
-
-    /// Used in Text3D.
-    bool usedInText3D_;
-    /// Font.
-    SharedPtr<Font> font_;
-    /// Current face.
-    WeakPtr<FontFace> fontFace_;
-    /// Font size.
-    int fontSize_;
-    /// UTF-8 encoded text.
-    String text_;
-    /// Row alignment.
-    HorizontalAlignment textAlignment_;
-    /// Row spacing.
-    float rowSpacing_;
-    /// Wordwrap mode.
-    bool wordWrap_;
-    /// Char positions dirty flag.
-    bool charLocationsDirty_;
-    /// Selection start.
-    unsigned selectionStart_;
-    /// Selection length.
-    unsigned selectionLength_;
-    /// Selection background color.
-    Color selectionColor_;
-    /// Hover background color.
-    Color hoverColor_;
-    /// Text effect.
-    TextEffect textEffect_;
-    /// Effect color.
-    Color effectColor_;
-    /// Text effect Z bias.
-    float effectDepthBias_;
-    /// Row height.
-    int rowHeight_;
-    /// Text as Unicode characters.
-    PODVector<unsigned> unicodeText_;
-    /// Text modified into printed form.
-    PODVector<unsigned> printText_;
-    /// Mapping of printed form back to original char indices.
-    PODVector<unsigned> printToText_;
-    /// Row widths.
-    PODVector<int> rowWidths_;
-    /// Glyph locations per each texture in the font.
-    Vector<PODVector<GlyphLocation> > pageGlyphLocations_;
-    /// Cached locations of each character in the text.
-    PODVector<CharLocation> charLocations_;
-};
-
-}

+ 0 - 590
Source/Atomic/UI/Text3D.cpp

@@ -1,590 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#ifdef ATOMIC_3D
-
-#include "Precompiled.h"
-#include "../Graphics/Camera.h"
-#include "../Core/Context.h"
-#include "../UI/Font.h"
-#include "../Graphics/Geometry.h"
-#include "../IO/Log.h"
-#include "../Graphics/Material.h"
-#include "../Scene/Node.h"
-#include "../Resource/ResourceCache.h"
-#include "../Graphics/Technique.h"
-#include "../UI/Text.h"
-#include "../UI/Text3D.h"
-#include "../Graphics/VertexBuffer.h"
-
-namespace Atomic
-{
-
-extern const char* horizontalAlignments[];
-extern const char* verticalAlignments[];
-extern const char* textEffects[];
-extern const char* faceCameraModeNames[];
-extern const char* GEOMETRY_CATEGORY;
-
-static const float TEXT_SCALING = 1.0f / 128.0f;
-static const float DEFAULT_EFFECT_DEPTH_BIAS = 0.1f;
-
-Text3D::Text3D(Context* context) :
-    Drawable(context, DRAWABLE_GEOMETRY),
-    text_(context),
-    vertexBuffer_(new VertexBuffer(context_)),
-    customWorldTransform_(Matrix3x4::IDENTITY),
-    faceCameraMode_(FC_NONE),
-    textDirty_(true),
-    geometryDirty_(true)
-{
-    text_.SetUsedInText3D(true);
-    text_.SetEffectDepthBias(DEFAULT_EFFECT_DEPTH_BIAS);
-}
-
-Text3D::~Text3D()
-{
-}
-
-void Text3D::RegisterObject(Context* context)
-{
-    context->RegisterFactory<Text3D>(GEOMETRY_CATEGORY);
-
-    ACCESSOR_ATTRIBUTE("Is Enabled", IsEnabled, SetEnabled, bool, true, AM_DEFAULT);
-    MIXED_ACCESSOR_ATTRIBUTE("Font", GetFontAttr, SetFontAttr, ResourceRef, ResourceRef(Font::GetTypeStatic()), AM_DEFAULT);
-    MIXED_ACCESSOR_ATTRIBUTE("Material", GetMaterialAttr, SetMaterialAttr, ResourceRef, ResourceRef(Material::GetTypeStatic()), AM_DEFAULT);
-    ATTRIBUTE("Font Size", int, text_.fontSize_, DEFAULT_FONT_SIZE, AM_DEFAULT);
-    ATTRIBUTE("Text", String, text_.text_, String::EMPTY, AM_DEFAULT);
-    ENUM_ATTRIBUTE("Text Alignment", text_.textAlignment_, horizontalAlignments, HA_LEFT, AM_DEFAULT);
-    ATTRIBUTE("Row Spacing", float, text_.rowSpacing_, 1.0f, AM_DEFAULT);
-    ATTRIBUTE("Word Wrap", bool, text_.wordWrap_, false, AM_DEFAULT);
-    ACCESSOR_ATTRIBUTE("Can Be Occluded", IsOccludee, SetOccludee, bool, true, AM_DEFAULT);
-    ENUM_ATTRIBUTE("Face Camera Mode", faceCameraMode_, faceCameraModeNames, FC_NONE, AM_DEFAULT);
-    ACCESSOR_ATTRIBUTE("Draw Distance", GetDrawDistance, SetDrawDistance, float, 0.0f, AM_DEFAULT);
-    ACCESSOR_ATTRIBUTE("Width", GetWidth, SetWidth, int, 0, AM_DEFAULT);
-    ENUM_ACCESSOR_ATTRIBUTE("Horiz Alignment", GetHorizontalAlignment, SetHorizontalAlignment, HorizontalAlignment, horizontalAlignments, HA_LEFT, AM_DEFAULT);
-    ENUM_ACCESSOR_ATTRIBUTE("Vert Alignment", GetVerticalAlignment, SetVerticalAlignment, VerticalAlignment, verticalAlignments, VA_TOP, AM_DEFAULT);
-    ACCESSOR_ATTRIBUTE("Color", GetColorAttr, SetColor, Color, Color::WHITE, AM_DEFAULT);
-    ATTRIBUTE("Top Left Color", Color, text_.color_[0], Color::WHITE, AM_DEFAULT);
-    ATTRIBUTE("Top Right Color", Color, text_.color_[1], Color::WHITE, AM_DEFAULT);
-    ATTRIBUTE("Bottom Left Color", Color, text_.color_[2], Color::WHITE, AM_DEFAULT);
-    ATTRIBUTE("Bottom Right Color", Color, text_.color_[3], Color::WHITE, AM_DEFAULT);
-    ENUM_ATTRIBUTE("Text Effect", text_.textEffect_, textEffects, TE_NONE, AM_DEFAULT);
-    ACCESSOR_ATTRIBUTE("Effect Color", GetEffectColor, SetEffectColor, Color, Color::BLACK, AM_DEFAULT);
-    ATTRIBUTE("Effect Depth Bias", float, text_.effectDepthBias_, DEFAULT_EFFECT_DEPTH_BIAS, AM_DEFAULT);
-    COPY_BASE_ATTRIBUTES(Drawable);
-}
-
-void Text3D::ApplyAttributes()
-{
-    text_.ApplyAttributes();
-    MarkTextDirty();
-    UpdateTextBatches();
-    UpdateTextMaterials();
-}
-
-void Text3D::UpdateBatches(const FrameInfo& frame)
-{
-    distance_ = frame.camera_->GetDistance(GetWorldBoundingBox().Center());
-
-    if (faceCameraMode_ != FC_NONE)
-    {
-        Vector3 worldPosition = node_->GetWorldPosition();
-        customWorldTransform_ = Matrix3x4(worldPosition, frame.camera_->GetFaceCameraRotation(
-            worldPosition, node_->GetWorldRotation(), faceCameraMode_), node_->GetWorldScale());
-        worldBoundingBoxDirty_ = true;
-    }
-
-    for (unsigned i = 0; i < batches_.Size(); ++i)
-    {
-        batches_[i].distance_ = distance_;
-        batches_[i].worldTransform_ = faceCameraMode_ != FC_NONE ? &customWorldTransform_ : &node_->GetWorldTransform();
-    }
-}
-
-void Text3D::UpdateGeometry(const FrameInfo& frame)
-{
-    if (geometryDirty_)
-    {
-        for (unsigned i = 0; i < batches_.Size(); ++i)
-        {
-            Geometry* geometry = geometries_[i];
-            geometry->SetDrawRange(TRIANGLE_LIST, 0, 0, uiBatches_[i].vertexStart_, (uiBatches_[i].vertexEnd_ -
-                uiBatches_[i].vertexStart_) / UI_VERTEX_SIZE);
-        }
-    }
-
-    if ((geometryDirty_ || vertexBuffer_->IsDataLost()) && uiVertexData_.Size())
-    {
-        unsigned vertexCount = uiVertexData_.Size() / UI_VERTEX_SIZE;
-        if (vertexBuffer_->GetVertexCount() != vertexCount)
-            vertexBuffer_->SetSize(vertexCount, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1);
-        vertexBuffer_->SetData(&uiVertexData_[0]);
-    }
-
-    geometryDirty_ = false;
-}
-
-UpdateGeometryType Text3D::GetUpdateGeometryType()
-{
-    if (geometryDirty_ || vertexBuffer_->IsDataLost())
-        return UPDATE_MAIN_THREAD;
-    else
-        return UPDATE_NONE;
-}
-
-void Text3D::SetMaterial(Material* material)
-{
-    material_ = material;
-
-    UpdateTextMaterials(true);
-}
-
-bool Text3D::SetFont(const String& fontName, int size)
-{
-    bool success = text_.SetFont(fontName, size);
-
-    // Changing font requires materials to be re-evaluated. Material evaluation can not be done in worker threads,
-    // so UI batches must be brought up-to-date immediately
-    MarkTextDirty();
-    UpdateTextBatches();
-    UpdateTextMaterials();
-
-    return success;
-}
-
-bool Text3D::SetFont(Font* font, int size)
-{
-    bool success = text_.SetFont(font, size);
-
-    MarkTextDirty();
-    UpdateTextBatches();
-    UpdateTextMaterials();
-
-    return success;
-}
-
-void Text3D::SetText(const String& text)
-{
-    text_.SetText(text);
-
-    // Changing text requires materials to be re-evaluated, in case the font is multi-page
-    MarkTextDirty();
-    UpdateTextBatches();
-    UpdateTextMaterials();
-}
-
-void Text3D::SetAlignment(HorizontalAlignment hAlign, VerticalAlignment vAlign)
-{
-    text_.SetAlignment(hAlign, vAlign);
-
-    MarkTextDirty();
-}
-
-void Text3D::SetHorizontalAlignment(HorizontalAlignment align)
-{
-    text_.SetHorizontalAlignment(align);
-
-    MarkTextDirty();
-}
-
-void Text3D::SetVerticalAlignment(VerticalAlignment align)
-{
-    text_.SetVerticalAlignment(align);
-
-    MarkTextDirty();
-}
-
-void Text3D::SetTextAlignment(HorizontalAlignment align)
-{
-    text_.SetTextAlignment(align);
-
-    MarkTextDirty();
-}
-
-void Text3D::SetRowSpacing(float spacing)
-{
-    text_.SetRowSpacing(spacing);
-
-    MarkTextDirty();
-}
-
-void Text3D::SetWordwrap(bool enable)
-{
-    text_.SetWordwrap(enable);
-
-    MarkTextDirty();
-}
-
-void Text3D::SetTextEffect(TextEffect textEffect)
-{
-    text_.SetTextEffect(textEffect);
-
-    MarkTextDirty();
-    UpdateTextMaterials(true);
-}
-
-void Text3D::SetEffectColor(const Color& effectColor)
-{
-    text_.SetEffectColor(effectColor);
-
-    MarkTextDirty();
-    UpdateTextMaterials();
-}
-
-void Text3D::SetEffectDepthBias(float bias)
-{
-    text_.SetEffectDepthBias(bias);
-
-    MarkTextDirty();
-}
-
-void Text3D::SetWidth(int width)
-{
-    text_.SetMinWidth(width);
-    text_.SetWidth(width);
-
-    MarkTextDirty();
-}
-
-void Text3D::SetColor(const Color& color)
-{
-    text_.SetColor(color);
-
-    MarkTextDirty();
-}
-
-void Text3D::SetColor(Corner corner, const Color& color)
-{
-    text_.SetColor(corner, color);
-
-    MarkTextDirty();
-}
-
-void Text3D::SetOpacity(float opacity)
-{
-    text_.SetOpacity(opacity);
-
-    MarkTextDirty();
-}
-
-void Text3D::SetFaceCameraMode(FaceCameraMode mode)
-{
-    if (mode != faceCameraMode_)
-    {
-        faceCameraMode_ = mode;
-
-        // Bounding box must be recalculated
-        OnMarkedDirty(node_);
-    }
-}
-
-Material* Text3D::GetMaterial() const
-{
-    return material_;
-}
-
-Font* Text3D::GetFont() const
-{
-    return text_.GetFont();
-}
-
-int Text3D::GetFontSize() const
-{
-    return text_.GetFontSize();
-}
-
-const String& Text3D::GetText() const
-{
-    return text_.GetText();
-}
-
-HorizontalAlignment Text3D::GetHorizontalAlignment() const
-{
-    return text_.GetHorizontalAlignment();
-}
-
-VerticalAlignment Text3D::GetVerticalAlignment() const
-{
-    return text_.GetVerticalAlignment();
-}
-
-HorizontalAlignment Text3D::GetTextAlignment() const
-{
-    return text_.GetTextAlignment();
-}
-
-float Text3D::GetRowSpacing() const
-{
-    return text_.GetRowSpacing();
-}
-
-bool Text3D::GetWordwrap() const
-{
-    return text_.GetWordwrap();
-}
-
-TextEffect Text3D::GetTextEffect() const
-{
-    return text_.GetTextEffect();
-}
-
-const Color& Text3D::GetEffectColor() const
-{
-    return text_.GetEffectColor();
-}
-
-float Text3D::GetEffectDepthBias() const
-{
-    return text_.GetEffectDepthBias();
-}
-
-int Text3D::GetWidth() const
-{
-    return text_.GetWidth();
-}
-
-int Text3D::GetRowHeight() const
-{
-    return text_.GetRowHeight();
-}
-
-unsigned Text3D::GetNumRows() const
-{
-    return text_.GetNumRows();
-}
-
-unsigned Text3D::GetNumChars() const
-{
-    return text_.GetNumChars();
-}
-
-int Text3D::GetRowWidth(unsigned index) const
-{
-    return text_.GetRowWidth(index);
-}
-
-IntVector2 Text3D::GetCharPosition(unsigned index)
-{
-    return text_.GetCharPosition(index);
-}
-
-IntVector2 Text3D::GetCharSize(unsigned index)
-{
-    return text_.GetCharSize(index);
-}
-
-const Color& Text3D::GetColor(Corner corner) const
-{
-    return text_.GetColor(corner);
-}
-
-float Text3D::GetOpacity() const
-{
-    return text_.GetOpacity();
-}
-
-void Text3D::OnNodeSet(Node* node)
-{
-    Drawable::OnNodeSet(node);
-
-    if (node)
-        customWorldTransform_ = node->GetWorldTransform();
-}
-
-void Text3D::OnWorldBoundingBoxUpdate()
-{
-    if (textDirty_)
-        UpdateTextBatches();
-
-    // In face camera mode, use the last camera rotation to build the world bounding box
-    worldBoundingBox_ = boundingBox_.Transformed(faceCameraMode_ != FC_NONE ? Matrix3x4(node_->GetWorldPosition(),
-        customWorldTransform_.Rotation(), node_->GetWorldScale()) : node_->GetWorldTransform());
-}
-
-void Text3D::MarkTextDirty()
-{
-    textDirty_ = true;
-
-    OnMarkedDirty(node_);
-    MarkNetworkUpdate();
-}
-
-void Text3D::SetMaterialAttr(const ResourceRef& value)
-{
-    ResourceCache* cache = GetSubsystem<ResourceCache>();
-    SetMaterial(cache->GetResource<Material>(value.name_));
-}
-
-void Text3D::SetFontAttr(const ResourceRef& value)
-{
-    ResourceCache* cache = GetSubsystem<ResourceCache>();
-    text_.font_ = cache->GetResource<Font>(value.name_);
-}
-
-ResourceRef Text3D::GetMaterialAttr() const
-{
-    return GetResourceRef(material_, Material::GetTypeStatic());
-}
-
-ResourceRef Text3D::GetFontAttr() const
-{
-    return GetResourceRef(text_.font_, Font::GetTypeStatic());
-}
-
-void Text3D::UpdateTextBatches()
-{
-    uiBatches_.Clear();
-    uiVertexData_.Clear();
-
-    text_.GetBatches(uiBatches_, uiVertexData_, IntRect::ZERO);
-
-    Vector3 offset(Vector3::ZERO);
-
-    switch (text_.GetHorizontalAlignment())
-    {
-    case HA_LEFT:
-        break;
-
-    case HA_CENTER:
-        offset.x_ -= (float)text_.GetWidth() * 0.5f;
-        break;
-
-    case HA_RIGHT:
-        offset.x_ -= (float)text_.GetWidth();
-        break;
-    }
-
-    switch (text_.GetVerticalAlignment())
-    {
-    case VA_TOP:
-        break;
-
-    case VA_CENTER:
-        offset.y_ -= (float)text_.GetHeight() * 0.5f;
-        break;
-
-    case VA_BOTTOM:
-        offset.y_ -= (float)text_.GetHeight();
-        break;
-    }
-
-    boundingBox_.defined_ = false;
-    boundingBox_.min_ = boundingBox_.max_ = Vector3::ZERO;
-
-    for (unsigned i = 0; i < uiVertexData_.Size(); i += UI_VERTEX_SIZE)
-    {
-        Vector3& position = *(reinterpret_cast<Vector3*>(&uiVertexData_[i]));
-        position += offset;
-        position *= TEXT_SCALING;
-        position.y_ = -position.y_;
-        boundingBox_.Merge(position);
-    }
-
-    textDirty_ = false;
-    geometryDirty_ = true;
-}
-
-void Text3D::UpdateTextMaterials(bool forceUpdate)
-{
-    batches_.Resize(uiBatches_.Size());
-    geometries_.Resize(uiBatches_.Size());
-
-    for (unsigned i = 0; i < batches_.Size(); ++i)
-    {
-        if (!geometries_[i])
-        {
-            Geometry* geometry = new Geometry(context_);
-            geometry->SetVertexBuffer(0, vertexBuffer_, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1);
-            batches_[i].geometry_ = geometries_[i] = geometry;
-        }
-
-        if (!batches_[i].material_ || forceUpdate)
-        {
-            // If material not defined, create a reasonable default from scratch
-            if (!material_)
-            {
-                Material* material = new Material(context_);
-                Technique* tech = new Technique(context_);
-                Pass* pass = tech->CreatePass(PASS_ALPHA);
-                pass->SetVertexShader("Text");
-                pass->SetPixelShader("Text");
-
-                if (GetFont()->IsSDFFont())
-                {
-                    switch (GetTextEffect())
-                    {
-                    case TE_NONE:
-                        pass->SetPixelShaderDefines("SIGNED_DISTANCE_FIELD");
-                        break;
-
-                    case TE_SHADOW:
-                        pass->SetPixelShaderDefines("SIGNED_DISTANCE_FIELD TEXT_EFFECT_SHADOW");
-                        break;
-
-                    case TE_STROKE:
-                        pass->SetPixelShaderDefines("SIGNED_DISTANCE_FIELD TEXT_EFFECT_STROKE");
-                        break;
-                    }
-                }
-
-                pass->SetBlendMode(BLEND_ALPHA);
-                pass->SetDepthWrite(false);
-                material->SetTechnique(0, tech);
-                material->SetCullMode(CULL_NONE);
-                batches_[i].material_ = material;
-            }
-            else
-                batches_[i].material_ = material_->Clone();
-        }
-
-        Material* material = batches_[i].material_;
-        Texture* texture = uiBatches_[i].texture_;
-        material->SetTexture(TU_DIFFUSE, texture);
-
-        if (GetFont()->IsSDFFont())
-        {
-            switch (GetTextEffect())
-            {
-            case TE_SHADOW:
-                if (texture)
-                {
-                    Vector2 shadowOffset(0.5f / texture->GetWidth(), 0.5f / texture->GetHeight());
-                    material->SetShaderParameter("ShadowOffset", shadowOffset);
-                }
-                material->SetShaderParameter("ShadowColor", GetEffectColor());
-                break;
-
-            case TE_STROKE:
-                material->SetShaderParameter("StrokeColor", GetEffectColor());
-                break;
-
-            default:
-                break;
-            }
-        }
-    }
-}
-
-}
-
-#endif

+ 0 - 194
Source/Atomic/UI/Text3D.h

@@ -1,194 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-
-#ifdef ATOMIC_3D
-
-#include "../Graphics/Drawable.h"
-#include "../Math/Matrix3x4.h"
-#include "../UI/Text.h"
-#include "../Graphics/VertexBuffer.h"
-
-namespace Atomic
-{
-
-class Text;
-
-/// 3D text component.
-class ATOMIC_API Text3D : public Drawable
-{
-    OBJECT(Text3D);
-
-public:
-    /// Construct.
-    Text3D(Context* context);
-    /// Destruct.
-    ~Text3D();
-    /// Register object factory. Drawable must be registered first.
-    static void RegisterObject(Context* context);
-
-    /// Apply attribute changes that can not be applied immediately.
-    virtual void ApplyAttributes();
-    /// Calculate distance and prepare batches for rendering. May be called from worker thread(s), possibly re-entrantly.
-    virtual void UpdateBatches(const FrameInfo& frame);
-    /// Prepare geometry for rendering. Called from a worker thread if possible (no GPU update.)
-    virtual void UpdateGeometry(const FrameInfo& frame);
-    /// Return whether a geometry update is necessary, and if it can happen in a worker thread.
-    virtual UpdateGeometryType GetUpdateGeometryType();
-
-    /// Set font and font size and use signed distance field font. Return true if successful.
-    bool SetFont(const String& fontName, int size = DEFAULT_FONT_SIZE);
-    /// Set font and font size and use signed distance field font. Return true if successful.
-    bool SetFont(Font* font, int size = DEFAULT_FONT_SIZE);
-    /// Set material.
-    void SetMaterial(Material* material);
-    /// Set text. Text is assumed to be either ASCII or UTF8-encoded.
-    void SetText(const String& text);
-    /// Set horizontal and vertical alignment.
-    void SetAlignment(HorizontalAlignment hAlign, VerticalAlignment vAlign);
-    /// Set horizontal alignment.
-    void SetHorizontalAlignment(HorizontalAlignment align);
-    /// Set vertical alignment.
-    void SetVerticalAlignment(VerticalAlignment align);
-    /// Set row alignment.
-    void SetTextAlignment(HorizontalAlignment align);
-    /// Set row spacing, 1.0 for original font spacing.
-    void SetRowSpacing(float spacing);
-    /// Set wordwrap. In wordwrap mode the text element will respect its current width. Otherwise it resizes itself freely.
-    void SetWordwrap(bool enable);
-    /// Set text effect.
-    void SetTextEffect(TextEffect textEffect);
-    /// Set effect color.
-    void SetEffectColor(const Color& effectColor);
-    /// Set effect Z bias.
-    void SetEffectDepthBias(float bias);
-    /// Set text width. Only has effect in word wrap mode.
-    void SetWidth(int width);
-    /// Set color on all corners.
-    void SetColor(const Color& color);
-    /// Set color on one corner.
-    void SetColor(Corner corner, const Color& color);
-    /// Set opacity.
-    void SetOpacity(float opacity);
-    /// Set how the text should rotate in relation to the camera. Default is to not rotate (FC_NONE.)
-    void SetFaceCameraMode(FaceCameraMode mode);
-
-    /// Return font.
-    Font* GetFont() const;
-    /// Return material.
-    Material* GetMaterial() const;
-    /// Return font size.
-    int GetFontSize() const;
-    /// Return text.
-    const String& GetText() const;
-    /// Return row alignment.
-    HorizontalAlignment GetTextAlignment() const;
-    /// Return horizontal alignment.
-    HorizontalAlignment GetHorizontalAlignment() const;
-    /// Return vertical alignment.
-    VerticalAlignment GetVerticalAlignment() const;
-    /// Return row spacing.
-    float GetRowSpacing() const;
-    /// Return wordwrap mode.
-    bool GetWordwrap() const;
-    /// Return text effect.
-    TextEffect GetTextEffect() const;
-    /// Return effect color.
-    const Color& GetEffectColor() const;
-    /// Return effect depth bias.
-    float GetEffectDepthBias() const;
-    /// Return text width.
-    int GetWidth() const;
-    /// Return row height.
-    int GetRowHeight() const;
-    /// Return number of rows.
-    unsigned GetNumRows() const;
-    /// Return number of characters.
-    unsigned GetNumChars() const;
-    /// Return width of row by index.
-    int GetRowWidth(unsigned index) const;
-    /// Return position of character by index relative to the text element origin.
-    IntVector2 GetCharPosition(unsigned index);
-    /// Return size of character by index.
-    IntVector2 GetCharSize(unsigned index);
-    /// Return corner color.
-    const Color& GetColor(Corner corner) const;
-    /// Return opacity.
-    float GetOpacity() const;
-    /// Return how the text rotates in relation to the camera.
-    FaceCameraMode GetFaceCameraMode() const { return faceCameraMode_; }
-
-    /// Set font attribute.
-    void SetFontAttr(const ResourceRef& value);
-    /// Return font attribute.
-    ResourceRef GetFontAttr() const;
-    /// Set material attribute.
-    void SetMaterialAttr(const ResourceRef& value);
-    /// Return material attribute.
-    ResourceRef GetMaterialAttr() const;
-    /// Get color attribute. Uses just the top-left color.
-    const Color& GetColorAttr() const { return text_.color_[0]; }
-
-protected:
-    /// Handle node being assigned.
-    virtual void OnNodeSet(Node* node);
-    /// Recalculate the world-space bounding box.
-    virtual void OnWorldBoundingBoxUpdate();
-
-private:
-    /// Mark text & geometry dirty.
-    void MarkTextDirty();
-    /// Update text and font.
-    void UpdateText();
-    /// Update text %UI batches.
-    void UpdateTextBatches();
-    /// Create materials for text rendering. May only be called from the main thread. Text %UI batches must be up-to-date.
-    void UpdateTextMaterials(bool forceUpdate = false);
-
-    /// Internally used text element.
-    Text text_;
-    /// Geometries.
-    Vector<SharedPtr<Geometry> > geometries_;
-    /// Vertex buffer.
-    SharedPtr<VertexBuffer> vertexBuffer_;
-    /// Material to use as a base for the text material(s).
-    SharedPtr<Material> material_;
-    /// Text UI batches.
-    PODVector<UIBatch> uiBatches_;
-    /// Text vertex data.
-    PODVector<float> uiVertexData_;
-    /// Custom world transform for facing the camera automatically.
-    Matrix3x4 customWorldTransform_;
-    /// Text rotation mode in relation to the camera.
-    FaceCameraMode faceCameraMode_;
-    /// Text needs update flag.
-    bool textDirty_;
-    /// Geometry dirty flag.
-    bool geometryDirty_;
-};
-
-}
-
-#endif
-

+ 0 - 110
Source/Atomic/UI/ToolTip.cpp

@@ -1,110 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../UI/ToolTip.h"
-#include "../Core/Context.h"
-#include "../Core/Timer.h"
-#include "../UI/UI.h"
-
-namespace Atomic
-{
-
-extern const char* UI_CATEGORY;
-
-ToolTip::ToolTip(Context* context) :
-    UIElement(context),
-    delay_(0.0f),
-    parentHovered_(false)
-{
-    SetVisible(false);
-}
-
-ToolTip::~ToolTip()
-{
-}
-
-void ToolTip::RegisterObject(Context* context)
-{
-    context->RegisterFactory<ToolTip>(UI_CATEGORY);
-
-    COPY_BASE_ATTRIBUTES(UIElement);
-    ACCESSOR_ATTRIBUTE("Delay", GetDelay, SetDelay, float, 0.0f, AM_FILE);
-}
-
-void ToolTip::Update(float timeStep)
-{
-    // Track the element we are parented to for hovering. When we display, we move ourself to the root element
-    // to ensure displaying on top
-    UIElement* root = GetRoot();
-    if (!root)
-        return;
-    if (parent_ != root)
-        target_ = parent_;
-
-    // If target is removed while we are displaying, we have no choice but to destroy ourself
-    if (target_.Expired())
-    {
-        Remove();
-        return;
-    }
-
-    if (target_->IsHovering())
-    {
-        float effectiveDelay = delay_ > 0.0f ? delay_ : GetSubsystem<UI>()->GetDefaultToolTipDelay();
-        
-        if (!parentHovered_)
-        {
-            parentHovered_ = true;
-            displayAt_.Reset();
-        }
-        else if(displayAt_.GetMSec(false) >= (unsigned)(effectiveDelay * 1000.0f) && parent_ == target_)
-        {
-            originalPosition_ = GetPosition();
-            IntVector2 screenPosition = GetScreenPosition();
-            SetParent(root);
-            SetPosition(screenPosition);
-            SetVisible(true);
-            // BringToFront() is unreliable in this case as it takes into account only input-enabled elements.
-            // Rather just force priority to max
-            SetPriority(M_MAX_INT);
-        }
-    }
-    else
-    {
-        if (IsVisible() && parent_ == root)
-        {
-            SetParent(target_);
-            SetPosition(originalPosition_);
-            SetVisible(false);
-        }
-        parentHovered_ = false;
-        displayAt_.Reset();
-    }
-}
-
-void ToolTip::SetDelay(float delay)
-{
-    delay_ = delay;
-}
-
-}

+ 0 - 66
Source/Atomic/UI/ToolTip.h

@@ -1,66 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../Graphics/GraphicsDefs.h"
-#include "../UI/UIElement.h"
-
-namespace Atomic
-{
-
-/// Tooltip %UI element.
-class ATOMIC_API ToolTip : public UIElement
-{
-    OBJECT(ToolTip)
-
-public:
-    /// Construct.
-    ToolTip(Context* context);
-    /// Destruct.
-    virtual ~ToolTip();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// Perform UI element update.
-    virtual void Update(float timeStep);
-
-    /// Set the delay in seconds until the tooltip shows once hovering. Set zero to use the default from the UI subsystem.
-    void SetDelay(float delay);
-
-    /// Return the delay in seconds until the tooltip shows once hovering.
-    float GetDelay() const { return delay_; }
-
-private:
-    /// The element that is being tracked for hovering. Normally the parent element.
-    WeakPtr<UIElement> target_;
-    /// Delay from hover start to displaying the tooltip.
-    float delay_;
-    /// Point at which the parent was hovered.
-    bool parentHovered_;
-    /// Point at which the tooltip was set visible.
-    Timer displayAt_;
-    /// Original offset position to the parent.
-    IntVector2 originalPosition_;
-};
-
-}

+ 0 - 325
Source/Atomic/UI/UI.cpp

@@ -21,39 +21,24 @@
 //
 //
 
 
 #include "Precompiled.h"
 #include "Precompiled.h"
-#include "../UI/CheckBox.h"
 #include "../Core/Context.h"
 #include "../Core/Context.h"
 #include "../Core/CoreEvents.h"
 #include "../Core/CoreEvents.h"
 #include "../UI/Cursor.h"
 #include "../UI/Cursor.h"
-#include "../UI/DropDownList.h"
-#include "../UI/FileSelector.h"
-#include "../UI/Font.h"
 #include "../Graphics/Graphics.h"
 #include "../Graphics/Graphics.h"
 #include "../Graphics/GraphicsEvents.h"
 #include "../Graphics/GraphicsEvents.h"
 #include "../Input/Input.h"
 #include "../Input/Input.h"
 #include "../Input/InputEvents.h"
 #include "../Input/InputEvents.h"
-#include "../UI/LineEdit.h"
-#include "../UI/ListView.h"
 #include "../IO/Log.h"
 #include "../IO/Log.h"
 #include "../Math/Matrix3x4.h"
 #include "../Math/Matrix3x4.h"
-#include "../UI/MessageBox.h"
 #include "../Core/Profiler.h"
 #include "../Core/Profiler.h"
 #include "../Resource/ResourceCache.h"
 #include "../Resource/ResourceCache.h"
-#include "../UI/ScrollBar.h"
 #include "../Graphics/Shader.h"
 #include "../Graphics/Shader.h"
 #include "../Graphics/ShaderVariation.h"
 #include "../Graphics/ShaderVariation.h"
-#include "../UI/Slider.h"
 #include "../Container/Sort.h"
 #include "../Container/Sort.h"
-#include "../UI/Sprite.h"
-#include "../UI/Text.h"
-#include "../UI/Text3D.h"
 #include "../Graphics/Texture2D.h"
 #include "../Graphics/Texture2D.h"
-#include "../UI/ToolTip.h"
 #include "../UI/UI.h"
 #include "../UI/UI.h"
 #include "../UI/UIEvents.h"
 #include "../UI/UIEvents.h"
 #include "../Graphics/VertexBuffer.h"
 #include "../Graphics/VertexBuffer.h"
-#include "../UI/Window.h"
-#include "../UI/View3D.h"
 
 
 #include <SDL/include/SDL.h>
 #include <SDL/include/SDL.h>
 
 
@@ -211,80 +196,6 @@ void UI::SetFocusElement(UIElement* element, bool byKey)
     SendEvent(E_FOCUSCHANGED, eventData);
     SendEvent(E_FOCUSCHANGED, eventData);
 }
 }
 
 
-bool UI::SetModalElement(UIElement* modalElement, bool enable)
-{
-    if (!modalElement)
-        return false;
-
-    // Currently only allow modal window
-    if (modalElement->GetType() != Window::GetTypeStatic())
-        return false;
-
-    assert(rootModalElement_);
-    UIElement* currParent = modalElement->GetParent();
-    if (enable)
-    {
-        // Make sure it is not already the child of the root modal element
-        if (currParent == rootModalElement_)
-            return false;
-
-        // Adopt modal root as parent
-        modalElement->SetVar(VAR_ORIGINAL_PARENT, currParent);
-        modalElement->SetVar(VAR_ORIGINAL_CHILD_INDEX, currParent ? currParent->FindChild(modalElement) : M_MAX_UNSIGNED);
-        modalElement->SetParent(rootModalElement_);
-
-        // If it is a popup element, bring along its top-level parent
-        UIElement* originElement = static_cast<UIElement*>(modalElement->GetVar(VAR_ORIGIN).GetPtr());
-        if (originElement)
-        {
-            UIElement* element = originElement;
-            while (element && element->GetParent() != rootElement_)
-                element = element->GetParent();
-            if (element)
-            {
-                originElement->SetVar(VAR_PARENT_CHANGED, element);
-                UIElement* oriParent = element->GetParent();
-                element->SetVar(VAR_ORIGINAL_PARENT, oriParent);
-                element->SetVar(VAR_ORIGINAL_CHILD_INDEX, oriParent ? oriParent->FindChild(element) : M_MAX_UNSIGNED);
-                element->SetParent(rootModalElement_);
-            }
-        }
-
-        return true;
-    }
-    else
-    {
-        // Only the modal element can disable itself
-        if (currParent != rootModalElement_)
-            return false;
-
-        // Revert back to original parent
-        modalElement->SetParent(static_cast<UIElement*>(modalElement->GetVar(VAR_ORIGINAL_PARENT).GetPtr()),
-            modalElement->GetVar(VAR_ORIGINAL_CHILD_INDEX).GetUInt());
-        VariantMap& vars = const_cast<VariantMap&>(modalElement->GetVars());
-        vars.Erase(VAR_ORIGINAL_PARENT);
-        vars.Erase(VAR_ORIGINAL_CHILD_INDEX);
-
-        // If it is a popup element, revert back its top-level parent
-        UIElement* originElement = static_cast<UIElement*>(modalElement->GetVar(VAR_ORIGIN).GetPtr());
-        if (originElement)
-        {
-            UIElement* element = static_cast<UIElement*>(originElement->GetVar(VAR_PARENT_CHANGED).GetPtr());
-            if (element)
-            {
-                const_cast<VariantMap&>(originElement->GetVars()).Erase(VAR_PARENT_CHANGED);
-                element->SetParent(static_cast<UIElement*>(element->GetVar(VAR_ORIGINAL_PARENT).GetPtr()),
-                    element->GetVar(VAR_ORIGINAL_CHILD_INDEX).GetUInt());
-                vars = const_cast<VariantMap&>(element->GetVars());
-                vars.Erase(VAR_ORIGINAL_PARENT);
-                vars.Erase(VAR_ORIGINAL_CHILD_INDEX);
-            }
-        }
-
-        return true;
-    }
-}
-
 void UI::Clear()
 void UI::Clear()
 {
 {
     rootElement_->RemoveAllChildren();
     rootElement_->RemoveAllChildren();
@@ -545,18 +456,6 @@ void UI::SetDefaultToolTipDelay(float delay)
     defaultToolTipDelay_ = Max(delay, 0.0f);
     defaultToolTipDelay_ = Max(delay, 0.0f);
 }
 }
 
 
-void UI::SetMaxFontTextureSize(int size)
-{
-    if (IsPowerOfTwo(size) && size >= FONT_TEXTURE_MIN_SIZE)
-    {
-        if (size != maxFontTextureSize_)
-        {
-            maxFontTextureSize_ = size;
-            ReleaseFontFaces();
-        }
-    }
-}
-
 void UI::SetNonFocusedMouseWheel(bool nonFocusedMouseWheel)
 void UI::SetNonFocusedMouseWheel(bool nonFocusedMouseWheel)
 {
 {
     nonFocusedMouseWheel_ = nonFocusedMouseWheel;
     nonFocusedMouseWheel_ = nonFocusedMouseWheel;
@@ -572,24 +471,6 @@ void UI::SetUseScreenKeyboard(bool enable)
     useScreenKeyboard_ = enable;
     useScreenKeyboard_ = enable;
 }
 }
 
 
-void UI::SetUseMutableGlyphs(bool enable)
-{
-    if (enable != useMutableGlyphs_)
-    {
-        useMutableGlyphs_ = enable;
-        ReleaseFontFaces();
-    }
-}
-
-void UI::SetForceAutoHint(bool enable)
-{
-    if (enable != forceAutoHint_)
-    {
-        forceAutoHint_ = enable;
-        ReleaseFontFaces();
-    }
-}
-
 IntVector2 UI::GetCursorPosition() const
 IntVector2 UI::GetCursorPosition() const
 {
 {
     return cursor_ ? cursor_->GetPosition() : GetSubsystem<Input>()->GetMousePosition();
     return cursor_ ? cursor_->GetPosition() : GetSubsystem<Input>()->GetMousePosition();
@@ -983,17 +864,6 @@ void UI::SetCursorShape(CursorShape shape)
         cursor_->SetShape(shape);
         cursor_->SetShape(shape);
 }
 }
 
 
-void UI::ReleaseFontFaces()
-{
-    LOGDEBUG("Reloading font faces");
-
-    PODVector<Font*> fonts;
-    GetSubsystem<ResourceCache>()->GetResources<Font>(fonts);
-
-    for (unsigned i = 0; i < fonts.Size(); ++i)
-        fonts[i]->ReleaseFaces();
-}
-
 void UI::ProcessHover(const IntVector2& cursorPos, int buttons, int qualifiers, Cursor* cursor)
 void UI::ProcessHover(const IntVector2& cursorPos, int buttons, int qualifiers, Cursor* cursor)
 {
 {
     WeakPtr<UIElement> element(GetElementAt(cursorPos));
     WeakPtr<UIElement> element(GetElementAt(cursorPos));
@@ -1438,201 +1308,27 @@ void UI::HandleMouseMove(StringHash eventType, VariantMap& eventData)
 
 
 void UI::HandleMouseWheel(StringHash eventType, VariantMap& eventData)
 void UI::HandleMouseWheel(StringHash eventType, VariantMap& eventData)
 {
 {
-    Input* input = GetSubsystem<Input>();
-    if (input->IsMouseGrabbed())
-        return;
-
-    using namespace MouseWheel;
-
-    mouseButtons_ = eventData[P_BUTTONS].GetInt();
-    qualifiers_ = eventData[P_QUALIFIERS].GetInt();
-    int delta = eventData[P_WHEEL].GetInt();
-    usingTouchInput_ = false;
-
-    IntVector2 cursorPos;
-    bool cursorVisible;
-    GetCursorPositionAndVisible(cursorPos, cursorVisible);
-
-    UIElement* element;
-    if (!nonFocusedMouseWheel_&& (element = focusElement_))
-        element->OnWheel(delta, mouseButtons_, qualifiers_);
-    else
-    {
-        // If no element has actual focus or in non-focused mode, get the element at cursor
-        if (cursorVisible)
-        {
-            element = GetElementAt(cursorPos);
-            if (nonFocusedMouseWheel_)
-            {
-                // Going up the hierarchy chain to find element that could handle mouse wheel
-                while (element)
-                {
-                    if (element->GetType() == ListView::GetTypeStatic() ||
-                        element->GetType() == ScrollView::GetTypeStatic())
-                        break;
-                    element = element->GetParent();
-                }
-            }
-            else
-                // If the element itself is not focusable, search for a focusable parent,
-                // although the focusable element may not actually handle mouse wheel
-                element = GetFocusableElement(element);
-
-            if (element && (nonFocusedMouseWheel_ || element->GetFocusMode() >= FM_FOCUSABLE))
-                element->OnWheel(delta, mouseButtons_, qualifiers_);
-        }
-    }
 }
 }
 
 
 void UI::HandleTouchBegin(StringHash eventType, VariantMap& eventData)
 void UI::HandleTouchBegin(StringHash eventType, VariantMap& eventData)
 {
 {
-    Input* input = GetSubsystem<Input>();
-    if (input->IsMouseGrabbed())
-        return;
-
-    using namespace TouchBegin;
-
-    IntVector2 pos(eventData[P_X].GetInt(), eventData[P_Y].GetInt());
-    usingTouchInput_ = true;
-
-    int touchId = TOUCHID_MASK(eventData[P_TOUCHID].GetInt());
-    WeakPtr<UIElement> element(GetElementAt(pos));
-
-    if (element)
-    {
-        ProcessClickBegin(pos, touchId, touchDragElements_[element], 0, 0, true);
-        touchDragElements_[element] |= touchId;
-    }
-    else
-        ProcessClickBegin(pos, touchId, touchId, 0, 0, true);
 }
 }
 
 
 void UI::HandleTouchEnd(StringHash eventType, VariantMap& eventData)
 void UI::HandleTouchEnd(StringHash eventType, VariantMap& eventData)
 {
 {
-    using namespace TouchEnd;
-
-    IntVector2 pos(eventData[P_X].GetInt(), eventData[P_Y].GetInt());
-
-    // Get the touch index
-    int touchId = TOUCHID_MASK(eventData[P_TOUCHID].GetInt());
-
-    // Transmit hover end to the position where the finger was lifted
-    WeakPtr<UIElement> element(GetElementAt(pos));
-
-    // Clear any drag events that were using the touch id
-    for (HashMap<WeakPtr<UIElement>, int>::Iterator i = touchDragElements_.Begin(); i != touchDragElements_.End(); )
-    {
-        int touches = i->second_;
-        if (touches & touchId)
-            i = touchDragElements_.Erase(i);
-        else
-            ++i;
-    }
-
-    if (element && element->IsEnabled())
-        element->OnHover(element->ScreenToElement(pos), pos, 0, 0, 0);
-
-    ProcessClickEnd(pos, touchId, 0, 0, 0, true);
 }
 }
 
 
 void UI::HandleTouchMove(StringHash eventType, VariantMap& eventData)
 void UI::HandleTouchMove(StringHash eventType, VariantMap& eventData)
 {
 {
-    using namespace TouchMove;
-
-    IntVector2 pos(eventData[P_X].GetInt(), eventData[P_Y].GetInt());
-    IntVector2 deltaPos(eventData[P_DX].GetInt(), eventData[P_DY].GetInt());
-    usingTouchInput_ = true;
-
-    int touchId = TOUCHID_MASK(eventData[P_TOUCHID].GetInt());
-
-    ProcessMove(pos, deltaPos, touchId, 0, 0, true);
 }
 }
 
 
 void UI::HandleKeyDown(StringHash eventType, VariantMap& eventData)
 void UI::HandleKeyDown(StringHash eventType, VariantMap& eventData)
 {
 {
-    using namespace KeyDown;
-
-    mouseButtons_ = eventData[P_BUTTONS].GetInt();
-    qualifiers_ = eventData[P_QUALIFIERS].GetInt();
-    int key = eventData[P_KEY].GetInt();
 
 
-    // Cancel UI dragging
-    if (key == KEY_ESC && dragElementsCount_ > 0)
-    {
-        ProcessDragCancel();
-
-        return;
-    }
-
-    // Dismiss modal element if any when ESC key is pressed
-    if (key == KEY_ESC && HasModalElement())
-    {
-        UIElement* element = rootModalElement_->GetChild(rootModalElement_->GetNumChildren() - 1);
-        if (element->GetVars().Contains(VAR_ORIGIN))
-            // If it is a popup, dismiss by defocusing it
-            SetFocusElement(0);
-        else
-        {
-            // If it is a modal window, by resetting its modal flag
-            Window* window = dynamic_cast<Window*>(element);
-            if (window && window->GetModalAutoDismiss())
-                window->SetModal(false);
-        }
-
-        return;
-    }
-
-    UIElement* element = focusElement_;
-    if (element)
-    {
-        // Switch focus between focusable elements in the same top level window
-        if (key == KEY_TAB)
-        {
-            UIElement* topLevel = element->GetParent();
-            while (topLevel && topLevel->GetParent() != rootElement_ && topLevel->GetParent() != rootModalElement_)
-                topLevel = topLevel->GetParent();
-            if (topLevel)
-            {
-                topLevel->GetChildren(tempElements_, true);
-                for (PODVector<UIElement*>::Iterator i = tempElements_.Begin(); i != tempElements_.End();)
-                {
-                    if ((*i)->GetFocusMode() < FM_FOCUSABLE)
-                        i = tempElements_.Erase(i);
-                    else
-                        ++i;
-                }
-                for (unsigned i = 0; i < tempElements_.Size(); ++i)
-                {
-                    if (tempElements_[i] == element)
-                    {
-                        int dir = (qualifiers_ & QUAL_SHIFT) ? -1 : 1;
-                        unsigned nextIndex = (tempElements_.Size() + i + dir) % tempElements_.Size();
-                        UIElement* next = tempElements_[nextIndex];
-                        SetFocusElement(next, true);
-                        return;
-                    }
-                }
-            }
-        }
-        // Defocus the element
-        else if (key == KEY_ESC && element->GetFocusMode() == FM_FOCUSABLE_DEFOCUSABLE)
-            element->SetFocus(false);
-        // If none of the special keys, pass the key to the focused element
-        else
-            element->OnKey(key, mouseButtons_, qualifiers_);
-    }
 }
 }
 
 
 void UI::HandleTextInput(StringHash eventType, VariantMap& eventData)
 void UI::HandleTextInput(StringHash eventType, VariantMap& eventData)
 {
 {
-    using namespace TextInput;
-
-    mouseButtons_ = eventData[P_BUTTONS].GetInt();
-    qualifiers_ = eventData[P_QUALIFIERS].GetInt();
-
-    UIElement* element = focusElement_;
-    if (element)
-        element->OnTextInput(eventData[P_TEXT].GetString(), mouseButtons_, qualifiers_);
 }
 }
 
 
 void UI::HandleBeginFrame(StringHash eventType, VariantMap& eventData)
 void UI::HandleBeginFrame(StringHash eventType, VariantMap& eventData)
@@ -1758,30 +1454,9 @@ IntVector2 UI::SumTouchPositions(UI::DragData* dragData, const IntVector2& oldSe
 
 
 void RegisterUILibrary(Context* context)
 void RegisterUILibrary(Context* context)
 {
 {
-    Font::RegisterObject(context);
-
     UIElement::RegisterObject(context);
     UIElement::RegisterObject(context);
     BorderImage::RegisterObject(context);
     BorderImage::RegisterObject(context);
-    Sprite::RegisterObject(context);
-    Button::RegisterObject(context);
-    CheckBox::RegisterObject(context);
     Cursor::RegisterObject(context);
     Cursor::RegisterObject(context);
-    Text::RegisterObject(context);
-#ifdef ATOMIC_3D
-    Text3D::RegisterObject(context);
-#endif
-    Window::RegisterObject(context);
-    View3D::RegisterObject(context);
-    LineEdit::RegisterObject(context);
-    Slider::RegisterObject(context);
-    ScrollBar::RegisterObject(context);
-    ScrollView::RegisterObject(context);
-    ListView::RegisterObject(context);
-    Menu::RegisterObject(context);
-    DropDownList::RegisterObject(context);
-    FileSelector::RegisterObject(context);
-    MessageBox::RegisterObject(context);
-    ToolTip::RegisterObject(context);
 }
 }
 
 
 }
 }

+ 1 - 12
Source/Atomic/UI/UI.h

@@ -54,9 +54,6 @@ public:
     void SetCursor(Cursor* cursor);
     void SetCursor(Cursor* cursor);
     /// Set focused UI element.
     /// Set focused UI element.
     void SetFocusElement(UIElement* element, bool byKey = false);
     void SetFocusElement(UIElement* element, bool byKey = false);
-    /// Set modal element. Until all the modal elements are dismissed, all the inputs and events are only sent to them. Return true when successful.
-    /// Only the modal element can clear its modal status or when it is being destructed.
-    bool SetModalElement(UIElement* modalElement, bool enable);
     /// Clear the UI (excluding the cursor.)
     /// Clear the UI (excluding the cursor.)
     void Clear();
     void Clear();
     /// Update the UI logic. Called by HandlePostUpdate().
     /// Update the UI logic. Called by HandlePostUpdate().
@@ -82,19 +79,13 @@ public:
     /// Set UI drag event start distance threshold in pixels.
     /// Set UI drag event start distance threshold in pixels.
     void SetDragBeginDistance(int pixels);
     void SetDragBeginDistance(int pixels);
     /// Set tooltip default display delay in seconds.
     /// Set tooltip default display delay in seconds.
-    void SetDefaultToolTipDelay(float delay);
-    /// Set maximum font face texture size. Must be a power of two. Default is 2048.
-    void SetMaxFontTextureSize(int size);
+    void SetDefaultToolTipDelay(float delay);    
     /// Set whether mouse wheel can control also a non-focused element.
     /// Set whether mouse wheel can control also a non-focused element.
     void SetNonFocusedMouseWheel(bool nonFocusedMouseWheel);
     void SetNonFocusedMouseWheel(bool nonFocusedMouseWheel);
     /// Set whether to use system clipboard. Default false.
     /// Set whether to use system clipboard. Default false.
     void SetUseSystemClipboard(bool enable);
     void SetUseSystemClipboard(bool enable);
     /// Set whether to show the on-screen keyboard (if supported) when a %LineEdit is focused. Default true on mobile devices.
     /// Set whether to show the on-screen keyboard (if supported) when a %LineEdit is focused. Default true on mobile devices.
     void SetUseScreenKeyboard(bool enable);
     void SetUseScreenKeyboard(bool enable);
-    /// Set whether to use mutable (eraseable) glyphs to ensure a font face never expands to more than one texture. Default false.
-    void SetUseMutableGlyphs(bool enable);
-    /// Set whether to force font autohinting instead of using FreeType's TTF bytecode interpreter.
-    void SetForceAutoHint(bool enable);
 
 
     /// Return root UI element.
     /// Return root UI element.
     UIElement* GetRoot() const { return rootElement_; }
     UIElement* GetRoot() const { return rootElement_; }
@@ -181,8 +172,6 @@ private:
     void GetCursorPositionAndVisible(IntVector2& pos, bool& visible);
     void GetCursorPositionAndVisible(IntVector2& pos, bool& visible);
     /// Set active cursor's shape.
     /// Set active cursor's shape.
     void SetCursorShape(CursorShape shape);
     void SetCursorShape(CursorShape shape);
-    /// Force release of font faces when global font properties change.
-    void ReleaseFontFaces();
     /// Handle button or touch hover
     /// Handle button or touch hover
     void ProcessHover(const IntVector2& cursorPos, int buttons, int qualifiers, Cursor* cursor);
     void ProcessHover(const IntVector2& cursorPos, int buttons, int qualifiers, Cursor* cursor);
     /// Handle button or touch begin.
     /// Handle button or touch begin.

+ 0 - 174
Source/Atomic/UI/View3D.cpp

@@ -1,174 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../Graphics/Camera.h"
-#include "../Graphics/Graphics.h"
-#include "../Graphics/Octree.h"
-#include "../Scene/Scene.h"
-#include "../Graphics/Texture2D.h"
-#include "../Graphics/Viewport.h"
-#include "../UI/View3D.h"
-#include "../UI/UI.h"
-#include "../UI/UIEvents.h"
-#include "../Graphics/Zone.h"
-
-namespace Atomic
-{
-
-extern const char* UI_CATEGORY;
-
-View3D::View3D(Context* context) :
-    Window(context),
-    ownScene_(true),
-    rttFormat_(Graphics::GetRGBFormat()),
-    autoUpdate_(true)
-{
-    renderTexture_ = new Texture2D(context_);
-    depthTexture_ = new Texture2D(context_);
-    viewport_ = new Viewport(context_);
-}
-
-View3D::~View3D()
-{
-    ResetScene();
-}
-
-void View3D::RegisterObject(Context* context)
-{
-    context->RegisterFactory<View3D>(UI_CATEGORY);
-
-    COPY_BASE_ATTRIBUTES(Window);
-    // The texture format is API specific, so do not register it as a serializable attribute
-    ACCESSOR_ATTRIBUTE("Auto Update", GetAutoUpdate, SetAutoUpdate, bool, true, AM_FILE);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Clip Children", true);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Is Enabled", true);
-}
-
-void View3D::OnResize()
-{
-    int width = GetWidth();
-    int height = GetHeight();
-    
-    if (width > 0 && height > 0)
-    {
-        renderTexture_->SetSize(width, height, rttFormat_, TEXTURE_RENDERTARGET);
-        depthTexture_->SetSize(width, height, Graphics::GetDepthStencilFormat(), TEXTURE_DEPTHSTENCIL);
-        RenderSurface* surface = renderTexture_->GetRenderSurface();
-        surface->SetViewport(0, viewport_);
-        surface->SetUpdateMode(autoUpdate_ ? SURFACE_UPDATEALWAYS : SURFACE_MANUALUPDATE);
-        surface->SetLinkedDepthStencil(depthTexture_->GetRenderSurface());
-        
-        SetTexture(renderTexture_);
-        SetImageRect(IntRect(0, 0, width, height));
-
-        if (!autoUpdate_)
-            surface->QueueUpdate();
-    }
-}
-
-void View3D::SetView(Scene* scene, Camera* camera, bool ownScene)
-{
-    ResetScene();
-    
-    scene_ = scene;
-    cameraNode_ = camera ? camera->GetNode() : 0;
-    ownScene_ = ownScene;
-
-    viewport_->SetScene(scene_);
-    viewport_->SetCamera(camera);
-    QueueUpdate();
-}
-
-void View3D::SetFormat(unsigned format)
-{
-    if (format != rttFormat_)
-    {
-        rttFormat_ = format;
-        OnResize();
-    }
-}
-
-void View3D::SetAutoUpdate(bool enable)
-{
-    if (enable != autoUpdate_)
-    {
-        autoUpdate_ = enable;
-        RenderSurface* surface = renderTexture_->GetRenderSurface();
-        if (surface)
-            surface->SetUpdateMode(autoUpdate_ ? SURFACE_UPDATEALWAYS : SURFACE_MANUALUPDATE);
-    }
-}
-
-void View3D::QueueUpdate()
-{
-    if (!autoUpdate_)
-    {
-        RenderSurface* surface = renderTexture_->GetRenderSurface();
-        if (surface)
-            surface->QueueUpdate();
-    }
-}
-
-Scene* View3D::GetScene() const
-{
-    return scene_;
-}
-
-Node* View3D::GetCameraNode() const
-{
-    return cameraNode_;
-}
-
-Texture2D* View3D::GetRenderTexture() const
-{
-    return renderTexture_;
-}
-
-Texture2D* View3D::GetDepthTexture() const
-{
-    return depthTexture_;
-}
-
-Viewport* View3D::GetViewport() const
-{
-    return viewport_;
-}
-
-void View3D::ResetScene()
-{
-    if (!scene_)
-        return;
-
-    if (!ownScene_)
-    {
-        RefCount* refCount = scene_->RefCountPtr();
-        ++refCount->refs_;
-        scene_ = 0;
-        --refCount->refs_;
-    }
-    else
-        scene_ = 0;
-}
-
-}

+ 0 - 98
Source/Atomic/UI/View3D.h

@@ -1,98 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/Window.h"
-
-namespace Atomic
-{
-
-class Camera;
-class Node;
-class Scene;
-class Texture2D;
-class Viewport;
-
-/// %UI element which renders a 3D scene.
-class ATOMIC_API View3D : public Window
-{
-    OBJECT(View3D);
-
-public:
-    /// Construct.
-    View3D(Context* context);
-    /// Destruct.
-    ~View3D();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// React to resize.
-    virtual void OnResize();
-
-    /// Define the scene and camera to use in rendering. When ownScene is true the View3D will take ownership of them with shared pointers.
-    void SetView(Scene* scene, Camera* camera, bool ownScene = true);
-    /// Set render texture pixel format. Default is RGB.
-    void SetFormat(unsigned format);
-    /// Set render target auto update mode. Default is true.
-    void SetAutoUpdate(bool enable);
-    /// Queue manual update on the render texture.
-    void QueueUpdate();
-    
-    /// Return render texture pixel format.
-    unsigned GetFormat() const { return rttFormat_; }
-    /// Return whether render target updates automatically.
-    bool GetAutoUpdate() const { return autoUpdate_; }
-    /// Return scene.
-    Scene* GetScene() const;
-    /// Return camera scene node.
-    Node* GetCameraNode() const;
-    /// Return render texture.
-    Texture2D* GetRenderTexture() const;
-    /// Return depth stencil texture.
-    Texture2D* GetDepthTexture() const;
-    /// Return viewport.
-    Viewport* GetViewport() const;
-    
-private:
-    /// Reset scene.
-    void ResetScene();
-
-    /// Renderable texture.
-    SharedPtr<Texture2D> renderTexture_;
-    /// Depth stencil texture.
-    SharedPtr<Texture2D> depthTexture_;
-    /// Viewport.
-    SharedPtr<Viewport> viewport_;
-    /// Scene.
-    SharedPtr<Scene> scene_;
-    /// Camera scene node.
-    SharedPtr<Node> cameraNode_;
-    /// Own scene.
-    bool ownScene_;
-    /// Render texture format.
-    unsigned rttFormat_;
-    /// Render texture auto update mode.
-    bool autoUpdate_;
-};
-
-}

+ 0 - 415
Source/Atomic/UI/Window.cpp

@@ -1,415 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "Precompiled.h"
-#include "../Core/Context.h"
-#include "../UI/Cursor.h"
-#include "../Input/InputEvents.h"
-#include "../UI/UI.h"
-#include "../UI/UIEvents.h"
-#include "../UI/Window.h"
-
-#include "../DebugNew.h"
-
-namespace Atomic
-{
-
-static const int DEFAULT_RESIZE_BORDER = 4;
-
-extern const char* UI_CATEGORY;
-
-Window::Window(Context* context) :
-    BorderImage(context),
-    movable_(false),
-    resizable_(false),
-    fixedWidthResizing_(false),
-    fixedHeightResizing_(false),
-    resizeBorder_(DEFAULT_RESIZE_BORDER, DEFAULT_RESIZE_BORDER, DEFAULT_RESIZE_BORDER, DEFAULT_RESIZE_BORDER),
-    dragMode_(DRAG_NONE),
-    modal_(false),
-    modalAutoDismiss_(true),
-    modalShadeColor_(Color::TRANSPARENT),
-    modalFrameColor_(Color::TRANSPARENT),
-    modalFrameSize_(IntVector2::ZERO)
-
-{
-    bringToFront_ = true;
-    clipChildren_ = true;
-    SetEnabled(true);
-}
-
-Window::~Window()
-{
-}
-
-void Window::RegisterObject(Context* context)
-{
-    context->RegisterFactory<Window>(UI_CATEGORY);
-
-    COPY_BASE_ATTRIBUTES(BorderImage);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Bring To Front", true);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Clip Children", true);
-    UPDATE_ATTRIBUTE_DEFAULT_VALUE("Is Enabled", true);
-    ACCESSOR_ATTRIBUTE("Resize Border", GetResizeBorder, SetResizeBorder, IntRect, IntRect(DEFAULT_RESIZE_BORDER, \
-        DEFAULT_RESIZE_BORDER, DEFAULT_RESIZE_BORDER, DEFAULT_RESIZE_BORDER), AM_FILE);
-    ACCESSOR_ATTRIBUTE("Is Movable", IsMovable, SetMovable, bool, false, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Is Resizable", IsResizable, SetResizable, bool, false, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Fixed Width Resizing", GetFixedWidthResizing, SetFixedWidthResizing, bool, false, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Fixed Height Resizing", GetFixedHeightResizing, SetFixedHeightResizing, bool, false, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Is Modal", IsModal, SetModal, bool, false, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Modal Shade Color", GetModalShadeColor, SetModalShadeColor, Color, Color::TRANSPARENT, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Modal Frame Color", GetModalFrameColor, SetModalFrameColor, Color, Color::TRANSPARENT, AM_FILE);
-    ACCESSOR_ATTRIBUTE("Modal Frame Size", GetModalFrameSize, SetModalFrameSize, IntVector2, IntVector2::ZERO, AM_FILE);
-    // Modal auto dismiss is purposefully not an attribute, as using it can make the editor lock up.
-    // Instead it should be set false in code when needed
-}
-
-void Window::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor)
-{
-    if (modal_)
-    {
-        // Modal shade
-        if (modalShadeColor_ != Color::TRANSPARENT)
-        {
-            UIElement* rootElement = GetRoot();
-            const IntVector2& rootSize = rootElement->GetSize();
-            UIBatch batch(rootElement, BLEND_ALPHA, IntRect(0, 0, rootSize.x_, rootSize.y_), 0, &vertexData);
-            batch.SetColor(modalShadeColor_);
-            batch.AddQuad(0, 0, rootSize.x_, rootSize.y_, 0, 0);
-            UIBatch::AddOrMerge(batch, batches);
-        }
-
-        // Modal frame
-        if (modalFrameColor_ != Color::TRANSPARENT && modalFrameSize_ != IntVector2::ZERO)
-        {
-            UIBatch batch(this, BLEND_ALPHA, currentScissor, 0, &vertexData);
-            int x = GetIndentWidth();
-            IntVector2 size = GetSize();
-            size.x_ -= x;
-            batch.SetColor(modalFrameColor_);
-            batch.AddQuad(x - modalFrameSize_.x_, -modalFrameSize_.y_, size.x_ + 2 * modalFrameSize_.x_, size.y_ + 2 * modalFrameSize_.y_, 0, 0);
-            UIBatch::AddOrMerge(batch, batches);
-        }
-    }
-
-    BorderImage::GetBatches(batches, vertexData, currentScissor);
-}
-
-void Window::OnHover(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
-{
-    UIElement::OnHover(position, screenPosition, buttons, qualifiers, cursor);
-
-    if (dragMode_ == DRAG_NONE)
-    {
-        WindowDragMode mode = GetDragMode(position);
-        SetCursorShape(mode, cursor);
-    }
-    else
-        SetCursorShape(dragMode_, cursor);
-}
-
-void Window::OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
-{
-    UIElement::OnDragBegin(position, screenPosition, buttons, qualifiers, cursor);
-
-    if (buttons != MOUSEB_LEFT || !CheckAlignment())
-    {
-        dragMode_ = DRAG_NONE;
-        return;
-    }
-
-    dragBeginCursor_ = screenPosition;
-    dragBeginPosition_ = GetPosition();
-    dragBeginSize_ = GetSize();
-    dragMode_ = GetDragMode(position);
-    SetCursorShape(dragMode_, cursor);
-}
-
-void Window::OnDragMove(const IntVector2& position, const IntVector2& screenPosition, const IntVector2& deltaPos, int buttons, int qualifiers, Cursor* cursor)
-{
-    if (dragMode_ == DRAG_NONE)
-        return;
-
-    IntVector2 delta = screenPosition - dragBeginCursor_;
-    IntVector2 dragSize;
-    IntVector2 resizeBorderSize(resizeBorder_.left_ + resizeBorder_.right_, resizeBorder_.top_ + resizeBorder_.bottom_);
-
-    const IntVector2& position_ = GetPosition();
-    const IntVector2& size_ = GetSize();
-    const IntVector2& minSize_ = GetMinSize();
-    const IntVector2& maxSize_ = GetMaxSize();
-
-    switch (dragMode_)
-    {
-    case DRAG_MOVE:
-        SetPosition(dragBeginPosition_ + delta);
-        break;
-
-    case DRAG_RESIZE_TOPLEFT:
-        SetPosition(Clamp(dragBeginPosition_.x_ + delta.x_, position_.x_ - (maxSize_.x_ - size_.x_), position_.x_ + (size_.x_ - minSize_.x_)),
-            Clamp(dragBeginPosition_.y_ + delta.y_, position_.y_ - (maxSize_.y_ - size_.y_), position_.y_ + (size_.y_ - minSize_.y_)));
-        dragSize = dragBeginSize_ - delta;
-        fixedWidthResizing_ ? SetFixedWidth(Max(dragSize.x_, resizeBorderSize.x_)) : SetWidth(dragSize.x_);
-        fixedHeightResizing_ ? SetFixedHeight(Max(dragSize.y_, resizeBorderSize.y_)) : SetHeight(dragSize.y_);
-        break;
-
-    case DRAG_RESIZE_TOP:
-        SetPosition(dragBeginPosition_.x_, Clamp(dragBeginPosition_.y_ + delta.y_, position_.y_ - (maxSize_.y_ - size_.y_), position_.y_ + (size_.y_ - minSize_.y_)));
-        dragSize = IntVector2(dragBeginSize_.x_, dragBeginSize_.y_ - delta.y_);
-        fixedHeightResizing_ ? SetFixedHeight(Max(dragSize.y_, resizeBorderSize.y_)) : SetHeight(dragSize.y_);
-        break;
-
-    case DRAG_RESIZE_TOPRIGHT:
-        SetPosition(dragBeginPosition_.x_, Clamp(dragBeginPosition_.y_ + delta.y_, position_.y_ - (maxSize_.y_ - size_.y_), position_.y_ + (size_.y_ - minSize_.y_)));
-        dragSize = IntVector2(dragBeginSize_.x_ + delta.x_, dragBeginSize_.y_ - delta.y_);
-        fixedWidthResizing_ ? SetFixedWidth(Max(dragSize.x_, resizeBorderSize.x_)) : SetWidth(dragSize.x_);
-        fixedHeightResizing_ ? SetFixedHeight(Max(dragSize.y_, resizeBorderSize.y_)) : SetHeight(dragSize.y_);
-        break;
-
-    case DRAG_RESIZE_RIGHT:
-        dragSize = IntVector2(dragBeginSize_.x_ + delta.x_, dragBeginSize_.y_);
-        fixedWidthResizing_ ? SetFixedWidth(Max(dragSize.x_, resizeBorderSize.x_)) : SetWidth(dragSize.x_);
-        break;
-
-    case DRAG_RESIZE_BOTTOMRIGHT:
-        dragSize = dragBeginSize_ + delta;
-        fixedWidthResizing_ ? SetFixedWidth(Max(dragSize.x_, resizeBorderSize.x_)) : SetWidth(dragSize.x_);
-        fixedHeightResizing_ ? SetFixedHeight(Max(dragSize.y_, resizeBorderSize.y_)) : SetHeight(dragSize.y_);
-        break;
-
-    case DRAG_RESIZE_BOTTOM:
-        dragSize = IntVector2(dragBeginSize_.x_, dragBeginSize_.y_ + delta.y_);
-        fixedHeightResizing_ ? SetFixedHeight(Max(dragSize.y_, resizeBorderSize.y_)) : SetHeight(dragSize.y_);
-        break;
-
-    case DRAG_RESIZE_BOTTOMLEFT:
-        SetPosition(Clamp(dragBeginPosition_.x_ + delta.x_, position_.x_ - (maxSize_.x_ - size_.x_), position_.x_ + (size_.x_ - minSize_.x_)), dragBeginPosition_.y_);
-        dragSize = IntVector2(dragBeginSize_.x_ - delta.x_, dragBeginSize_.y_ + delta.y_);
-        fixedWidthResizing_ ? SetFixedWidth(Max(dragSize.x_, resizeBorderSize.x_)) : SetWidth(dragSize.x_);
-        fixedHeightResizing_ ? SetFixedHeight(Max(dragSize.y_, resizeBorderSize.y_)) : SetHeight(dragSize.y_);
-        break;
-
-    case DRAG_RESIZE_LEFT:
-        SetPosition(Clamp(dragBeginPosition_.x_ + delta.x_, position_.x_ - (maxSize_.x_ - size_.x_), position_.x_ + (size_.x_ - minSize_.x_)), dragBeginPosition_.y_);
-        dragSize = IntVector2(dragBeginSize_.x_ - delta.x_, dragBeginSize_.y_);
-        fixedWidthResizing_ ? SetFixedWidth(Max(dragSize.x_, resizeBorderSize.x_)) : SetWidth(dragSize.x_);
-        break;
-
-    default:
-        break;
-    }
-
-    ValidatePosition();
-    SetCursorShape(dragMode_, cursor);
-}
-
-void Window::OnDragEnd(const IntVector2& position, const IntVector2& screenPosition, int dragButtons, int buttons, Cursor* cursor)
-{
-    UIElement::OnDragEnd(position, screenPosition, dragButtons, buttons, cursor);
-
-    dragMode_ = DRAG_NONE;
-}
-
-void Window::OnDragCancel(const IntVector2& position, const IntVector2& screenPosition, int dragButtons, int buttons, Cursor* cursor)
-{
-    UIElement::OnDragCancel(position, screenPosition, dragButtons, buttons, cursor);
-
-    if (dragButtons == MOUSEB_LEFT)
-    {
-        dragMode_ = DRAG_NONE;
-        SetPosition(dragBeginPosition_);
-        SetSize(dragBeginSize_);
-    }
-}
-
-void Window::SetMovable(bool enable)
-{
-    movable_ = enable;
-}
-
-void Window::SetResizable(bool enable)
-{
-    resizable_ = enable;
-}
-
-void Window::SetFixedWidthResizing(bool enable)
-{
-    fixedWidthResizing_ = enable;
-}
-
-void Window::SetFixedHeightResizing(bool enable)
-{
-    fixedHeightResizing_ = enable;
-}
-
-void Window::SetResizeBorder(const IntRect& rect)
-{
-    resizeBorder_.left_ = Max(rect.left_, 0);
-    resizeBorder_.top_ = Max(rect.top_, 0);
-    resizeBorder_.right_ = Max(rect.right_, 0);
-    resizeBorder_.bottom_ = Max(rect.bottom_, 0);
-}
-
-void Window::SetModal(bool modal)
-{
-    if (GetSubsystem<UI>()->SetModalElement(this, modal))
-    {
-        modal_ = modal;
-
-        using namespace ModalChanged;
-
-        VariantMap& eventData = GetEventDataMap();
-        eventData[P_ELEMENT] = this;
-        eventData[P_MODAL] = modal;
-        SendEvent(E_MODALCHANGED, eventData);
-    }
-}
-
-void Window::SetModalShadeColor(const Color& color)
-{
-    modalShadeColor_ = color;
-}
-
-void Window::SetModalFrameColor(const Color& color)
-{
-    modalFrameColor_ = color;
-}
-
-void Window::SetModalFrameSize(const IntVector2& size)
-{
-    modalFrameSize_ = size;
-}
-
-void Window::SetModalAutoDismiss(bool enable)
-{
-    modalAutoDismiss_ = enable;
-}
-
-WindowDragMode Window::GetDragMode(const IntVector2& position) const
-{
-    WindowDragMode mode = DRAG_NONE;
-
-    // Top row
-    if (position.y_ < resizeBorder_.top_)
-    {
-        if (movable_)
-            mode = DRAG_MOVE;
-        if (resizable_)
-        {
-            mode = DRAG_RESIZE_TOP;
-            if (position.x_ < resizeBorder_.left_)
-                mode = DRAG_RESIZE_TOPLEFT;
-            if (position.x_ >= GetWidth() - resizeBorder_.right_)
-                mode = DRAG_RESIZE_TOPRIGHT;
-        }
-    }
-    // Bottom row
-    else if (position.y_ >= GetHeight() - resizeBorder_.bottom_)
-    {
-        if (movable_)
-            mode = DRAG_MOVE;
-        if (resizable_)
-        {
-            mode = DRAG_RESIZE_BOTTOM;
-            if (position.x_ < resizeBorder_.left_)
-                mode = DRAG_RESIZE_BOTTOMLEFT;
-            if (position.x_ >= GetWidth() - resizeBorder_.right_)
-                mode = DRAG_RESIZE_BOTTOMRIGHT;
-        }
-    }
-    // Middle
-    else
-    {
-        if (movable_)
-            mode = DRAG_MOVE;
-        if (resizable_)
-        {
-            if (position.x_ < resizeBorder_.left_)
-                mode = DRAG_RESIZE_LEFT;
-            if (position.x_ >= GetWidth() - resizeBorder_.right_)
-                mode = DRAG_RESIZE_RIGHT;
-        }
-    }
-
-    return mode;
-}
-
-void Window::SetCursorShape(WindowDragMode mode, Cursor* cursor) const
-{
-    CursorShape shape = CS_NORMAL;
-
-    switch (mode)
-    {
-    case DRAG_RESIZE_TOP:
-    case DRAG_RESIZE_BOTTOM:
-        shape = CS_RESIZEVERTICAL;
-        break;
-
-    case DRAG_RESIZE_LEFT:
-    case DRAG_RESIZE_RIGHT:
-        shape = CS_RESIZEHORIZONTAL;
-        break;
-
-    case DRAG_RESIZE_TOPRIGHT:
-    case DRAG_RESIZE_BOTTOMLEFT:
-        shape = CS_RESIZEDIAGONAL_TOPRIGHT;
-        break;
-
-    case DRAG_RESIZE_TOPLEFT:
-    case DRAG_RESIZE_BOTTOMRIGHT:
-        shape = CS_RESIZEDIAGONAL_TOPLEFT;
-        break;
-
-    default:
-        break;
-    }
-
-    if (cursor)
-        cursor->SetShape(shape);
-}
-
-void Window::ValidatePosition()
-{
-    // Check that window does not go more than halfway outside its parent in either dimension
-    if (!parent_)
-        return;
-
-    const IntVector2& parentSize = parent_->GetSize();
-    IntVector2 position = GetPosition();
-    IntVector2 halfSize = GetSize() / 2;
-
-    position.x_ = Clamp(position.x_, -halfSize.x_, parentSize.x_ - halfSize.x_);
-    position.y_ = Clamp(position.y_, -halfSize.y_, parentSize.y_ - halfSize.y_);
-
-    SetPosition(position);
-}
-
-bool Window::CheckAlignment() const
-{
-    // Only top left-alignment is supported for move and resize
-    if (GetHorizontalAlignment() == HA_LEFT && GetVerticalAlignment() == VA_TOP)
-        return true;
-    else
-        return false;
-}
-
-}

+ 0 - 154
Source/Atomic/UI/Window.h

@@ -1,154 +0,0 @@
-//
-// Copyright (c) 2008-2014 the Urho3D project.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "../UI/BorderImage.h"
-
-namespace Atomic
-{
-
-/// %Window movement and resizing modes.
-enum WindowDragMode
-{
-    DRAG_NONE,
-    DRAG_MOVE,
-    DRAG_RESIZE_TOPLEFT,
-    DRAG_RESIZE_TOP,
-    DRAG_RESIZE_TOPRIGHT,
-    DRAG_RESIZE_RIGHT,
-    DRAG_RESIZE_BOTTOMRIGHT,
-    DRAG_RESIZE_BOTTOM,
-    DRAG_RESIZE_BOTTOMLEFT,
-    DRAG_RESIZE_LEFT
-};
-
-/// %Window %UI element that can optionally by moved or resized.
-class ATOMIC_API Window : public BorderImage
-{
-    OBJECT(Window);
-
-public:
-    /// Construct.
-    Window(Context* context);
-    /// Destruct.
-    virtual ~Window();
-    /// Register object factory.
-    static void RegisterObject(Context* context);
-
-    /// Return UI rendering batches.
-    virtual void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
-
-    /// React to mouse hover.
-    virtual void OnHover(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse drag begin.
-    virtual void OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse drag motion.
-    virtual void OnDragMove(const IntVector2& position, const IntVector2& screenPosition, const IntVector2& deltaPos, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse drag end.
-    virtual void OnDragEnd(const IntVector2& position, const IntVector2& screenPosition, int dragButtons, int buttons, Cursor* cursor);
-    /// React to mouse drag cancel.
-    virtual void OnDragCancel(const IntVector2& position, const IntVector2& screenPosition, int dragButtons, int buttons, Cursor* cursor);
-
-    /// Set whether can be moved.
-    void SetMovable(bool enable);
-    /// Set whether can be resized.
-    void SetResizable(bool enable);
-    /// Set whether resizing width is fixed.
-    void SetFixedWidthResizing(bool enable);
-    /// Set whether resizing height is fixed.
-    void SetFixedHeightResizing(bool enable);
-    /// Set resize area width at edges.
-    void SetResizeBorder(const IntRect& rect);
-    /// Set modal flag. When the modal flag is set, the focused window needs to be dismissed first to allow other UI elements to gain focus.
-    void SetModal(bool modal);
-    /// Set modal shade color.
-    void SetModalShadeColor(const Color& color);
-    /// Set modal frame color.
-    void SetModalFrameColor(const Color& color);
-    /// Set modal frame size.
-    void SetModalFrameSize(const IntVector2& size);
-    /// Set whether model window can be dismissed with the escape key. Default true.
-    void SetModalAutoDismiss(bool enable);
-
-    /// Return whether is movable.
-    bool IsMovable() const { return movable_; }
-    /// Return whether is resizable.
-    bool IsResizable() const { return resizable_; }
-    /// Return whether is resizing width is fixed.
-    bool GetFixedWidthResizing() const { return fixedWidthResizing_; }
-    /// Return whether is resizing height is fixed.
-    bool GetFixedHeightResizing() const { return fixedHeightResizing_; }
-    /// Return resize area width at edges.
-    const IntRect& GetResizeBorder() const { return resizeBorder_; }
-    /// Return modal flag.
-    bool IsModal() const { return modal_; }
-    /// Get modal shade color.
-    const Color& GetModalShadeColor() const { return modalShadeColor_; }
-    /// Get modal frame color.
-    const Color& GetModalFrameColor() const { return modalFrameColor_; }
-    /// Get modal frame size.
-    const IntVector2& GetModalFrameSize() const { return modalFrameSize_; }
-    /// Return whether can be dismissed with escape key.
-    bool GetModalAutoDismiss() const { return modalAutoDismiss_; }
-
-protected:
-    /// Identify drag mode (move/resize.)
-    WindowDragMode GetDragMode(const IntVector2& position) const;
-    /// Set cursor shape based on drag mode.
-    void SetCursorShape(WindowDragMode mode, Cursor* cursor) const;
-    /// Validate window position.
-    void ValidatePosition();
-    /// Check whether alignment supports moving and resizing.
-    bool CheckAlignment() const;
-
-    /// Movable flag.
-    bool movable_;
-    /// Resizable flag.
-    bool resizable_;
-    /// Fixed width resize flag.
-    bool fixedWidthResizing_;
-    /// Fixed height resize flag.
-    bool fixedHeightResizing_;
-    /// Resize area width at edges.
-    IntRect resizeBorder_;
-    /// Current drag mode.
-    WindowDragMode dragMode_;
-    /// Mouse position at drag begin.
-    IntVector2 dragBeginCursor_;
-    /// Original position at drag begin.
-    IntVector2 dragBeginPosition_;
-    /// Original size at drag begin.
-    IntVector2 dragBeginSize_;
-    /// Modal flag.
-    bool modal_;
-    /// Modal auto dismiss (with escape key) flag. Default true.
-    bool modalAutoDismiss_;
-    /// Modal shade color, used when modal flag is set.
-    Color modalShadeColor_;
-    /// Modal frame color, used when modal flag is set.
-    Color modalFrameColor_;
-    /// Modal frame size, used when modal flag is set.
-    IntVector2 modalFrameSize_;
-};
-
-}

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

@@ -83,15 +83,6 @@ void AEApplication::Start()
 
 
     XMLFile* xmlFile = cache->GetResource<XMLFile>("UI/DefaultStyle.xml");
     XMLFile* xmlFile = cache->GetResource<XMLFile>("UI/DefaultStyle.xml");
 
 
-    // Create console
-    Console* console = engine_->CreateConsole();
-    console->SetDefaultStyle(xmlFile);
-    console->GetBackground()->SetOpacity(0.8f);
-
-    // Create debug HUD.
-    DebugHud* debugHud = engine_->CreateDebugHud();
-    debugHud->SetDefaultStyle(xmlFile);
-
     Input* input = GetSubsystem<Input>();
     Input* input = GetSubsystem<Input>();
 
 
     input->SetMouseVisible(true);
     input->SetMouseVisible(true);

+ 0 - 210
Source/AtomicEditor/Source/Editors/ModelResourceEditor.cpp

@@ -25,7 +25,6 @@
 
 
 #include <Atomic/UI/TBUI.h>
 #include <Atomic/UI/TBUI.h>
 #include <Atomic/UI/UI.h>
 #include <Atomic/UI/UI.h>
-#include <Atomic/UI/View3D.h>
 
 
 namespace AtomicEditor
 namespace AtomicEditor
 {
 {
@@ -37,99 +36,6 @@ ModelResourceEditor ::ModelResourceEditor(Context* context, const String &fullpa
     yaw_(0.0f),
     yaw_(0.0f),
     pitch_(0.0f)
     pitch_(0.0f)
 {
 {
-    layout_ = new TBLayout();
-    layout_->SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY);
-    layout_->SetLayoutSize(LAYOUT_SIZE_AVAILABLE);
-    layout_->SetSize(container_->GetRect().w, container_->GetRect().h);
-
-    view3DContainer_ = new TBContainer();
-    view3DContainer_->SetGravity(WIDGET_GRAVITY_ALL);
-
-    TBLayout* verticalLayout = new TBLayout();
-    verticalLayout->SetAxis(AXIS_Y);
-    verticalLayout->SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY);
-
-    TBButton* button = new TBButton();
-    button->SetText("Idle");
-    button->SetID(TBIDC("Idle"));
-    button->SetGravity(WIDGET_GRAVITY_LEFT_RIGHT);
-    verticalLayout->AddChild(button);
-    button = new TBButton();
-    button->SetText("Walk");
-    button->SetGravity(WIDGET_GRAVITY_LEFT_RIGHT);
-    button->SetID(TBIDC("Walk"));
-    verticalLayout->AddChild(button);
-    button = new TBButton();
-    button->SetText("Run");
-    button->SetGravity(WIDGET_GRAVITY_LEFT_RIGHT);
-    button->SetID(TBIDC("Run"));
-    verticalLayout->AddChild(button);
-    button = new TBButton();
-    button->SetText("Turn Left");
-    button->SetGravity(WIDGET_GRAVITY_LEFT_RIGHT);
-    button->SetID(TBIDC("TurnLeft"));
-    verticalLayout->AddChild(button);
-    button = new TBButton();
-    button->SetText("Turn Right");
-    button->SetGravity(WIDGET_GRAVITY_LEFT_RIGHT);
-    button->SetID(TBIDC("TurnRight"));
-    verticalLayout->AddChild(button);
-    button = new TBButton();
-    button->SetText("Walk Backwards");
-    button->SetGravity(WIDGET_GRAVITY_LEFT_RIGHT);
-    button->SetID(TBIDC("WalkBackwards"));
-    verticalLayout->AddChild(button);
-    button = new TBButton();
-    button->SetText("Attack");
-    button->SetGravity(WIDGET_GRAVITY_LEFT_RIGHT);
-    button->SetID(TBIDC("Attack"));
-    verticalLayout->AddChild(button);
-
-    layout_->AddChild(view3DContainer_);
-    layout_->AddChild(verticalLayout);
-
-    container_->GetContentRoot()->AddChild(layout_);
-
-    ResourceCache* cache = GetSubsystem<ResourceCache>();
-
-    scene_ = new Scene(context_);
-
-    scene_ = new Scene(context_);
-    scene_->CreateComponent<Octree>();
-    scene_->CreateComponent<DebugRenderer>();
-
-    Node* zoneNode = scene_->CreateChild("Zone");
-    Zone* zone = zoneNode->CreateComponent<Zone>();
-    zone->SetBoundingBox(BoundingBox(-10000.0f, 10000.f));
-    zone->SetAmbientColor(Color(1, 1, 1));
-
-    cameraNode_ = scene_->CreateChild("Camera");
-    camera_ = cameraNode_->CreateComponent<Camera>();
-
-    cameraNode_->SetPosition(Vector3(0.0f, .9f, -2.75f));
-
-    // Create a smaller box at camera position
-    modelNode_ = scene_->CreateChild("ModelNode");
-
-    AnimatedModel* amodel = modelNode_->CreateComponent<AnimatedModel>();
-    Model* model = cache->GetResource<Model>("Models/AS_FatZombie_FBX_FatZombie_LOD0.mdl");
-    amodel->SetModel(model);
-    amodel->SetMaterial(cache->GetResource<Material>("Materials/AS_FatZombie_Base.xml"));
-    amodel->SetCastShadows(true);
-
-    AnimationController* controller = modelNode_->CreateComponent<AnimationController>();
-    controller->PlayExclusive("Models/AS_FatZombie_FBX_FatZombie_LOD0_Idle.ani", 0, true);
-
-    modelNode_->Yaw(180);
-
-    view3D_ = new View3D(context_);
-    view3D_->SetView(scene_, camera_);
-    view3D_->SetAutoUpdate(false);
-
-    GetSubsystem<TBUI>()->AddChild(view3D_);
-
-    SubscribeToEvent(E_UPDATE, HANDLER(ModelResourceEditor, HandleUpdate));
-
 }
 }
 
 
 ModelResourceEditor::~ModelResourceEditor()
 ModelResourceEditor::~ModelResourceEditor()
@@ -139,135 +45,19 @@ ModelResourceEditor::~ModelResourceEditor()
 
 
 bool ModelResourceEditor::OnEvent(const TBWidgetEvent &ev)
 bool ModelResourceEditor::OnEvent(const TBWidgetEvent &ev)
 {
 {
-    if (ev.type == EVENT_TYPE_CLICK)
-    {
-        AnimationController* controller = modelNode_->GetComponent<AnimationController>();
-
-        if (ev.target->GetID() == TBIDC("Walk"))
-        {
-            controller->PlayExclusive("Models/AS_FatZombie_FBX_FatZombie_LOD0_Walk.ani", 0.0f, true);
-        }
-        else if (ev.target->GetID() == TBIDC("Run"))
-        {
-            controller->PlayExclusive("Models/AS_FatZombie_FBX_FatZombie_LOD0_Run.ani", 0.0f, true);
-        }
-        else if (ev.target->GetID() == TBIDC("Idle"))
-        {
-            controller->PlayExclusive("Models/AS_FatZombie_FBX_FatZombie_LOD0_Idle.ani", 0.0f, true);
-        }
-        else if (ev.target->GetID() == TBIDC("TurnLeft"))
-        {
-            controller->PlayExclusive("Models/AS_FatZombie_FBX_FatZombie_LOD0_Turn_Left.ani", 0.0f, true);
-        }
-        else if (ev.target->GetID() == TBIDC("TurnRight"))
-        {
-            controller->PlayExclusive("Models/AS_FatZombie_FBX_FatZombie_LOD0_Turn_Right.ani", 0.0f, true);
-        }
-        else if (ev.target->GetID() == TBIDC("WalkBackwards"))
-        {
-            controller->PlayExclusive("Models/AS_FatZombie_FBX_FatZombie_LOD0_Walk_Backwards.ani", 0.0f, true);
-        }
-        else if (ev.target->GetID() == TBIDC("Attack"))
-        {
-            controller->PlayExclusive("Models/AS_FatZombie_FBX_FatZombie_LOD0_Attack_Melee.ani", 0.0f, true);
-        }
 
 
-    }
     return false;
     return false;
 }
 }
 
 
 void ModelResourceEditor::MoveCamera(float timeStep)
 void ModelResourceEditor::MoveCamera(float timeStep)
 {
 {
-    // Do not move if the UI has a focused element (the console)
-    if (GetSubsystem<UI>()->GetFocusElement())
-        return;
-
-    Input* input = GetSubsystem<Input>();
-
-    // Movement speed as world units per second
-    const float MOVE_SPEED = 1.5f;
-    // Mouse sensitivity as degrees per pixel
-    const float MOUSE_SENSITIVITY = 0.2f;
-
-    // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
-    if (input->GetKeyDown('F'))
-    {
-        IntVector2 mouseMove = input->GetMouseMove();
-        yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
-        pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
-        pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    }
 
 
-    // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
-    cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-
-    // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
-    // Use the Translate() function (default local space) to move relative to the node's orientation.
-    if (input->GetKeyDown('W'))
-        cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
-    if (input->GetKeyDown('S'))
-        cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
-    if (input->GetKeyDown('Q'))
-        cameraNode_->Translate(Vector3::UP * MOVE_SPEED * timeStep);
-    if (input->GetKeyDown('E'))
-        cameraNode_->Translate(Vector3::DOWN * MOVE_SPEED * timeStep);
-    if (input->GetKeyDown('A'))
-        modelNode_->Yaw(-timeStep * 100);
-    if (input->GetKeyDown('D'))
-        modelNode_->Yaw(timeStep * 100);
 }
 }
 
 
 void ModelResourceEditor::HandleUpdate(StringHash eventType, VariantMap& eventData)
 void ModelResourceEditor::HandleUpdate(StringHash eventType, VariantMap& eventData)
 {
 {
 
 
-    if ((layout_->GetVisibility() != WIDGET_VISIBILITY_VISIBLE) || GetSubsystem<Editor>()->IsPlayingProject())
-    {
-        if (view3D_->IsVisible())
-        {
-            view3D_->SetVisible(false);            
-        }
-
-        return;
-    }
-
-    if (!view3D_->IsVisible())
-        view3D_->SetVisible(true);
-
-    // Timestep parameter is same no matter what event is being listened to
-    float timeStep = eventData[Update::P_TIMESTEP].GetFloat();
-
-    MoveCamera(timeStep);
-
-    bool dirty = false;
-
-    TBRect rect = view3DContainer_->GetRect();
-
-    TBWidget* parent = view3DContainer_->GetParent();
-    while (parent)
-    {
-        TBRect prect = parent->GetRect();
-        rect.x += prect.x;
-        rect.y += prect.y;
-        parent = parent->GetParent();
-    }
-
-    const IntVector2& pos = view3D_->GetPosition();
-    if (pos.x_ != rect.x || pos.y_ != rect.y)
-        dirty = true;
-
-    const IntVector2& size = view3D_->GetScreenPosition();
-
-    if (size.x_ != rect.w || size.y_ != rect.h)
-        dirty = true;
-
-    if (dirty)
-    {
-        view3D_->SetPosition(rect.x, rect.y);
-        view3D_->SetWidth(rect.w);
-        view3D_->SetHeight(rect.h);
-    }
 
 
-    view3D_->QueueUpdate();
 
 
 }
 }
 
 

+ 1 - 2
Source/AtomicEditor/Source/Editors/ModelResourceEditor.h

@@ -14,7 +14,6 @@ namespace Atomic
 {
 {
 class Scene;
 class Scene;
 class Node;
 class Node;
-class View3D;
 class Camera;
 class Camera;
 }
 }
 
 
@@ -43,7 +42,7 @@ private:
 
 
     SharedPtr<Scene> scene_;
     SharedPtr<Scene> scene_;
     SharedPtr<Node> cameraNode_;
     SharedPtr<Node> cameraNode_;
-    SharedPtr<View3D> view3D_;
+    //SharedPtr<View3D> view3D_;
     SharedPtr<Camera> camera_;
     SharedPtr<Camera> camera_;
     float yaw_;
     float yaw_;
     float pitch_;
     float pitch_;

+ 0 - 1
Source/AtomicEditor/Source/Editors/SceneEditor3D/SceneEditor3D.cpp

@@ -25,7 +25,6 @@
 
 
 #include <Atomic/UI/TBUI.h>
 #include <Atomic/UI/TBUI.h>
 #include <Atomic/UI/UI.h>
 #include <Atomic/UI/UI.h>
-#include <Atomic/UI/View3D.h>
 
 
 #include "SceneEditor3D.h"
 #include "SceneEditor3D.h"
 
 

+ 3 - 3
Source/AtomicJS/JSBind/modules/Engine.json

@@ -1,6 +1,6 @@
 {
 {
 	"name" : "Engine",
 	"name" : "Engine",
 	"sources" : ["Engine"],
 	"sources" : ["Engine"],
-	"includes" : ["<Atomic/UI/Text.h>", "<Atomic/UI/Button.h>", "<Atomic/UI/LineEdit.h>"],
-	"classes" : ["Engine", "DebugHud", "Console"]
-}
+	"includes" : [],
+	"classes" : ["Engine"]
+}

+ 1 - 8
Source/AtomicJS/JSBind/modules/UI.json

@@ -2,14 +2,8 @@
 	"name" : "UI",
 	"name" : "UI",
 	"sources" : ["UI"],
 	"sources" : ["UI"],
 	"includes" : ["<Atomic/Graphics/Material.h>", "<Atomic/Scene/Node.h>", "<Atomic/Scene/Scene.h>", "<Atomic/Graphics/Texture2D.h>"],
 	"includes" : ["<Atomic/Graphics/Material.h>", "<Atomic/Scene/Node.h>", "<Atomic/Scene/Scene.h>", "<Atomic/Graphics/Texture2D.h>"],
-	"classes" : ["Font", "UI", "UIElement", "Text", "BorderImage", "Button", "CheckBox",
-			     "Cursor", "DropDownList", "Menu", "FileSelector", "FontFace", "FontFaceBitmap", 
-			     "FontFaceFreeType", "LineEdit", "ListView", "ScrollView", "MessageBox",
-			     "ScrollBar", "Slider", "Sprite", "ToolTip", "Window", "View3D"],
+	"classes" : ["UI", "UIElement", "BorderImage", "Cursor"],
 	"overloads" : {
 	"overloads" : {
-		"Text" : {
-			"SetFont" : ["Font", "int"]
-		},
 		"UIElement" : {
 		"UIElement" : {
 			"SetColor" : ["Color"],
 			"SetColor" : ["Color"],
 			"SetPosition" : ["IntVector2"],
 			"SetPosition" : ["IntVector2"],
@@ -19,4 +13,3 @@
 
 
 	}
 	}
 }
 }
-