From 112f90fbbb4579aa147aa36eaf91b54d3fb580a2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 1 Jul 2014 01:51:41 +0200 Subject: [PATCH] Bitmap alignment can now be set as an enum. --- .../gui_editor/property_browser_ctrl.cpp | 87 +++++++++++++++++++ .../plugins/gui_editor/widgets/ViewBitmap.xml | 2 +- 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp index d56062eda..a8f129bfd 100644 --- a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp +++ b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp @@ -28,6 +28,53 @@ namespace { + class NelBMAlign + { + public: + + enum NELBMAlign + { + LB = 0, + RB = 1, + LT = 2, + RT = 3 + }; + + static int fromString( const std::string &s ) + { + int r = -1; + + if( s == "LB" ) + r = 0; + else + if( s == "RB" ) + r = 1; + else + if( s == "LT" ) + r = 2; + else + if( s == "RT" ) + r = 3; + + return r; + } + + static std::string toString( int value ) + { + std::string s; + + switch( value ) + { + case LB: s = "LB"; break; + case RB: s = "RB"; break; + case LT: s = "LT"; break; + case RT: s = "RT"; break; + } + + return s; + } + }; + class NelTTParent { public: @@ -555,6 +602,19 @@ namespace GUIEditor e->setProperty( propName.toUtf8().constData(), v ); } + else + if( type == "bitmap_align" ) + { + CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement ); + if( e == NULL ) + return; + + std::string v = NelBMAlign::toString( value ); + if( v.empty() ) + return; + + e->setProperty( propName.toUtf8().constData(), v ); + } } void CPropBrowserCtrl::enablePropertyWatchers() @@ -597,6 +657,33 @@ namespace GUIEditor QtVariantProperty *p = NULL; QVariant v; + if( prop.propType == "bitmap_align" ) + { + std::string j = element->getProperty( prop.propName ); + + if( j.empty() ) + return; + + int e = -1; + e = NelBMAlign::fromString( j ); + if( e == -1 ) + return; + + QtProperty *pp = enumMgr->addProperty( prop.propName.c_str() ); + if( pp == NULL ) + return; + + QStringList enums; + enums.push_back( "LB" ); + enums.push_back( "RB" ); + enums.push_back( "LT" ); + enums.push_back( "RT" ); + + enumMgr->setEnumNames( pp, enums ); + enumMgr->setValue( pp, e ); + browser->addProperty( pp ); + } + else if( prop.propType == "tooltip_parent" ) { std::string j = element->getProperty( prop.propName ); diff --git a/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml b/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml index 9da967b5a..7dddfdbe1 100644 --- a/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml +++ b/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml @@ -60,7 +60,7 @@ align - string + bitmap_align