diff options
Diffstat (limited to 'src/menu/drawable_control.cpp')
-rw-r--r-- | src/menu/drawable_control.cpp | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/src/menu/drawable_control.cpp b/src/menu/drawable_control.cpp index 6ee5100c..72486d42 100644 --- a/src/menu/drawable_control.cpp +++ b/src/menu/drawable_control.cpp @@ -28,6 +28,7 @@ #include "drawable_control.hpp" #include "container.hpp" +#include "clipping_helper.hpp" namespace usdx { @@ -35,14 +36,16 @@ namespace usdx log4cpp::Category::getInstance("usdx.menu.drawable_control"); DrawableControl::DrawableControl(Container* parent) - : Control(parent), position(0, 0), parent(parent) + : Control(parent), position(0, 0), size(0, 0), + clipping_required(false), parent(parent) { ContainerHelper(this).add(parent); } DrawableControl::DrawableControl(Container* parent, const ContainerHelper& helper) - : Control(parent), position(0, 0), parent(parent) + : Control(parent), position(0, 0), size(0, 0), + clipping_required(false), parent(parent) { helper.add(parent); } @@ -55,6 +58,17 @@ namespace usdx } } + bool DrawableControl::get_clipping_required(void) const + { + return clipping_required; + } + + void DrawableControl::set_clipping_required(const bool value) + { + boost::mutex::scoped_lock lock(clipping_required_mutex); + clipping_required = value; + } + void DrawableControl::repaint(void) { glLoadIdentity(); @@ -65,7 +79,19 @@ namespace usdx glTranslatef(position.get_x(), position.get_y(), 0.0f); } - Drawable::repaint(); + boost::mutex::scoped_lock clipping_lock(clipping_required_mutex); + if (clipping_required) { + clipping_lock.unlock(); + + boost::mutex::scoped_lock lock(size_mutex); + ClippingHelper clipping(Rectangle<int>(position, size)); + + Drawable::repaint(); + } + else { + clipping_lock.unlock(); + Drawable::repaint(); + } } void DrawableControl::set_position(const Point<int>& position) @@ -97,6 +123,34 @@ namespace usdx } + void DrawableControl::set_size(const Dimension<int> &size) + { + boost::mutex::scoped_lock lock(size_mutex); + this->size = size; + } + + void DrawableControl::set_size(int width, int height) + { + boost::mutex::scoped_lock lock(size_mutex); + this->size = Dimension<int>(width, height); + } + + + const Dimension<int>& DrawableControl::get_size(void) const + { + return size; + } + + int DrawableControl::get_width(void) const + { + return size.get_width(); + } + + int DrawableControl::get_height(void) const + { + return size.get_height(); + } + DrawableControl::ContainerHelper::ContainerHelper(DrawableControl* self) : self(self) { |