From e0e9997a5e92ce2a31f0ff4d139109be4434105b Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 11 Apr 2012 21:19:48 +0200 Subject: menu: generalized frame_background to background background could now be a background for all DrawableControl instances each subclass should call the parents draw() during executing the draw() method for background painting TODO: background should know the size of the control to only draw the background there --- src/menu/drawable_control.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/menu/drawable_control.cpp') diff --git a/src/menu/drawable_control.cpp b/src/menu/drawable_control.cpp index 9d00d3f1..a0b4ad27 100644 --- a/src/menu/drawable_control.cpp +++ b/src/menu/drawable_control.cpp @@ -37,7 +37,8 @@ namespace usdx DrawableControl::DrawableControl(Container* parent) : Control(parent), position(0, 0), size(0, 0), - clipping_required(false), parent(parent) + clipping_required(false), background(NULL), + parent(parent) { ContainerHelper(this).add(parent); } @@ -45,7 +46,8 @@ namespace usdx DrawableControl::DrawableControl(Container* parent, const ContainerHelper& helper) : Control(parent), position(0, 0), size(0, 0), - clipping_required(false), parent(parent) + clipping_required(false), background(NULL), + parent(parent) { helper.add(parent); } @@ -53,6 +55,11 @@ namespace usdx DrawableControl::~DrawableControl() { remove_parent(); + + if (background) { + delete background; + background = NULL; + } } bool DrawableControl::get_clipping_required(void) const @@ -66,6 +73,14 @@ namespace usdx clipping_required = value; } + void DrawableControl::draw(void) + { + boost::mutex::scoped_lock lock(background_mutex); + if (background) { + background->repaint(); + } + } + void DrawableControl::repaint(void) { { @@ -164,4 +179,19 @@ namespace usdx c->add(self); } } + + void DrawableControl::set_background(Background* background) + { + boost::mutex::scoped_lock lock(background_mutex); + if (this->background) { + delete this->background; + } + + this->background = background; + } + + const Background* DrawableControl::get_background(void) const + { + return background; + } }; -- cgit v1.2.3