From 7caa7e8b55521bddfb0ee4a683c24715a0baaec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Tue, 17 Dec 2019 02:18:58 -0300 Subject: [PATCH] Fixed modal UIWindow. --HG-- branch : dev --- include/eepp/ui/uimessagebox.hpp | 6 ++++-- src/eepp/ui/uimessagebox.cpp | 8 ++++---- src/eepp/ui/uiwindow.cpp | 1 - src/tools/mapeditor/mapeditor.cpp | 4 ++-- src/tools/textureatlaseditor/textureatlaseditor.cpp | 4 ++-- src/tools/uieditor/uieditor.cpp | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/eepp/ui/uimessagebox.hpp b/include/eepp/ui/uimessagebox.hpp index a649569f2..444c98f71 100644 --- a/include/eepp/ui/uimessagebox.hpp +++ b/include/eepp/ui/uimessagebox.hpp @@ -7,6 +7,8 @@ namespace EE { namespace UI { +#define UI_MESSAGE_BOX_DEFAULT_FLAGS UI_WIN_CLOSE_BUTTON | UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS | UI_WIN_MODAL | UI_WIN_SHARE_ALPHA_WITH_CHILDS + class EE_API UIMessageBox : public UIWindow { public: enum Type { @@ -16,9 +18,9 @@ class EE_API UIMessageBox : public UIWindow { OK }; - static UIMessageBox * New( Type type, String message ); + static UIMessageBox * New( const Type& type, const String& message, const Uint32& windowFlags = UI_MESSAGE_BOX_DEFAULT_FLAGS ); - UIMessageBox( Type type, String message ); + UIMessageBox( const Type& type, const String& message, const Uint32& windowFlags = UI_MESSAGE_BOX_DEFAULT_FLAGS ); virtual ~UIMessageBox(); diff --git a/src/eepp/ui/uimessagebox.cpp b/src/eepp/ui/uimessagebox.cpp index f48c6f0c4..e0adcd3d2 100644 --- a/src/eepp/ui/uimessagebox.cpp +++ b/src/eepp/ui/uimessagebox.cpp @@ -5,16 +5,16 @@ namespace EE { namespace UI { -UIMessageBox * UIMessageBox::New( UIMessageBox::Type type, String message) { - return eeNew( UIMessageBox, ( type, message ) ); +UIMessageBox * UIMessageBox::New( const Type& type, const String& message, const Uint32& windowFlags ) { + return eeNew( UIMessageBox, ( type, message, windowFlags ) ); } -UIMessageBox::UIMessageBox( UIMessageBox::Type type , String message ) : +UIMessageBox::UIMessageBox( const Type& type, const String& message, const Uint32& windowFlags ) : UIWindow(), mMsgBoxType( type ), mCloseWithKey( KEY_UNKNOWN ) { - mStyleConfig.WinFlags &= ~UI_WIN_RESIZEABLE; + mStyleConfig.WinFlags = windowFlags; updateWinFlags(); diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index 175cb4df5..aa2ac09fa 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -372,7 +372,6 @@ void UIWindow::createModalControl() { if ( NULL == mModalCtrl ) { mModalCtrl = UIWidget::NewWithTag( "window::modaldialog" ); - mModalCtrl->writeNodeFlag( NODE_FLAG_OWNED_BY_NODE, 1 ); mModalCtrl->setParent( Ctrl )->setPosition(0,0)->setSize( Ctrl->getSize() ); mModalCtrl->setAnchors( UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ); } else { diff --git a/src/tools/mapeditor/mapeditor.cpp b/src/tools/mapeditor/mapeditor.cpp index 550cb24cb..51871ff81 100644 --- a/src/tools/mapeditor/mapeditor.cpp +++ b/src/tools/mapeditor/mapeditor.cpp @@ -7,8 +7,8 @@ MapEditor * Editor = NULL; bool onCloseRequestCallback( EE::Window::Window * w ) { if ( NULL != Editor ) { MsgBox = UIMessageBox::New( UIMessageBox::OK_CANCEL, "Do you really want to close the current map?\nAll changes will be lost." ); - MsgBox->addEventListener( Event::MsgBoxConfirmClick, cb::Make1( []( const Event * event ) { win->close(); } ) ); - MsgBox->addEventListener( Event::OnClose, cb::Make1( []( const Event * event ) { MsgBox = NULL; } ) ); + MsgBox->addEventListener( Event::MsgBoxConfirmClick, []( const Event * event ) { win->close(); } ); + MsgBox->addEventListener( Event::OnClose, []( const Event * event ) { MsgBox = NULL; } ); MsgBox->setTitle( "Close Map?" ); MsgBox->center(); MsgBox->show(); diff --git a/src/tools/textureatlaseditor/textureatlaseditor.cpp b/src/tools/textureatlaseditor/textureatlaseditor.cpp index 30588a9b5..d3aeb1f6f 100644 --- a/src/tools/textureatlaseditor/textureatlaseditor.cpp +++ b/src/tools/textureatlaseditor/textureatlaseditor.cpp @@ -7,8 +7,8 @@ TextureAtlasEditor * Editor = NULL; bool onCloseRequestCallback( EE::Window::Window * w ) { if ( NULL != Editor && Editor->isEdited() ) { MsgBox = UIMessageBox::New( UIMessageBox::OK_CANCEL, "Do you really want to close the texture atlas editor?\nAll changes will be lost." ); - MsgBox->addEventListener( Event::MsgBoxConfirmClick, cb::Make1( []( const Event * event ) { win->close(); } ) ); - MsgBox->addEventListener( Event::OnClose, cb::Make1( []( const Event * event ) { MsgBox = NULL; } ) ); + MsgBox->addEventListener( Event::MsgBoxConfirmClick, []( const Event * event ) { win->close(); } ); + MsgBox->addEventListener( Event::OnClose, []( const Event * event ) { MsgBox = NULL; } ); MsgBox->setTitle( "Close Texture Atlas Editor?" ); MsgBox->center(); MsgBox->show(); diff --git a/src/tools/uieditor/uieditor.cpp b/src/tools/uieditor/uieditor.cpp index 569c5f828..bff2ddeab 100644 --- a/src/tools/uieditor/uieditor.cpp +++ b/src/tools/uieditor/uieditor.cpp @@ -695,8 +695,8 @@ bool onCloseRequestCallback( EE::Window::Window * ) { MsgBox = UIMessageBox::New( UIMessageBox::OK_CANCEL, "Do you really want to close the current file?\nAll changes will be lost." ); MsgBox->setTheme( theme ); - MsgBox->addEventListener( Event::MsgBoxConfirmClick, cb::Make1( []( const Event * ) { window->close(); } ) ); - MsgBox->addEventListener( Event::OnClose, cb::Make1( []( const Event * ) { MsgBox = NULL; } ) ); + MsgBox->addEventListener( Event::MsgBoxConfirmClick, []( const Event * ) { window->close(); } ); + MsgBox->addEventListener( Event::OnClose, []( const Event * ) { MsgBox = NULL; } ); MsgBox->setTitle( "Close Editor?" ); MsgBox->center(); MsgBox->show();