From fb7542a5e7d390a20eefc946cc5054dc79d74180 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 22 Mar 2012 22:52:59 +0100 Subject: menu/container: clipping requires window coordinates glScissor only work with window coordinates. to calculate that a control has to know it position on the window and therefor the parent container have to track the position in the window --- src/menu/container.cpp | 9 +++++++-- src/menu/container.hpp | 4 ++++ src/menu/drawable_control.cpp | 5 ++++- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src/menu') diff --git a/src/menu/container.cpp b/src/menu/container.cpp index 795d57ab..ce73c1c2 100644 --- a/src/menu/container.cpp +++ b/src/menu/container.cpp @@ -33,13 +33,13 @@ namespace usdx log4cpp::Category::getInstance("usdx.menu.container"); Container::Container(Container* owner) - : DrawableControl(owner), frame(NULL) + : DrawableControl(owner), frame(NULL), window_coords(0, 0) { set_clipping_required(true); } Container::Container(Container* owner, const ContainerHelper& add) - : DrawableControl(owner, add), frame(NULL) + : DrawableControl(owner, add), frame(NULL), window_coords(0, 0) { set_clipping_required(true); } @@ -86,4 +86,9 @@ namespace usdx { frame = NULL; } + + const Point& Container::get_window_coords(void) const + { + return window_coords; + } }; diff --git a/src/menu/container.hpp b/src/menu/container.hpp index 9b30b117..147a0d92 100644 --- a/src/menu/container.hpp +++ b/src/menu/container.hpp @@ -31,6 +31,7 @@ #include #include "drawable_control.hpp" +#include "utils/point.hpp" namespace usdx { @@ -48,6 +49,7 @@ namespace usdx Container(Container*, const ContainerHelper&); virtual void draw(void); + Point window_coords; public: Container(Container*); @@ -58,6 +60,8 @@ namespace usdx virtual void setFrame(Frame*); virtual void removeFrame(void); + + const Point& get_window_coords(void) const; }; }; diff --git a/src/menu/drawable_control.cpp b/src/menu/drawable_control.cpp index 00b6fa78..10da2bfc 100644 --- a/src/menu/drawable_control.cpp +++ b/src/menu/drawable_control.cpp @@ -81,8 +81,11 @@ namespace usdx clipping_lock.unlock(); boost::mutex::scoped_lock lock(size_mutex); - ClippingHelper clipping(Rectangle(position, size)); + Point offset(0, 0); + if (parent) + offset = parent->get_window_coords(); + ClippingHelper clipping(Rectangle(offset + position, size)); Drawable::repaint(); } else { -- cgit v1.2.3