Added color picking support to the GUI Editor. TODO: change all the widget definitions.
This commit is contained in:
parent
8fb7c1c5f0
commit
03e4c5ccd4
3 changed files with 66 additions and 25 deletions
|
@ -22,6 +22,7 @@
|
|||
#include "nel/gui/widget_manager.h"
|
||||
#include <typeinfo>
|
||||
#include "widget_info_tree.h"
|
||||
#include <QList>
|
||||
|
||||
namespace GUIEditor
|
||||
{
|
||||
|
@ -62,8 +63,8 @@ namespace GUIEditor
|
|||
void CPropBrowserCtrl::clear()
|
||||
{
|
||||
browser->clear();
|
||||
disconnect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ),
|
||||
this, SLOT( onPropertyChanged( QtProperty* ) ) );
|
||||
disconnect( propertyMgr, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ),
|
||||
this, SLOT( onPropertyChanged( QtProperty*, const QVariant& ) ) );
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::onSelectionChanged( std::string &id )
|
||||
|
@ -71,16 +72,16 @@ namespace GUIEditor
|
|||
if( browser == NULL )
|
||||
return;
|
||||
|
||||
disconnect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ),
|
||||
this, SLOT( onPropertyChanged( QtProperty* ) ) );
|
||||
disconnect( propertyMgr, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ),
|
||||
this, SLOT( onPropertyChanged( QtProperty*, const QVariant& ) ) );
|
||||
|
||||
browser->clear();
|
||||
|
||||
CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( id );
|
||||
if( e == NULL )
|
||||
{
|
||||
connect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ),
|
||||
this, SLOT( onPropertyChanged( QtProperty* ) ) );
|
||||
connect( propertyMgr, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ),
|
||||
this, SLOT( onPropertyChanged( QtProperty*, const QVariant& ) ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -90,11 +91,11 @@ namespace GUIEditor
|
|||
std::string n = e->getClassName();
|
||||
|
||||
setupProperties( n, e );
|
||||
connect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ),
|
||||
this, SLOT( onPropertyChanged( QtProperty* ) ) );
|
||||
connect( propertyMgr, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ),
|
||||
this, SLOT( onPropertyChanged( QtProperty*, const QVariant& ) ) );
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::onPropertyChanged( QtProperty *prop )
|
||||
void CPropBrowserCtrl::onPropertyChanged( QtProperty *prop, const QVariant &v )
|
||||
{
|
||||
QString propName = prop->propertyName();
|
||||
QString propValue = prop->valueText();
|
||||
|
@ -107,6 +108,14 @@ namespace GUIEditor
|
|||
propValue = p->value().toString();
|
||||
}
|
||||
|
||||
if( v.type() == QVariant::Color )
|
||||
{
|
||||
QColor c = v.value< QColor >();
|
||||
QString val = "%1 %2 %3 %4";
|
||||
val = val.arg( c.red() ).arg( c.green() ).arg( c.blue() ).arg( c.alpha() );
|
||||
propValue = val;
|
||||
}
|
||||
|
||||
CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement );
|
||||
if( e == NULL )
|
||||
return;
|
||||
|
@ -163,6 +172,38 @@ namespace GUIEditor
|
|||
NLMISC::fromString( element->getProperty( prop.propName ), value );
|
||||
v = value;
|
||||
}
|
||||
else
|
||||
if( prop.propType == "color" )
|
||||
{
|
||||
p = propertyMgr->addProperty( QVariant::Color, prop.propName.c_str() );
|
||||
|
||||
std::string s = element->getProperty( prop.propName );
|
||||
// Parse string into a QColor
|
||||
QString qs = s.c_str();
|
||||
QStringList l = qs.split( " " );
|
||||
int r = l[ 0 ].toInt();
|
||||
int g = l[ 1 ].toInt();
|
||||
int b = l[ 2 ].toInt();
|
||||
int a = l[ 3 ].toInt();
|
||||
|
||||
QColor value;
|
||||
value.setRed( r );
|
||||
value.setGreen( g );
|
||||
value.setBlue( b );
|
||||
value.setAlpha( a );
|
||||
v = value;
|
||||
|
||||
|
||||
// Remove the subproperties
|
||||
QList< QtProperty* > pl = p->subProperties();
|
||||
QListIterator< QtProperty* > itr( pl );
|
||||
while( itr.hasNext() )
|
||||
{
|
||||
delete itr.next();
|
||||
}
|
||||
pl.clear();
|
||||
|
||||
}
|
||||
|
||||
if( p == NULL )
|
||||
return;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
class QtTreePropertyBrowser;
|
||||
class QtVariantPropertyManager;
|
||||
class QtProperty;
|
||||
class QVariant;
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
@ -53,7 +54,7 @@ namespace GUIEditor
|
|||
void onSelectionChanged( std::string &id );
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPropertyChanged( QtProperty *prop );
|
||||
void onPropertyChanged( QtProperty *prop, const QVariant &v );
|
||||
|
||||
private:
|
||||
void setupProperties( const std::string &type, const NLGUI::CInterfaceElement *element );
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
<header>
|
||||
<name>CtrlTextButton</name>
|
||||
<guiname>CCtrlTextButton</guiname>
|
||||
<classname>text_button</classname>
|
||||
<ancestor>CtrlBaseButton</ancestor>
|
||||
<description></description>
|
||||
<abstract>false</abstract>
|
||||
|
@ -12,27 +11,27 @@
|
|||
<property>
|
||||
<name>tx_normal</name>
|
||||
<type>string</type>
|
||||
<default>but</default>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>tx_pushed</name>
|
||||
<type>string</type>
|
||||
<default>but</default>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>tx_over</name>
|
||||
<type>string</type>
|
||||
<default>but_over</default>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>hardtext</name>
|
||||
<type>string</type>
|
||||
<default>text</default>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>wmargin</name>
|
||||
<type>int</type>
|
||||
<default>20</default>
|
||||
<default>0</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>wmin</name>
|
||||
|
@ -61,32 +60,32 @@
|
|||
</property>
|
||||
<property>
|
||||
<name>text_color_normal</name>
|
||||
<type>string</type>
|
||||
<type>color</type>
|
||||
<default>255 255 255 255</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>text_color_pushed</name>
|
||||
<type>string</type>
|
||||
<type>color</type>
|
||||
<default>255 255 255 255</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>text_color_over</name>
|
||||
<type>string</type>
|
||||
<type>color</type>
|
||||
<default>255 255 255 255</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>text_shadow_color_normal</name>
|
||||
<type>string</type>
|
||||
<type>color</type>
|
||||
<default>0 0 0 255</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>text_shadow_color_pushed</name>
|
||||
<type>string</type>
|
||||
<type>color</type>
|
||||
<default>0 0 0 255</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>text_shadow_color_over</name>
|
||||
<type>string</type>
|
||||
<type>color</type>
|
||||
<default>0 0 0 255</default>
|
||||
</property>
|
||||
<property>
|
||||
|
@ -116,7 +115,7 @@
|
|||
</property>
|
||||
<property>
|
||||
<name>color</name>
|
||||
<type>string</type>
|
||||
<type>color</type>
|
||||
<default>255 255 255 255</default>
|
||||
</property>
|
||||
<property>
|
||||
|
@ -136,7 +135,7 @@
|
|||
</property>
|
||||
<property>
|
||||
<name>shadow_color</name>
|
||||
<type>string</type>
|
||||
<type>color</type>
|
||||
<default>0 0 0 255</default>
|
||||
</property>
|
||||
<property>
|
||||
|
@ -152,7 +151,7 @@
|
|||
<property>
|
||||
<name>line_maxw</name>
|
||||
<type>int</type>
|
||||
<default>200</default>
|
||||
<default>0</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>multi_line_space</name>
|
||||
|
|
Loading…
Reference in a new issue