Răsfoiți Sursa

setters/getters.
override instead of virtual.

Enhex 7 ani în urmă
părinte
comite
91af42eca9

+ 10 - 0
Source/Urho3D/UI/Selectable.cpp

@@ -34,4 +34,14 @@ void Selectable::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& verte
     hovering_ = false;
 }
 
+void Selectable::SetSelectionColor(const Color& color)
+{
+    selectionColor_ = color;
+}
+
+void Selectable::SetHoverColor(const Color& color)
+{
+    hoverColor_ = color;
+}
+
 }

+ 18 - 5
Source/Urho3D/UI/Selectable.h

@@ -27,21 +27,34 @@
 namespace Urho3D
 {
 
-struct URHO3D_API Selectable : UIElement
+class URHO3D_API Selectable : public UIElement
 {
+public:
     URHO3D_OBJECT(Selectable, UIElement);
 
     using UIElement::UIElement;
-    virtual ~Selectable() = default;
-
-    Color selectionColor_ = Color(0.f, 0.f, 0.f, 0.f);
-    Color hoverColor_ = Color(0.f, 0.f, 0.f, 0.f);
+    ~Selectable() override = default;
 
     /// Register object factory.
     static void RegisterObject(Context* context);
 
     /// Return UI rendering batches.
     void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor) override;
+
+    /// 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);
+
+    /// Return selection background color.
+    const Color& GetSelectionColor() const { return selectionColor_; }
+
+    /// Return hover background color.
+    const Color& GetHoverColor() const { return hoverColor_; }
+
+protected:
+    Color selectionColor_{ Color::TRANSPARENT };
+    Color hoverColor_{ Color::TRANSPARENT };
 };
 
 }

+ 0 - 12
Source/Urho3D/UI/Text.cpp

@@ -61,8 +61,6 @@ Text::Text(Context* context) :
     charLocationsDirty_(true),
     selectionStart_(0),
     selectionLength_(0),
-    selectionColor_(Color::TRANSPARENT),
-    hoverColor_(Color::TRANSPARENT),
     textEffect_(TE_NONE),
     shadowOffset_(IntVector2(1, 1)),
     strokeThickness_(1),
@@ -383,16 +381,6 @@ void Text::ClearSelection()
     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;

+ 0 - 14
Source/Urho3D/UI/Text.h

@@ -113,10 +113,6 @@ public:
     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 shadow offset.
@@ -155,12 +151,6 @@ public:
     /// 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_; }
 
@@ -243,10 +233,6 @@ protected:
     unsigned selectionStart_;
     /// Selection length.
     unsigned selectionLength_;
-    /// Selection background color.
-    Color selectionColor_;
-    /// Hover background color.
-    Color hoverColor_;
     /// Text effect.
     TextEffect textEffect_;
     /// Text effect shadow offset.