From 23c7d2c11170ee8736673e82a88e87a3d2e538f7 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 26 Oct 2010 15:32:42 +0000 Subject: enables ui::Slider mouse dragging, corrected a bug in ui::Widget coordinate mapping --- src/ui/widget.h | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'src/ui/widget.h') diff --git a/src/ui/widget.h b/src/ui/widget.h index 530af05..cb42ad0 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -293,12 +293,23 @@ protected: /* -- coordinate mapping ----------------------------------- */ + /// map local widget location to global location + inline math::Vector2f global_location() { + math::Vector2f v(widget_location); + Widget *parent = widget_parent; + while (parent) { + v += parent->location(); + parent = parent->parent(); + } + return v; + } + /// map local coordinates to global coordinates inline math::Vector2f to_global_coords(const math::Vector2f &local) { math::Vector2f v(local); Widget *parent = widget_parent; do { - v -= parent->location(); + v += parent->location(); parent = parent->parent(); } while (parent); return v; @@ -309,18 +320,7 @@ protected: math::Vector2f v(global); Widget *parent = this; while (parent) { - v += parent->location(); - parent = parent->parent(); - } - return v; - } - - /// map local widget location to global location - inline math::Vector2f global_location() { - math::Vector2f v(widget_location); - Widget *parent = widget_parent; - while (parent) { - v += parent->location(); + v -= parent->location(); parent = parent->parent(); } return v; @@ -356,6 +356,9 @@ protected: /// draw the widget border virtual void draw_border(); + + /// draw denug state + virtual void draw_debug(); /// add a child widget virtual void add_child(Widget *child); @@ -366,8 +369,8 @@ protected: /// remove all child widgets virtual void remove_children(); + private: - void draw_debug_border(); bool widget_visible; bool widget_background; -- cgit v1.2.3