Browse Source

Make sure plain widgets are getting wrapped, add a way to get a widget rect

Josh Engebretson 10 years ago
parent
commit
a1fdc3bf1e
3 changed files with 27 additions and 0 deletions
  1. 8 0
      Source/Atomic/UI/UI.cpp
  2. 17 0
      Source/Atomic/UI/UIWidget.cpp
  3. 2 0
      Source/Atomic/UI/UIWidget.h

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

@@ -483,6 +483,14 @@ UIWidget* UI::WrapWidget(tb::TBWidget* widget)
         return imagewidget;
         return imagewidget;
     }
     }
 
 
+    if (widget->IsOfType<TBWidget>())
+    {
+        UIWidget* nwidget = new UIWidget(context_, false);
+        nwidget->SetWidget(widget);
+        widgetWrap_[widget] = nwidget;
+        return nwidget;
+    }
+
     return 0;
     return 0;
 }
 }
 
 

+ 17 - 0
Source/Atomic/UI/UIWidget.cpp

@@ -137,6 +137,23 @@ void UIWidget::SetPosition(int x, int y)
 
 
 }
 }
 
 
+IntRect UIWidget::GetRect()
+{
+    IntRect rect(0, 0, 0, 0);
+
+    if (!widget_)
+        return rect;
+
+    tb::TBRect tbrect = widget_->GetRect();
+
+    rect.top_ = tbrect.y;
+    rect.left_ = tbrect.x;
+    rect.right_ = tbrect.x + tbrect.w;
+    rect.bottom_ = tbrect.y + tbrect.h;
+
+    return rect;
+}
+
 void UIWidget::SetSize(int width, int height)
 void UIWidget::SetSize(int width, int height)
 {
 {
     if (!widget_)
     if (!widget_)

+ 2 - 0
Source/Atomic/UI/UIWidget.h

@@ -27,6 +27,8 @@ public:
 
 
     bool Load(const String& filename);
     bool Load(const String& filename);
 
 
+    IntRect GetRect();
+
     void SetSize(int width, int height);
     void SetSize(int width, int height);
     void SetPosition(int x, int y);
     void SetPosition(int x, int y);
     void SetText(const String& text);
     void SetText(const String& text);