From effdf45a70718a7b1844e6dad7cc08db5bef88e0 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Jul 2012 23:32:35 +0200 Subject: [PATCH] CHANGED: #1471 Buttons can now be selected in the NelGUI widget or the widget hierarchy widget, and they will become highlighted. --- code/nel/include/nel/gui/widget_manager.h | 4 ++++ code/nel/src/gui/ctrl_base_button.cpp | 6 ++++++ code/nel/src/gui/ctrl_button.cpp | 4 ++-- code/nel/src/gui/ctrl_text_button.cpp | 10 +++++++--- code/nel/src/gui/widget_manager.cpp | 18 ++++++++++++++++++ .../plugins/gui_editor/widget_hierarchy.cpp | 10 +--------- .../src/plugins/gui_editor/widget_hierarchy.h | 3 +++ 7 files changed, 41 insertions(+), 14 deletions(-) diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 763691cb7..f4c121ca7 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -480,6 +480,8 @@ namespace NLGUI const CEventDescriptorKey& getLastKeyEvent() const{ return lastKeyEvent; } IParser* getParser() const{ return parser; } + + void setCurrentEditorSelection( const std::string &name ); private: CWidgetManager(); @@ -557,6 +559,8 @@ namespace NLGUI std::vector< INewScreenSizeHandler* > newScreenSizeHandlers; std::vector< IOnWidgetsDrawnHandler* > onWidgetsDrawnHandlers; + + std::string currentEditorSelection; }; } diff --git a/code/nel/src/gui/ctrl_base_button.cpp b/code/nel/src/gui/ctrl_base_button.cpp index 2d1a61f9b..bd42a30fc 100644 --- a/code/nel/src/gui/ctrl_base_button.cpp +++ b/code/nel/src/gui/ctrl_base_button.cpp @@ -252,6 +252,12 @@ namespace NLGUI if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) return false; + if( editorMode ) + { + CWidgetManager::getInstance()->setCurrentEditorSelection( getId() ); + return true; + } + if (_LeftDblClickHandled) // no effect on mouse up after double click has been handled { _LeftDblClickHandled = false; diff --git a/code/nel/src/gui/ctrl_button.cpp b/code/nel/src/gui/ctrl_button.cpp index bda33c179..0683cf4cf 100644 --- a/code/nel/src/gui/ctrl_button.cpp +++ b/code/nel/src/gui/ctrl_button.cpp @@ -218,10 +218,10 @@ namespace NLGUI - if ( _Over && !editorMode ) + if ( ( _Over && !editorMode ) || editorSelected ) { - if ((lastOver == false) && (_AHOnOver != NULL)) + if( !editorMode && (lastOver == false) && (_AHOnOver != NULL)) CAHManager::getInstance()->runActionHandler (_AHOnOver, this, _AHOverParams); // the pointer is over the button diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index f1596ca96..f47279ad2 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -354,10 +354,14 @@ namespace NLGUI rVR.drawRotFlipBitmap ( _RenderLayer, x+_BmpLeftW, y, txw, txh, 0, false, pTxId[1], color ); rVR.drawRotFlipBitmap ( _RenderLayer, x+_BmpLeftW+txw, y, _BmpRightW, txh, 0, false, pTxId[2], color ); + CCtrlBase *capturePointerLeft = CWidgetManager::getInstance()->getCapturePointerLeft(); + // *** Draw Over - if ( !editorMode && _Over && (_OverWhenPushed || !(_Pushed || CWidgetManager::getInstance()->getCapturePointerLeft() == this))) + if( editorSelected || + ( !editorMode && _Over && (_OverWhenPushed || !(_Pushed || capturePointerLeft == this ) ) ) + ) { - if ((lastOver == false) && (_AHOnOver != NULL)) + if( !editorMode && (lastOver == false) && (_AHOnOver != NULL) ) CAHManager::getInstance()->runActionHandler (_AHOnOver, this, _AHOverParams); // the pointer is over the button. @@ -390,7 +394,7 @@ namespace NLGUI } } // Setup ViewText color - if ( pTxId==_TextureIdNormal ) + if ( pTxId==_TextureIdNormal || editorMode ) { if(_TextHeaderColor) viewTextColor.A= _TextColorNormal.A; else viewTextColor= _TextColorNormal; diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 8fd2ee3a2..bf872948b 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -3093,6 +3093,22 @@ namespace NLGUI } + void CWidgetManager::setCurrentEditorSelection( const std::string &name ) + { + CInterfaceElement *e = getElementFromId( name ); + if( e != NULL ) + { + if( !currentEditorSelection.empty() ) + { + CInterfaceElement *prev = getElementFromId( currentEditorSelection ); + if( prev != NULL ) + prev->setEditorSelected( false ); + } + e->setEditorSelected( true ); + currentEditorSelection = name; + } + } + CWidgetManager::CWidgetManager() { @@ -3127,6 +3143,8 @@ namespace NLGUI inGame = false; setScreenWH( 0, 0 ); + + currentEditorSelection = ""; } CWidgetManager::~CWidgetManager() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp index 8896cdc80..2eaa3dcd0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp @@ -127,17 +127,9 @@ namespace GUIEditor void WidgetHierarchy::onItemDblClicked( QTreeWidgetItem *item ) { - CWidgetManager *mg = CWidgetManager::getInstance(); - if( item->parent() == NULL ) return; - std::string name = item->text( 0 ).toStdString(); - CInterfaceElement *e = mg->getElementFromId( makeFullName( item, name ) ); - if( e != NULL ) - { - - } - + CWidgetManager::getInstance()->setCurrentEditorSelection( makeFullName( item, item->text( 0 ).toStdString() ) ); } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h index 2797dfef6..b28f994c4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h @@ -43,6 +43,9 @@ namespace GUIEditor private Q_SLOTS: void onItemDblClicked( QTreeWidgetItem *item ); + + private: + std::string currentSelection; }; }