From bd942ba62b0ecd33987312db3c45d5a4f8816b7a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 15 Oct 2014 19:54:35 +0200 Subject: [PATCH 01/18] TEMPORARILY add the login texture map to new project by default. --HG-- branch : dfighter-tools --- code/studio/src/plugins/gui_editor/new_gui_dlg.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp b/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp index 3c9208dfc..43faabf79 100644 --- a/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp +++ b/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp @@ -25,6 +25,9 @@ QDialog( parent ) { m_ui.setupUi( this ); + // Login texture map - temporaty measure until we add default textures for widgets to use + m_ui.mapList->addItem( "texture_interfaces_v3_login.tga" ); + connect( m_ui.okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) ); connect( m_ui.cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); connect( m_ui.projectDirTB, SIGNAL( clicked( bool ) ), this, SLOT( onProjectDirTBClicked() ) ); From cfa4129754cd67fdec0d3bc8fd6cbcc959defa3c Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 15 Oct 2014 20:03:46 +0200 Subject: [PATCH 02/18] Default texture for CtrlButton. --HG-- branch : dfighter-tools --- code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml b/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml index c081f3dae..b52bb73a5 100644 --- a/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml +++ b/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml @@ -12,17 +12,17 @@ tx_normal string - + tp_quit.tga tx_pushed string - + tp_quit.tga tx_over string - + tp_quit.tga scale From c9b528081e0a6ba38ba3dd3f9e64b3189b6c0d48 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 15 Oct 2014 20:07:13 +0200 Subject: [PATCH 03/18] CtrlButton textures should be selectable in the texture chooser! --HG-- branch : dfighter-tools --- code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml b/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml index b52bb73a5..2454f7035 100644 --- a/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml +++ b/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml @@ -11,17 +11,17 @@ tx_normal - string + texture tp_quit.tga tx_pushed - string + texture tp_quit.tga tx_over - string + texture tp_quit.tga From 66fe76fc064a591f6647e944462c3d304fc413b5 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 15 Oct 2014 20:20:44 +0200 Subject: [PATCH 04/18] A Kami will be the default texture for Bitmaps. --HG-- branch : dfighter-tools --- code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml b/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml index 7d78f6c40..1c22d67cd 100644 --- a/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml +++ b/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml @@ -37,7 +37,7 @@ texture texture - + log_kami.tga scale From f7f74b5398e27c38f1f95e1aa9aebdada7b92d7c Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 15 Oct 2014 23:30:36 +0200 Subject: [PATCH 05/18] Render every 25ms instead of 200ms --HG-- branch : dfighter-tools --- code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp b/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp index e9712ce4e..4852b227f 100644 --- a/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp +++ b/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp @@ -188,7 +188,7 @@ namespace GUIEditor void NelGUICtrl::onGUILoaded() { - timerID = startTimer( 200 ); + timerID = startTimer( 25 ); guiLoaded = true; Q_EMIT guiLoadComplete(); From 42ebad94f6a416ba3d30e84ff6ac541f28074eec Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 16 Oct 2014 20:25:19 +0200 Subject: [PATCH 06/18] Implemented CGroupEditBoxDecor a decorated CGroupEditBox. --HG-- branch : dfighter-tools --- .../nel/include/nel/gui/group_editbox_decor.h | 49 +++ code/nel/include/nel/gui/interface_element.h | 8 + code/nel/src/gui/group_editbox.cpp | 12 +- code/nel/src/gui/group_editbox_decor.cpp | 357 ++++++++++++++++++ code/nel/src/gui/link_hack.cpp | 2 + code/nel/src/gui/widget_manager.cpp | 6 + .../gui_editor/widget_info_tree_node.h | 4 + .../gui_editor/widgets/GroupEditBoxDecor.xml | 68 ++++ 8 files changed, 503 insertions(+), 3 deletions(-) create mode 100644 code/nel/include/nel/gui/group_editbox_decor.h create mode 100644 code/nel/src/gui/group_editbox_decor.cpp create mode 100644 code/studio/src/plugins/gui_editor/widgets/GroupEditBoxDecor.xml diff --git a/code/nel/include/nel/gui/group_editbox_decor.h b/code/nel/include/nel/gui/group_editbox_decor.h new file mode 100644 index 000000000..a2b540608 --- /dev/null +++ b/code/nel/include/nel/gui/group_editbox_decor.h @@ -0,0 +1,49 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2014 Laszlo Kis-Adam +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef GROUP_EDITBOX_DECOR +#define GROUP_EDITBOX_DECOR + +#include "nel/gui/group_editbox.h" + +namespace NLGUI +{ + /// Decorated CGroupEditBox + class CGroupEditBoxDecor : public CGroupEditBox + { + public: + DECLARE_UI_CLASS( CGroupEditBoxDecor ) + + CGroupEditBoxDecor( const TCtorParam ¶m ); + ~CGroupEditBoxDecor(); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + bool parse( xmlNodePtr cur, CInterfaceGroup *parent ); + void draw(); + void updateCoords(); + + static void forceLink(); + + private: + class EBDPrivate *_Pvt; + }; +} + +#endif + diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index c1f6d20e7..e2f9ffc87 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -117,6 +117,7 @@ namespace NLGUI editorSelected = false; serializable = true; + _EditorSelectable = true; } // dtor @@ -531,9 +532,16 @@ namespace NLGUI /// Aligns the element to the other element specified void alignTo( CInterfaceElement *other ); + /// Specifies if the widget can be selected in the editor + void setEditorSelectable( bool b ){ _EditorSelectable = b; } + + /// Tells if the widget can be selected in the editor + bool isEditorSelectable() const{ return _EditorSelectable; } + protected: bool editorSelected; + bool _EditorSelectable; static bool editorMode; diff --git a/code/nel/src/gui/group_editbox.cpp b/code/nel/src/gui/group_editbox.cpp index 92ae46703..8c8ae867c 100644 --- a/code/nel/src/gui/group_editbox.cpp +++ b/code/nel/src/gui/group_editbox.cpp @@ -1548,13 +1548,17 @@ namespace NLGUI { _ViewText->setParent( this ); _ViewText->setIdRecurse( "edit_text" ); - _ViewText->setHardText( "sometext" ); + _ViewText->setHardText( "" ); _ViewText->setPosRef( Hotspot_TL ); _ViewText->setParentPosRef( Hotspot_TL ); addView( _ViewText ); + + sint32 w,h; + w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() ); + h = std::max( sint32( _ViewText->getFontHeight() ), getH() ); - setH( _ViewText->getFontHeight() ); - setW( _ViewText->getFontWidth() * _ViewText->getText().size() ); + setH( h ); + setW( w ); } else @@ -1562,6 +1566,8 @@ namespace NLGUI } } + _ViewText->setEditorSelectable( false ); + // For MultiLine editbox, clip the end space, else weird when edit space at end of line (nothing happens) if(_ViewText) _ViewText->setMultiLineClipEndSpace(true); diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp new file mode 100644 index 000000000..50241789e --- /dev/null +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -0,0 +1,357 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2014 Laszlo Kis-Adam +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdpch.h" +#include "nel/gui/group_editbox_decor.h" +#include "nel/gui/view_bitmap.h" + +namespace NLGUI +{ + class EBDPrivate + { + public: + enum Textures + { + BG, + L, + R, + TM, + BM, + TL, + TR, + BL, + BR, + TCOUNT + }; + + EBDPrivate() + { + for( int i = 0; i < TCOUNT; i++ ) + { + _Textures.push_back( new CViewBitmap( CViewBase::TCtorParam() ) ); + } + } + + ~EBDPrivate() + { + for( int i = 0; i < _Textures.size(); i++ ) + delete _Textures[ i ]; + _Textures.clear(); + } + + void draw() + { + for( int i = 0; i < _Textures.size(); i++ ) + { + CViewBitmap *bm = _Textures[ i ]; + bm->draw(); + } + } + + void updateCoords() + { + for( int i = 0; i < _Textures.size(); i++ ) + { + CViewBitmap *bm = _Textures[ i ]; + bm->fitTexture(); + } + + // W and H parameters depend on the sizes of the other textures + // Negative sizes mean that the sizes are that much smaller than the parent + sint32 w,h; + h = _Textures[ TL ]->getHReal() + _Textures[ BL ]->getHReal(); + h *= -1; + _Textures[ L ]->setH( h ); + + h = _Textures[ TR ]->getHReal() + _Textures[ BR ]->getHReal(); + h *= -1; + _Textures[ R ]->setH( h ); + + w = _Textures[ TL ]->getWReal() + _Textures[ TR ]->getWReal(); + w *= -1; + _Textures[ TM ]->setW( w ); + + w = _Textures[ BL ]->getWReal() + _Textures[ BR ]->getWReal(); + w *= -1; + _Textures[ BM ]->setW( w ); + + h = _Textures[ TM ]->getHReal() + _Textures[ BM ]->getHReal(); + h *= -1; + w = _Textures[ L ]->getWReal() + _Textures[ R ]->getWReal(); + w *= -1; + _Textures[ BG ]->setW( w ); + _Textures[ BG ]->setH( h ); + + for( int i = 0; i < _Textures.size(); i++ ) + { + CViewBitmap *bm = _Textures[ i ]; + bm->updateCoords(); + } + } + + void setup( CInterfaceGroup *parent ) + { + for( int i = 0; i < _Textures.size(); i++ ) + { + CViewBitmap *bm = _Textures[ i ]; + bm->setParent( parent ); + bm->setParentPos( parent ); + bm->setParentSize( parent ); + bm->setEditorSelectable( false ); + } + + _Textures[ TL ]->setPosRef( Hotspot_TL ); + _Textures[ TL ]->setParentPosRef( Hotspot_TL ); + + _Textures[ TM ]->setPosRef( Hotspot_TM ); + _Textures[ TM ]->setParentPosRef( Hotspot_TM ); + _Textures[ TM ]->setScale( true ); + _Textures[ TM ]->setSizeRef( "w" ); + + _Textures[ TR ]->setPosRef( Hotspot_TR ); + _Textures[ TR ]->setParentPosRef( Hotspot_TR ); + + _Textures[ BL ]->setPosRef( Hotspot_BL ); + _Textures[ BL ]->setParentPosRef( Hotspot_BL ); + + _Textures[ BM ]->setPosRef( Hotspot_BM ); + _Textures[ BM ]->setParentPosRef( Hotspot_BM ); + _Textures[ BM ]->setScale( true ); + _Textures[ BM ]->setSizeRef( "w" ); + + _Textures[ BR ]->setPosRef( Hotspot_BR ); + _Textures[ BR ]->setParentPosRef( Hotspot_BR ); + + _Textures[ L ]->setPosRef( Hotspot_ML ); + _Textures[ L ]->setParentPosRef( Hotspot_ML ); + _Textures[ L ]->setScale( true ); + _Textures[ L ]->setSizeRef( "h" ); + + _Textures[ R ]->setPosRef( Hotspot_MR ); + _Textures[ R ]->setParentPosRef( Hotspot_MR ); + _Textures[ R ]->setScale( true ); + _Textures[ R ]->setSizeRef( "h" ); + + _Textures[ BG ]->setPosRef( Hotspot_MM ); + _Textures[ BG ]->setParentPosRef( Hotspot_MM ); + _Textures[ BG ]->setScale( true ); + _Textures[ BG ]->setSizeRef( "wh" ); + _Textures[ BG ]->setRenderLayer( -1 ); + } + + std::vector< CViewBitmap* > _Textures; + }; + + NLMISC_REGISTER_OBJECT( CViewBase, CGroupEditBoxDecor, std::string, "edit_box_decor" ); + + CGroupEditBoxDecor::CGroupEditBoxDecor( const TCtorParam ¶m ) : + CGroupEditBox( param ) + { + _Pvt = new EBDPrivate(); + _Pvt->setup( this ); + } + + CGroupEditBoxDecor::~CGroupEditBoxDecor() + { + delete _Pvt; + _Pvt = NULL; + } + + std::string CGroupEditBoxDecor::getProperty( const std::string &name ) const + { + if( name == "tx_tl" ) + { + return _Pvt->_Textures[ EBDPrivate::TL ]->getTexture(); + } + else + if( name == "tx_tm" ) + { + return _Pvt->_Textures[ EBDPrivate::TM ]->getTexture(); + } + else + if( name == "tx_tr" ) + { + return _Pvt->_Textures[ EBDPrivate::TR ]->getTexture(); + } + else + if( name == "tx_bl" ) + { + return _Pvt->_Textures[ EBDPrivate::BL ]->getTexture(); + } + else + if( name == "tx_bm" ) + { + return _Pvt->_Textures[ EBDPrivate::BM ]->getTexture(); + } + else + if( name == "tx_br" ) + { + return _Pvt->_Textures[ EBDPrivate::BR ]->getTexture(); + } + else + if( name == "tx_l" ) + { + return _Pvt->_Textures[ EBDPrivate::L ]->getTexture(); + } + else + if( name == "tx_r" ) + { + return _Pvt->_Textures[ EBDPrivate::R ]->getTexture(); + } + else + if( name == "tx_bg" ) + { + return _Pvt->_Textures[ EBDPrivate::BG ]->getTexture(); + } + else + return CGroupEditBox::getProperty( name ); + } + + void CGroupEditBoxDecor::setProperty( const std::string &name, const std::string &value ) + { + if( name == "tx_tl" ) + { + _Pvt->_Textures[ EBDPrivate::TL ]->setTexture( value ); + } + else + if( name == "tx_tm" ) + { + _Pvt->_Textures[ EBDPrivate::TM ]->setTexture( value ); + } + else + if( name == "tx_tr" ) + { + _Pvt->_Textures[ EBDPrivate::TR ]->setTexture( value ); + } + else + if( name == "tx_bl" ) + { + _Pvt->_Textures[ EBDPrivate::BL ]->setTexture( value ); + } + else + if( name == "tx_bm" ) + { + _Pvt->_Textures[ EBDPrivate::BM ]->setTexture( value ); + } + else + if( name == "tx_br" ) + { + _Pvt->_Textures[ EBDPrivate::BR ]->setTexture( value ); + } + else + if( name == "tx_l" ) + { + _Pvt->_Textures[ EBDPrivate::L ]->setTexture( value ); + } + else + if( name == "tx_r" ) + { + _Pvt->_Textures[ EBDPrivate::R ]->setTexture( value ); + } + else + if( name == "tx_bg" ) + { + _Pvt->_Textures[ EBDPrivate::BG ]->setTexture( value ); + } + else + CGroupEditBox::setProperty( name, value ); + } + + xmlNodePtr CGroupEditBoxDecor::serialize( xmlNodePtr parentNode, const char *type ) const + { + xmlNodePtr node = CGroupEditBox::serialize( parentNode, type ); + if( node == NULL ) + return NULL; + + xmlSetProp( node, BAD_CAST "tx_tl", BAD_CAST _Pvt->_Textures[ EBDPrivate::TL ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_tr", BAD_CAST _Pvt->_Textures[ EBDPrivate::TM ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_tm", BAD_CAST _Pvt->_Textures[ EBDPrivate::TR ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_bl", BAD_CAST _Pvt->_Textures[ EBDPrivate::BL ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_bm", BAD_CAST _Pvt->_Textures[ EBDPrivate::BM ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_br", BAD_CAST _Pvt->_Textures[ EBDPrivate::BR ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_l", BAD_CAST _Pvt->_Textures[ EBDPrivate::L ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_r", BAD_CAST _Pvt->_Textures[ EBDPrivate::R ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_bg", BAD_CAST _Pvt->_Textures[ EBDPrivate::BG ]->getTexture().c_str() ); + + return node; + } + + bool CGroupEditBoxDecor::parse( xmlNodePtr cur, CInterfaceGroup *parent ) + { + if( !CGroupEditBox::parse( cur, parent ) ) + return false; + + CXMLAutoPtr prop; + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_tl" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::TL ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_tm" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::TM ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_tr" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::TR ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_bl" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::BL ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_bm" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::BM ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_br" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::BR ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_l" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::L ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_r" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::R ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_bg" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::BG ]->setTexture( ( const char* )prop ); + + return true; + } + + void CGroupEditBoxDecor::draw() + { + CGroupEditBox::draw(); + + _Pvt->draw(); + } + + void CGroupEditBoxDecor::updateCoords() + { + CGroupEditBox::updateCoords(); + _Pvt->updateCoords(); + } + + void CGroupEditBoxDecor::forceLink() + { + } +} + + diff --git a/code/nel/src/gui/link_hack.cpp b/code/nel/src/gui/link_hack.cpp index 06a8c23e8..3ecc6fb0a 100644 --- a/code/nel/src/gui/link_hack.cpp +++ b/code/nel/src/gui/link_hack.cpp @@ -20,6 +20,7 @@ #include "nel/gui/dbview_number.h" #include "nel/gui/dbview_quantity.h" #include "nel/gui/view_pointer.h" +#include "nel/gui/group_editbox_decor.h" namespace NLGUI { @@ -39,5 +40,6 @@ namespace NLGUI force_link_dbgroup_select_number_cpp(); force_link_dbgroup_combo_box_cpp(); force_link_group_wheel_cpp(); + CGroupEditBoxDecor::forceLink(); } } \ No newline at end of file diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 81fbaf28b..4591d7554 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -2436,6 +2436,9 @@ namespace NLGUI CCtrlBase *ctrl= _CtrlsUnderPointer[i]; if (ctrl && ctrl->isCapturable() && ctrl->isInGroup( pNewCurrentWnd ) ) { + if( CInterfaceElement::getEditorMode() && !ctrl->isEditorSelectable() ) + continue; + uint d = ctrl->getDepth( pNewCurrentWnd ); if (d > nMaxDepth) { @@ -2454,6 +2457,9 @@ namespace NLGUI CViewBase *v = _ViewsUnderPointer[i]; if( ( v != NULL ) && v->isInGroup( pNewCurrentWnd ) ) { + if( CInterfaceElement::getEditorMode() && !v->isEditorSelectable() ) + continue; + _CapturedView = v; captured = true; break; diff --git a/code/studio/src/plugins/gui_editor/widget_info_tree_node.h b/code/studio/src/plugins/gui_editor/widget_info_tree_node.h index 0de9e6977..8aefe6f0f 100644 --- a/code/studio/src/plugins/gui_editor/widget_info_tree_node.h +++ b/code/studio/src/plugins/gui_editor/widget_info_tree_node.h @@ -75,6 +75,10 @@ namespace GUIEditor // copy the properties to the child, since they inherit them for( std::vector< SPropEntry >::const_iterator itr = this->info.props.begin(); itr != this->info.props.end(); ++itr ) { + // Don't add property if already exists, since it's an override. + if( node->hasProperty( itr->propName ) ) + continue; + node->addProperty( *itr ); } } diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupEditBoxDecor.xml b/code/studio/src/plugins/gui_editor/widgets/GroupEditBoxDecor.xml new file mode 100644 index 000000000..67865e707 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/widgets/GroupEditBoxDecor.xml @@ -0,0 +1,68 @@ + +
+ GroupEditBoxDecor + CGroupEditBoxDecor + edit_box_decor + GroupEditBox + + false + +
+ + + w + int + 150 + + + h + int + 25 + + + tx_tl + texture + log_eb_tl.tga + + + tx_tm + texture + log_eb_t.tga + + + tx_tr + texture + log_eb_tr.tga + + + tx_bl + texture + log_eb_bl.tga + + + tx_bm + texture + log_eb_b.tga + + + tx_br + texture + log_eb_br.tga + + + tx_l + texture + log_eb_l.tga + + + tx_r + texture + log_eb_r.tga + + + tx_bg + texture + log_eb_m.tga + + +
From 274efe67987aaeff065e8a1eb2736c2d65237c1e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 16 Oct 2014 20:29:36 +0200 Subject: [PATCH 07/18] Allow selection of CGroupEditBox. --HG-- branch : dfighter-tools --- code/nel/src/gui/group_editbox.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/nel/src/gui/group_editbox.cpp b/code/nel/src/gui/group_editbox.cpp index 8c8ae867c..049222210 100644 --- a/code/nel/src/gui/group_editbox.cpp +++ b/code/nel/src/gui/group_editbox.cpp @@ -1336,6 +1336,11 @@ namespace NLGUI // if click, and not frozen, then get the focus if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && !_Frozen) { + if( getEditorMode() ) + { + return CViewBase::handleEvent( event ); + } + _SelectingText = true; stopParentBlink(); CWidgetManager::getInstance()->setCaptureKeyboard (this); From 18866c88afe0330fd28610aafc85fa1f0ff95920 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 16 Oct 2014 20:58:47 +0200 Subject: [PATCH 08/18] Update decorated edit box decoration coords while dragging. --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/group_editbox_decor.h | 2 ++ code/nel/src/gui/group_editbox_decor.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/gui/group_editbox_decor.h b/code/nel/include/nel/gui/group_editbox_decor.h index a2b540608..153f48a25 100644 --- a/code/nel/include/nel/gui/group_editbox_decor.h +++ b/code/nel/include/nel/gui/group_editbox_decor.h @@ -31,6 +31,8 @@ namespace NLGUI CGroupEditBoxDecor( const TCtorParam ¶m ); ~CGroupEditBoxDecor(); + void moveBy( sint32 x, sint32 y ); + std::string getProperty( const std::string &name ) const; void setProperty( const std::string &name, const std::string &value ); xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index 50241789e..dd6b58b66 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -150,7 +150,6 @@ namespace NLGUI _Textures[ BG ]->setParentPosRef( Hotspot_MM ); _Textures[ BG ]->setScale( true ); _Textures[ BG ]->setSizeRef( "wh" ); - _Textures[ BG ]->setRenderLayer( -1 ); } std::vector< CViewBitmap* > _Textures; @@ -171,6 +170,13 @@ namespace NLGUI _Pvt = NULL; } + void CGroupEditBoxDecor::moveBy( sint32 x, sint32 y ) + { + CInterfaceElement::moveBy( x, y ); + + _Pvt->updateCoords(); + } + std::string CGroupEditBoxDecor::getProperty( const std::string &name ) const { if( name == "tx_tl" ) From 210f93a4f28314d97975dca3b64ebd3e35a7ff96 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 16 Oct 2014 21:03:58 +0200 Subject: [PATCH 09/18] Save decorated edit box as such. --HG-- branch : dfighter-tools --- code/nel/src/gui/group_editbox_decor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index dd6b58b66..78de4ead0 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -283,6 +283,7 @@ namespace NLGUI if( node == NULL ) return NULL; + xmlSetProp( node, BAD_CAST "type", BAD_CAST "edit_box_decor" ); xmlSetProp( node, BAD_CAST "tx_tl", BAD_CAST _Pvt->_Textures[ EBDPrivate::TL ]->getTexture().c_str() ); xmlSetProp( node, BAD_CAST "tx_tr", BAD_CAST _Pvt->_Textures[ EBDPrivate::TM ]->getTexture().c_str() ); xmlSetProp( node, BAD_CAST "tx_tm", BAD_CAST _Pvt->_Textures[ EBDPrivate::TR ]->getTexture().c_str() ); From ba1e3c9919c02ccc80f80f68845c60b68a1fcaa1 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 17 Oct 2014 16:01:50 +0200 Subject: [PATCH 10/18] Fixed a typo that messed up the textures of decorated editbox. --HG-- branch : dfighter-tools --- code/nel/src/gui/group_editbox_decor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index 78de4ead0..899ea660c 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -285,8 +285,8 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "type", BAD_CAST "edit_box_decor" ); xmlSetProp( node, BAD_CAST "tx_tl", BAD_CAST _Pvt->_Textures[ EBDPrivate::TL ]->getTexture().c_str() ); - xmlSetProp( node, BAD_CAST "tx_tr", BAD_CAST _Pvt->_Textures[ EBDPrivate::TM ]->getTexture().c_str() ); - xmlSetProp( node, BAD_CAST "tx_tm", BAD_CAST _Pvt->_Textures[ EBDPrivate::TR ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_tr", BAD_CAST _Pvt->_Textures[ EBDPrivate::TR ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_tm", BAD_CAST _Pvt->_Textures[ EBDPrivate::TM ]->getTexture().c_str() ); xmlSetProp( node, BAD_CAST "tx_bl", BAD_CAST _Pvt->_Textures[ EBDPrivate::BL ]->getTexture().c_str() ); xmlSetProp( node, BAD_CAST "tx_bm", BAD_CAST _Pvt->_Textures[ EBDPrivate::BM ]->getTexture().c_str() ); xmlSetProp( node, BAD_CAST "tx_br", BAD_CAST _Pvt->_Textures[ EBDPrivate::BR ]->getTexture().c_str() ); From 923b36f0e56bba7f8a1a2637d4f5a8fa6cb2a062 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 17 Oct 2014 21:18:26 +0200 Subject: [PATCH 11/18] Create the viewtext of the decorated edit box when the box is created, also adjust it so the text is drawn to the right of the left texture. --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/group_editbox.h | 4 ++ code/nel/src/gui/group_editbox.cpp | 59 +++++++++++++----------- code/nel/src/gui/group_editbox_decor.cpp | 8 ++++ 3 files changed, 43 insertions(+), 28 deletions(-) diff --git a/code/nel/include/nel/gui/group_editbox.h b/code/nel/include/nel/gui/group_editbox.h index 7ea2ab529..771bdc482 100644 --- a/code/nel/include/nel/gui/group_editbox.h +++ b/code/nel/include/nel/gui/group_editbox.h @@ -283,6 +283,10 @@ namespace NLGUI sint32 _ViewTextDeltaX; + CViewText* getVT() const{ return _ViewText; } + + void createViewText(); + private: void setupDisplayText(); void makeTopWindow(); diff --git a/code/nel/src/gui/group_editbox.cpp b/code/nel/src/gui/group_editbox.cpp index 049222210..0dd4ffbda 100644 --- a/code/nel/src/gui/group_editbox.cpp +++ b/code/nel/src/gui/group_editbox.cpp @@ -1536,40 +1536,43 @@ namespace NLGUI CInterfaceGroup::clearViews(); } + // ---------------------------------------------------------------------------- + + void CGroupEditBox::createViewText() + { + nlwarning("Interface: CGroupEditBox: text 'edit_text' missing or bad type"); + nlwarning( "Trying to create a new 'edit_text' for %s", getId().c_str() ); + _ViewText = dynamic_cast< CViewText* >( CInterfaceFactory::createClass( "text" ) ); + if( _ViewText == NULL ) + { + nlwarning( "Failed to create new 'edit_text' for %s", getId().c_str() ); + return; + } + + _ViewText->setParent( this ); + _ViewText->setIdRecurse( "edit_text" ); + _ViewText->setHardText( "" ); + _ViewText->setPosRef( Hotspot_ML ); + _ViewText->setParentPosRef( Hotspot_ML ); + addView( _ViewText ); + + sint32 w,h; + w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() ); + h = std::max( sint32( _ViewText->getFontHeight() ), getH() ); + + setH( h ); + setW( w ); + } + // ---------------------------------------------------------------------------- void CGroupEditBox::setup() { // bind to the controls - _ViewText = dynamic_cast(CInterfaceGroup::getView("edit_text")); + if( _ViewText == NULL ) + _ViewText = dynamic_cast(CInterfaceGroup::getView("edit_text")); if(_ViewText == NULL) - { - nlwarning("Interface: CGroupEditBox: text 'edit_text' missing or bad type"); - if( editorMode ) - { - nlwarning( "Trying to create a new 'edit_text' for %s", getId().c_str() ); - _ViewText = dynamic_cast< CViewText* >( CInterfaceFactory::createClass( "text" ) ); - if( _ViewText != NULL ) - { - _ViewText->setParent( this ); - _ViewText->setIdRecurse( "edit_text" ); - _ViewText->setHardText( "" ); - _ViewText->setPosRef( Hotspot_TL ); - _ViewText->setParentPosRef( Hotspot_TL ); - addView( _ViewText ); - - sint32 w,h; - w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() ); - h = std::max( sint32( _ViewText->getFontHeight() ), getH() ); - - setH( h ); - setW( w ); - - } - else - nlwarning( "Failed to create new 'edit_text' for %s", getId().c_str() ); - } - } + createViewText(); _ViewText->setEditorSelectable( false ); diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index 899ea660c..a5a2c8239 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -18,6 +18,7 @@ #include "stdpch.h" #include "nel/gui/group_editbox_decor.h" #include "nel/gui/view_bitmap.h" +#include "nel/gui/view_text.h" namespace NLGUI { @@ -162,6 +163,10 @@ namespace NLGUI { _Pvt = new EBDPrivate(); _Pvt->setup( this ); + + createViewText(); + getVT()->setSerializable( false ); + getVT()->setEditorSelectable( false ); } CGroupEditBoxDecor::~CGroupEditBoxDecor() @@ -352,6 +357,9 @@ namespace NLGUI void CGroupEditBoxDecor::updateCoords() { + sint32 tw = _Pvt->_Textures[ EBDPrivate::L ]->getWReal(); + getVT()->setX( tw + 1 ); + CGroupEditBox::updateCoords(); _Pvt->updateCoords(); } From fd5a1a6834e6b78d5cc1179d3c75666a8b66bb98 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 17 Oct 2014 21:23:00 +0200 Subject: [PATCH 12/18] Don't add non-selectable widgets to the hierarchy tree. --HG-- branch : dfighter-tools --- code/studio/src/plugins/gui_editor/widget_hierarchy.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/studio/src/plugins/gui_editor/widget_hierarchy.cpp b/code/studio/src/plugins/gui_editor/widget_hierarchy.cpp index 343d8efd8..17e7f6e57 100644 --- a/code/studio/src/plugins/gui_editor/widget_hierarchy.cpp +++ b/code/studio/src/plugins/gui_editor/widget_hierarchy.cpp @@ -166,6 +166,9 @@ namespace GUIEditor std::vector< CCtrlBase* >::const_iterator citr; for( citr = controls.begin(); citr != controls.end(); ++citr ) { + if( !(*citr)->isEditorSelectable() ) + continue; + QTreeWidgetItem *subItem = new QTreeWidgetItem( item ); subItem->setText( 0, makeNodeName( (*citr)->getId() ).c_str() ); widgetHierarchyMap[ (*citr)->getId() ] = subItem; @@ -176,6 +179,9 @@ namespace GUIEditor std::vector< CViewBase* >::const_iterator vitr; for( vitr = views.begin(); vitr != views.end(); ++vitr ) { + if( !(*vitr)->isEditorSelectable() ) + continue; + QTreeWidgetItem *subItem = new QTreeWidgetItem( item ); subItem->setText( 0, makeNodeName( (*vitr)->getId() ).c_str() ); widgetHierarchyMap[ (*vitr)->getId() ] = subItem; From 67aa7a50d2853d827dc86400c7cf2772adafe053 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 17 Oct 2014 22:25:30 +0200 Subject: [PATCH 13/18] set the Id of the text properly when loading the decorated edit box. --HG-- branch : dfighter-tools --- code/nel/src/gui/group_editbox_decor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index a5a2c8239..fd7f1110d 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -345,6 +345,8 @@ namespace NLGUI if( prop ) _Pvt->_Textures[ EBDPrivate::BG ]->setTexture( ( const char* )prop ); + getVT()->setIdRecurse( "edit_text" ); + return true; } From 2fe207717036b79e3f80cd167e692a8436384694 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 20 Oct 2014 18:51:53 +0200 Subject: [PATCH 14/18] When setting the Id of the decorated edit box, set the Id of the text as well. --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/group_editbox_decor.h | 2 ++ code/nel/src/gui/group_editbox_decor.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/code/nel/include/nel/gui/group_editbox_decor.h b/code/nel/include/nel/gui/group_editbox_decor.h index 153f48a25..975177612 100644 --- a/code/nel/include/nel/gui/group_editbox_decor.h +++ b/code/nel/include/nel/gui/group_editbox_decor.h @@ -33,6 +33,8 @@ namespace NLGUI void moveBy( sint32 x, sint32 y ); + void setIdRecurse( const std::string &newID ); + std::string getProperty( const std::string &name ) const; void setProperty( const std::string &name, const std::string &value ); xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index fd7f1110d..ae31513de 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -182,6 +182,12 @@ namespace NLGUI _Pvt->updateCoords(); } + void CGroupEditBoxDecor::setIdRecurse( const std::string &newID ) + { + CInterfaceElement::setIdRecurse( newID ); + _ViewText->setIdRecurse( _ViewText->getShortId() ); + } + std::string CGroupEditBoxDecor::getProperty( const std::string &name ) const { if( name == "tx_tl" ) From b6d9e3285f58d8f8ce41b7c3cd7cfa60cf81b4e3 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 20 Oct 2014 20:57:08 +0200 Subject: [PATCH 15/18] DBViewNumber shouldn't crash anymore. --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/dbview_number.h | 4 +--- code/nel/include/nel/gui/interface_property.h | 9 +++++++++ code/nel/src/gui/dbview_number.cpp | 11 +++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/code/nel/include/nel/gui/dbview_number.h b/code/nel/include/nel/gui/dbview_number.h index 2c76a255d..bfa963fb6 100644 --- a/code/nel/include/nel/gui/dbview_number.h +++ b/code/nel/include/nel/gui/dbview_number.h @@ -55,9 +55,7 @@ namespace NLGUI static void forceLink(); protected: - - sint64 getVal() { if (_Modulo == 0) return (_Number.getSInt64() / _Divisor); - else return (_Number.getSInt64() / _Divisor)%_Modulo; } + sint64 getVal(); protected: diff --git a/code/nel/include/nel/gui/interface_property.h b/code/nel/include/nel/gui/interface_property.h index 63a62ef0e..4ed6e701e 100644 --- a/code/nel/include/nel/gui/interface_property.h +++ b/code/nel/include/nel/gui/interface_property.h @@ -47,6 +47,15 @@ namespace NLGUI _VolatileValue = NULL; } + /// Tells if this property has a value + bool hasValue() const + { + if( _VolatileValue != NULL ) + return true; + else + return false; + } + NLMISC::CCDBNodeLeaf* getNodePtr() const { return _VolatileValue; diff --git a/code/nel/src/gui/dbview_number.cpp b/code/nel/src/gui/dbview_number.cpp index a0b6dfb02..bd193c47d 100644 --- a/code/nel/src/gui/dbview_number.cpp +++ b/code/nel/src/gui/dbview_number.cpp @@ -249,5 +249,16 @@ namespace NLGUI { } + sint64 CDBViewNumber::getVal() + { + if( !_Number.hasValue() ) + return 0; + + if( _Modulo == 0 ) + return _Number.getSInt64() / _Divisor; + else + return ( _Number.getSInt64() / _Divisor ) % _Modulo; + } + } From 8c5ad811990b5352ce5ba94a3f68a0a6aace8b63 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 20 Oct 2014 22:21:59 +0200 Subject: [PATCH 16/18] it's not a bad idea to store the value in the right variable... --HG-- branch : dfighter-tools --- code/nel/src/gui/dbview_number.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/gui/dbview_number.cpp b/code/nel/src/gui/dbview_number.cpp index bd193c47d..e844bf4c0 100644 --- a/code/nel/src/gui/dbview_number.cpp +++ b/code/nel/src/gui/dbview_number.cpp @@ -121,7 +121,7 @@ namespace NLGUI { sint64 i; if( fromString( value, i ) ) - _Divisor = i; + _Modulo = i; return; } else From d2ca66c57477a844da0b86d9fcf4898dbaf1a837 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 20 Oct 2014 22:27:33 +0200 Subject: [PATCH 17/18] Default text for DBViewNumber. --HG-- branch : dfighter-tools --- code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml b/code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml index 36a7d23ce..99cc153ce 100644 --- a/code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml +++ b/code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml @@ -9,6 +9,11 @@ + + hardtext + string + 0 + value string From 0ac94e3e7237660c8d506043f29515e20711a840 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 20 Oct 2014 22:49:46 +0200 Subject: [PATCH 18/18] CDBViewQuantity shouldn't crash in the editor. --HG-- branch : dfighter-tools --- code/nel/src/gui/dbview_quantity.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/code/nel/src/gui/dbview_quantity.cpp b/code/nel/src/gui/dbview_quantity.cpp index ad651f582..12dfce4b8 100644 --- a/code/nel/src/gui/dbview_quantity.cpp +++ b/code/nel/src/gui/dbview_quantity.cpp @@ -157,14 +157,17 @@ namespace NLGUI // *************************************************************************** void CDBViewQuantity::draw () { - // change text - sint32 val= _Number.getSInt32(); - sint32 valMax= _NumberMax.getSInt32(); - if(_Cache!=val || _CacheMax!=valMax) + if( _Number.hasValue() && _NumberMax.hasValue() ) { - _Cache= val; - _CacheMax=valMax; - buildTextFromCache(); + // change text + sint32 val= _Number.getSInt32(); + sint32 valMax= _NumberMax.getSInt32(); + if(_Cache!=val || _CacheMax!=valMax) + { + _Cache= val; + _CacheMax=valMax; + buildTextFromCache(); + } } // parent call