aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2013-01-20 21:46:52 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-20 21:46:52 +0100
commit8977e88b64e5f08a27cb10b8606f1d9c9ca27679 (patch)
tree33fdf68a529d1143e4880ae3353cd6e5bfeb3371
parenta6b096260ae3dea25233852c90b04b8298b92688 (diff)
downloadusdx-8977e88b64e5f08a27cb10b8606f1d9c9ca27679.tar.gz
usdx-8977e88b64e5f08a27cb10b8606f1d9c9ca27679.tar.xz
usdx-8977e88b64e5f08a27cb10b8606f1d9c9ca27679.zip
menu/drawable_control: add static member for debug boxes
-rw-r--r--src/menu/drawable_control.cpp21
-rw-r--r--src/menu/drawable_control.hpp6
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;