diff --git a/Projects/Editor/Source/Editor/Space/Assets/CContextMenuFS.cpp b/Projects/Editor/Source/Editor/Space/Assets/CContextMenuFS.cpp index b5f418117..5fa8fb6ed 100644 --- a/Projects/Editor/Source/Editor/Space/Assets/CContextMenuFS.cpp +++ b/Projects/Editor/Source/Editor/Space/Assets/CContextMenuFS.cpp @@ -33,9 +33,11 @@ namespace Skylicht namespace Editor { CContextMenuFS::CContextMenuFS(GUI::CCanvas* canvas, GUI::CTreeControl* tree, GUI::CListBox* list, CListFSController* listFSController) : + m_canvas(canvas), m_treeFS(tree), m_listFS(list), - m_listFSController(listFSController) + m_listFSController(listFSController), + m_msgBox(NULL) { m_contextMenu = new GUI::CMenu(canvas); m_contextMenu->setHidden(true); @@ -44,10 +46,10 @@ namespace Skylicht m_open = m_contextMenu->addItem(L"Open"); m_contextMenu->addItem(L"Show in Explorer"); m_contextMenu->addSeparator(); - m_contextMenu->addItem(L"Delete"); + m_contextMenu->addItem(L"Delete", GUI::ESystemIcon::Trash); m_contextMenu->addItem(L"Rename", L"F2"); - m_contextMenu->addItem(L"Copy path", L"SHIFT + C"); - m_contextMenu->addItem(L"Duplicate", L"CTRL + D"); + m_contextMenu->addItem(L"Copy path", GUI::ESystemIcon::Copy, L"SHIFT + C"); + m_contextMenu->addItem(L"Duplicate", GUI::ESystemIcon::Duplicate, L"CTRL + D"); m_treeFS->addAccelerator("SHIFT + C", BIND_LISTENER(&CContextMenuFS::OnCopyPath, this)); m_listFS->addAccelerator("SHIFT + C", BIND_LISTENER(&CContextMenuFS::OnCopyPath, this)); @@ -119,6 +121,8 @@ namespace Skylicht } else if (label == L"Delete") { + // m_msgBox = new GUI::CMessageBox(m_canvas); + if (m_assetManager->deleteAsset(m_selectedPath.c_str())) m_listFSController->refresh(); } diff --git a/Projects/Editor/Source/Editor/Space/Assets/CContextMenuFS.h b/Projects/Editor/Source/Editor/Space/Assets/CContextMenuFS.h index c41172ab7..0a8bb2fc7 100644 --- a/Projects/Editor/Source/Editor/Space/Assets/CContextMenuFS.h +++ b/Projects/Editor/Source/Editor/Space/Assets/CContextMenuFS.h @@ -35,6 +35,8 @@ namespace Skylicht class CContextMenuFS { protected: + GUI::CCanvas* m_canvas; + GUI::CTreeControl* m_treeFS; GUI::CListBox* m_listFS; @@ -53,6 +55,8 @@ namespace Skylicht std::string m_selectedPath; + GUI::CMessageBox* m_msgBox; + public: CContextMenuFS(GUI::CCanvas* canvas, GUI::CTreeControl* tree, GUI::CListBox* list, CListFSController* listFSController); diff --git a/Projects/Editor/Source/Editor/Space/Assets/CTreeFSController.cpp b/Projects/Editor/Source/Editor/Space/Assets/CTreeFSController.cpp index 0b0387491..54bebb847 100644 --- a/Projects/Editor/Source/Editor/Space/Assets/CTreeFSController.cpp +++ b/Projects/Editor/Source/Editor/Space/Assets/CTreeFSController.cpp @@ -137,7 +137,7 @@ namespace Skylicht wchar_t wname[512]; - for (u32 i = 0, n = result.size(); i < n; i++) + for (u32 i = 0, n = (u32)result.size(); i < n; i++) { const std::string name = result[i]; CStringImp::convertUTF8ToUnicode(name.c_str(), wname); diff --git a/Projects/Editor/Source/GUI/Controls/CButton.h b/Projects/Editor/Source/GUI/Controls/CButton.h index 5b8cea718..edfc12e50 100644 --- a/Projects/Editor/Source/GUI/Controls/CButton.h +++ b/Projects/Editor/Source/GUI/Controls/CButton.h @@ -36,8 +36,8 @@ namespace Skylicht class CButton : public CBase { protected: - CIcon *m_icon; - CTextContainer *m_label; + CIcon* m_icon; + CTextContainer* m_label; SGUIColor m_color; SGUIColor m_hoverColor; @@ -60,7 +60,7 @@ namespace Skylicht Listener OnRightPress; public: - CButton(CBase *parent); + CButton(CBase* parent); virtual ~CButton(); virtual void onBoundsChanged(const SRect& oldBounds); @@ -105,6 +105,11 @@ namespace Skylicht m_label->setHidden(!b); } + inline void setTextAlignment(GUI::ETextAlign alignment) + { + m_label->setTextAlignment(alignment); + } + inline EFontSize getFontSize() { return m_label->getFontSize(); diff --git a/Projects/Editor/Source/GUI/Controls/CDialogWindow.cpp b/Projects/Editor/Source/GUI/Controls/CDialogWindow.cpp index cf2855474..81f364729 100644 --- a/Projects/Editor/Source/GUI/Controls/CDialogWindow.cpp +++ b/Projects/Editor/Source/GUI/Controls/CDialogWindow.cpp @@ -80,13 +80,16 @@ namespace Skylicht m_blinkTime = 0.0f; } - if (m_blink % 2 == 0) + if (m_title != NULL) { - m_title->setColor(CThemeConfig::DefaultTextColor); - } - else - { - m_title->setColor(CThemeConfig::DisableTextColor); + if (m_blink % 2 == 0) + { + m_title->setColor(CThemeConfig::DefaultTextColor); + } + else + { + m_title->setColor(CThemeConfig::DisableTextColor); + } } } } diff --git a/Projects/Editor/Source/GUI/Controls/CMessageBox.cpp b/Projects/Editor/Source/GUI/Controls/CMessageBox.cpp new file mode 100644 index 000000000..de628b3f2 --- /dev/null +++ b/Projects/Editor/Source/GUI/Controls/CMessageBox.cpp @@ -0,0 +1,114 @@ +/* +!@ +MIT License + +Copyright (c) 2021 Skylicht Technology CO., LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This file is part of the "Skylicht Engine". +https://github.com/skylicht-lab/skylicht-engine +!# +*/ + +#include "pch.h" +#include "GUI/Theme/CThemeConfig.h" +#include "CMessageBox.h" + +namespace Skylicht +{ + namespace Editor + { + namespace GUI + { + CMessageBox::CMessageBox(CBase* base) : + CDialogWindow(base, 0.0f, 0.0f, 465.0f, 120.0f) + { + m_titleBar->remove(); + m_titleBar = NULL; + m_icon = NULL; + m_title = NULL; + + m_innerPanel->remove(); + m_innerPanel = NULL; + + CDragger* dragger = new CDragger(this); + dragger->setClampInsideParent(false); + + m_innerPanel = dragger; + m_innerPanel->setPadding(SPadding(0.0f, 0.0f, 0.0f, 0.0f)); + m_innerPanel->setMargin(SMargin(0.0f, 0.0f, 0.0f, 0.0f)); + m_innerPanel->dock(EPosition::Fill); + + m_msgIcon = new CIcon(this, ESystemIcon::Info, true); + m_msgIcon->dock(EPosition::Left); + m_msgIcon->setMargin(SPadding(15.0f, 15.0f, 0.0f, 0.0f)); + m_msgIcon->setTransparentMouseInput(true); + + CBase* content = new CBase(this); + content->dock(EPosition::Fill); + content->setMargin(SPadding(10.0f, 20.0f, 15.0f, 0.0f)); + content->setTransparentMouseInput(true); + + m_info1 = new CLabel(content); + m_info1->dock(EPosition::Top); + m_info1->setString("Message Content"); + m_info1->sizeToContents(); + + m_info2 = new CLabel(content); + m_info2->dock(EPosition::Top); + m_info2->setMargin(SPadding(0.0f, 5.0f, 0.0f, 0.0f)); + m_info2->setString("Target"); + m_info2->setColor(CThemeConfig::ButtonTextDisableColor); + m_info2->sizeToContents(); + + CBase* bottom = new CBase(content); + bottom->dock(EPosition::Top); + bottom->setMargin(SPadding(0.0f, 20.0f, 0.0f, 0.0f)); + bottom->setHeight(20.0f); + bottom->setTransparentMouseInput(true); + + m_cancel = new CButton(bottom); + m_cancel->setWidth(110.0f); + m_cancel->setLabel(L"Cancel"); + m_cancel->dock(EPosition::Right); + m_cancel->setTextAlignment(ETextAlign::TextCenter); + m_cancel->OnPress = [dialog = this](CBase* control) { + dialog->onCloseButtonPress(control); + }; + + m_no = new CButton(bottom); + m_no->setWidth(110.0f); + m_no->setLabel(L"No"); + m_no->dock(EPosition::Right); + m_no->setTextAlignment(ETextAlign::TextCenter); + m_no->setMargin(SPadding(0.0f, 0.0f, 10.0f, 0.0f)); + + m_yes = new CButton(bottom); + m_yes->setWidth(110.0f); + m_yes->setLabel(L"Yes"); + m_yes->dock(EPosition::Right); + m_yes->setTextAlignment(ETextAlign::TextCenter); + m_yes->setMargin(SPadding(0.0f, 0.0f, 10.0f, 0.0f)); + + setCenterPosition(); + } + + CMessageBox::~CMessageBox() + { + + } + } + } +} \ No newline at end of file diff --git a/Projects/Editor/Source/GUI/Controls/CMessageBox.h b/Projects/Editor/Source/GUI/Controls/CMessageBox.h new file mode 100644 index 000000000..a17c016b3 --- /dev/null +++ b/Projects/Editor/Source/GUI/Controls/CMessageBox.h @@ -0,0 +1,55 @@ +/* +!@ +MIT License + +Copyright (c) 2021 Skylicht Technology CO., LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This file is part of the "Skylicht Engine". +https://github.com/skylicht-lab/skylicht-engine +!# +*/ + +#pragma once + +#include "CDialogWindow.h" +#include "CButton.h" + +namespace Skylicht +{ + namespace Editor + { + namespace GUI + { + class CMessageBox : public CDialogWindow + { + protected: + CIcon* m_msgIcon; + + CLabel* m_info1; + CLabel* m_info2; + + CButton* m_yes; + CButton* m_no; + CButton* m_cancel; + + public: + CMessageBox(CBase* base); + + virtual ~CMessageBox(); + }; + } + } +} \ No newline at end of file diff --git a/Projects/Editor/Source/GUI/GUI.h b/Projects/Editor/Source/GUI/GUI.h index 2e889944a..22398726c 100644 --- a/Projects/Editor/Source/GUI/GUI.h +++ b/Projects/Editor/Source/GUI/GUI.h @@ -47,4 +47,5 @@ This file is part of the "Skylicht Engine". #include "GUI/Controls/CCollapsibleGroup.h" #include "GUI/Controls/CBoxLayout.h" #include "GUI/Controls/CContentSizeControl.h" -#include "GUI/Controls/CProgressBar.h" \ No newline at end of file +#include "GUI/Controls/CProgressBar.h" +#include "GUI/Controls/CMessageBox.h" \ No newline at end of file