Browse Source

Updated buttons on Unsaved Modification window

rsredsq 10 years ago
parent
commit
7cdfe31a16

+ 1 - 0
Resources/EditorData/AtomicEditor/resources/language/lng_en.tb.txt

@@ -14,3 +14,4 @@ new New
 save Save
 save Save
 close Close
 close Close
 search Search
 search Search
+dont_save Don't save

+ 13 - 3
Source/AtomicEditor/Editors/ResourceEditor.cpp

@@ -42,11 +42,15 @@ public:
         if (editor_->HasUnsavedModifications())
         if (editor_->HasUnsavedModifications())
         {
         {
             TBMessageWindow *msg_win = new TBMessageWindow(this, TBIDC("unsaved_modifications_dialog"));
             TBMessageWindow *msg_win = new TBMessageWindow(this, TBIDC("unsaved_modifications_dialog"));
-            TBMessageWindowSettings settings(TB_MSG_OK_CANCEL, TBID(uint32(0)));
+            TBMessageWindowSettings settings(TB_MSG_NONE, TBID(uint32(0)));
             settings.dimmer = true;
             settings.dimmer = true;
             settings.styling = true;
             settings.styling = true;
             String windowString = Atomic::ToString("%s has unsaved modifications.\nDo you wish to discard them and close?", GetFileNameAndExtension(editor_->GetFullPath()).CString());
             String windowString = Atomic::ToString("%s has unsaved modifications.\nDo you wish to discard them and close?", GetFileNameAndExtension(editor_->GetFullPath()).CString());
             msg_win->Show("Unsaved Modifications",  windowString.CString(), &settings, 640, 360);
             msg_win->Show("Unsaved Modifications",  windowString.CString(), &settings, 640, 360);
+            TBButton *btn = new TBButton();
+            msg_win->AddButton("dont_save", false, msg_win->GetWidgetByIDAndType<TBLayout>(5));
+            msg_win->AddButton("TBMessageWindow.cancel", false);
+            msg_win->AddButton("save", true);
             return false;
             return false;
         }
         }
         else
         else
@@ -62,16 +66,22 @@ public:
         {
         {
             if (ev.target->GetID() == TBIDC("unsaved_modifications_dialog"))
             if (ev.target->GetID() == TBIDC("unsaved_modifications_dialog"))
             {
             {
-                if (ev.ref_id == TBIDC("TBMessageWindow.ok"))
+                if (ev.ref_id == TBIDC("dont_save"))
                 {
                 {
                     container_->OnEvent(ev);
                     container_->OnEvent(ev);
                     editor_->Close(container_->GetNumPages()>1);
                     editor_->Close(container_->GetNumPages()>1);
                 }
                 }
-                else
+                else if (ev.ref_id == TBIDC("cancel"))
                 {
                 {
                     editor_->SendEvent(E_EDITORRESOURCECLOSECANCELED);
                     editor_->SendEvent(E_EDITORRESOURCECLOSECANCELED);
                     SetFocus(WIDGET_FOCUS_REASON_UNKNOWN);
                     SetFocus(WIDGET_FOCUS_REASON_UNKNOWN);
                 }
                 }
+                else if (ev.ref_id == TBIDC("save"))
+                {
+                    editor_->Save();
+                    container_->OnEvent(ev);
+                    editor_->Close(container_->GetNumPages()>1);
+                }
                 return true;
                 return true;
             }
             }
             if (ev.target->GetID() == TBIDC("tabclose"))
             if (ev.target->GetID() == TBIDC("tabclose"))

+ 14 - 8
Source/ThirdParty/TurboBadger/tb_message_window.cpp

@@ -42,11 +42,14 @@ bool TBMessageWindow::Show(const char *title, const char *message, TBMessageWind
 
 
 	TBWidget *root = target->GetParentRoot();
 	TBWidget *root = target->GetParentRoot();
 
 
-	const char *source =	"TBLayout: axis: y, distribution: available\n"
-							"	TBLayout: distribution: available, size: available\n"
-							"		TBSkinImage: id: 2\n"
-							"		TBEditField: multiline: 1, readonly: 1, id: 1\n"
-							"	TBLayout: distribution-position: right bottom, id: 3\n";
+    const char *source =    "TBLayout: axis: y, distribution: available\n"
+                            "	TBLayout: distribution: available, size: available\n"
+                            "		TBSkinImage: id: 2\n"
+                            "		TBEditField: multiline: 1, readonly: 1, id: 1\n"
+                            "	TBLayout: distribution: available\n"
+                            "		TBLayout: distribution-position: left top, id: 5\n"
+                            "		TBLayout: distribution-position: right bottom, id: 3\n";
+
 	if (!g_widgets_reader->LoadData(GetContentRoot(), source))
 	if (!g_widgets_reader->LoadData(GetContentRoot(), source))
 		return false;
 		return false;
 
 
@@ -113,12 +116,15 @@ bool TBMessageWindow::Show(const char *title, const char *message, TBMessageWind
 	return true;
 	return true;
 }
 }
 
 
-void TBMessageWindow::AddButton(TBID id, bool focused)
+void TBMessageWindow::AddButton(TBID id, bool focused, TBLayout *layout)
 {
 {
-	TBLayout *layout = GetWidgetByIDAndType<TBLayout>(3);
+    if (!layout) 
+	    layout = GetWidgetByIDAndType<TBLayout>(3);
+
 	if (!layout)
 	if (!layout)
 		return;
 		return;
-	if (TBButton *btn = new TBButton)
+	
+    if (TBButton *btn = new TBButton)
 	{
 	{
 		btn->SetID(id);
 		btn->SetID(id);
 		btn->SetText(g_tb_lng->GetString(btn->GetID()));
 		btn->SetText(g_tb_lng->GetString(btn->GetID()));

+ 3 - 1
Source/ThirdParty/TurboBadger/tb_message_window.h

@@ -12,6 +12,7 @@
 namespace tb {
 namespace tb {
 
 
 enum TB_MSG {
 enum TB_MSG {
+    TB_MSG_NONE,
 	TB_MSG_OK,
 	TB_MSG_OK,
 	TB_MSG_OK_CANCEL,
 	TB_MSG_OK_CANCEL,
 	TB_MSG_YES_NO
 	TB_MSG_YES_NO
@@ -54,8 +55,9 @@ public:
 
 
 	virtual bool OnEvent(const TBWidgetEvent &ev);
 	virtual bool OnEvent(const TBWidgetEvent &ev);
 	virtual void OnDie();
 	virtual void OnDie();
+
+    void AddButton(TBID id, bool focused, TBLayout *layout = NULL);
 private:
 private:
-	void AddButton(TBID id, bool focused);
 	// TBWidgetListener
 	// TBWidgetListener
 	virtual void OnWidgetDelete(TBWidget *widget);
 	virtual void OnWidgetDelete(TBWidget *widget);
 	virtual bool OnWidgetDying(TBWidget *widget);
 	virtual bool OnWidgetDying(TBWidget *widget);