diff options
Diffstat (limited to '')
-rw-r--r-- | src/menu/drawable_control.cpp | 21 | ||||
-rw-r--r-- | src/menu/drawable_control.hpp | 6 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/menu/drawable_control.cpp b/src/menu/drawable_control.cpp index 0708599b..72c3ec77 100644 --- a/src/menu/drawable_control.cpp +++ b/src/menu/drawable_control.cpp @@ -39,7 +39,7 @@ namespace usdx DrawableControl::DrawableControl(Container* parent) : Control(parent), position(0, 0), size(0, 0), clipping_required(false), focusable(true), background(NULL), - parent(parent) + debug_box(NULL), parent(parent) { ContainerHelper(this).add(parent); } @@ -48,7 +48,7 @@ namespace usdx const ContainerHelper& helper) : Control(parent), position(0, 0), size(0, 0), clipping_required(false), focusable(true), background(NULL), - parent(parent) + debug_box(NULL), parent(parent) { helper.add(parent); } @@ -61,6 +61,11 @@ namespace usdx delete background; background = NULL; } + + if (debug_box) { + delete debug_box; + debug_box = NULL; + } } bool DrawableControl::is_clipping_required(void) const @@ -120,10 +125,14 @@ namespace usdx if (Application::get_config()->get_debug_boxes()) { - boost::shared_lock<boost::shared_mutex> lock(size_mutex); - StaticRectangle s(RgbColor(255, 0, 0), size); - s.set_stroke_width(2.0f); - s.repaint(); + if (debug_box == NULL) { + boost::shared_lock<boost::shared_mutex> lock(size_mutex); + + debug_box = new StaticRectangle(RgbColor(255, 0, 0), size); + debug_box->set_stroke_width(2.0f); + } + + debug_box->repaint(); } } diff --git a/src/menu/drawable_control.hpp b/src/menu/drawable_control.hpp index 7627cbed..bac1ccfb 100644 --- a/src/menu/drawable_control.hpp +++ b/src/menu/drawable_control.hpp @@ -35,6 +35,7 @@ #include "utils/dimension.hpp" #include "utils/rectangle.hpp" #include "background.hpp" +#include "static.hpp" namespace usdx { @@ -72,6 +73,11 @@ namespace usdx */ Background* background; + /** + * Optional box around the control. Used for debugging. + */ + Static* debug_box; + mutable boost::shared_mutex position_mutex; mutable boost::shared_mutex size_mutex; mutable boost::shared_mutex clipping_required_mutex; |