Index: binaries/data/tools/atlas/toolbar/save.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: binaries/data/tools/atlas/toolbar/save.png
===================================================================
--- binaries/data/tools/atlas/toolbar/save.png	(revision 0)
+++ binaries/data/tools/atlas/toolbar/save.png	(working copy)

Property changes on: binaries/data/tools/atlas/toolbar/save.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.cpp
===================================================================
--- source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.cpp	(revision 15094)
+++ source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.cpp	(working copy)
@@ -71,7 +71,7 @@
 
 ToolButtonBar::ToolButtonBar(ToolManager& toolManager, wxWindow* parent, SectionLayout* sectionLayout, int baseID, long style)
 : wxToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style)
-, m_ToolManager(toolManager), m_SectionLayout(sectionLayout), m_Id(baseID), m_Size(-1)
+, m_ToolManager(toolManager), m_SectionLayout(sectionLayout), m_Id(baseID), m_Size(-1), m_IdAction(baseID)
 {
 	/* "msw.remap: If 1 (the default), wxToolBar bitmap colours will be remapped
 	   to the current theme's values. Set this to 0 to disable this functionality,
@@ -79,6 +79,39 @@
 	wxSystemOptions::SetOption(wxT("msw.remap"), 0); // (has global effect)
 }
 
+void ToolButtonBar::AddToolAction(const wxString& shortLabel, const wxString& longLabel,
+								  const wxString& iconPNGFilename, fnAction action)
+{
+	wxFileName iconPath(_T("tools/atlas/toolbar/"));
+	iconPath.MakeAbsolute(Datafile::GetDataDirectory());
+	iconPath.SetFullName(iconPNGFilename);
+	wxFFileInputStream fstr(iconPath.GetFullPath());
+	if (!fstr.Ok())
+	{
+		wxLogError(_("Failed to open toolbar icon file '%s'"), iconPath.GetFullPath().c_str());
+		return;
+	}
+	wxImage img(fstr, wxBITMAP_TYPE_PNG);
+	if (!img.Ok())
+	{
+		wxLogError(_("Failed to load toolbar icon image '%s'"), iconPath.GetFullPath().c_str());
+		return;
+	}
+
+	if (m_Size == -1)
+	{
+		m_Size = img.GetWidth();
+		SetToolBitmapSize(wxSize(m_Size, m_Size));
+	}
+
+	if (img.GetWidth() != m_Size || img.GetHeight() != m_Size)
+		img = img.Scale(m_Size, m_Size);
+
+	AddTool(1000 + m_IdAction, wxBitmap(img), shortLabel, longLabel);
+	m_ButtonsActions[m_IdAction] = ButtonAction(action);
+
+	++m_IdAction;
+}
 void ToolButtonBar::AddToolButton(const wxString& shortLabel, const wxString& longLabel,
 								  const wxString& iconPNGFilename, const wxString& toolName,
 								  const wxString& sectionPage)
@@ -86,14 +119,14 @@
 	wxFileName iconPath (_T("tools/atlas/toolbar/"));
 	iconPath.MakeAbsolute(Datafile::GetDataDirectory());
 	iconPath.SetFullName(iconPNGFilename);
-	wxFFileInputStream fstr (iconPath.GetFullPath());
-	if (! fstr.Ok())
+	wxFFileInputStream fstr(iconPath.GetFullPath());
+	if (!fstr.Ok())
 	{
 		wxLogError(_("Failed to open toolbar icon file '%s'"), iconPath.GetFullPath().c_str());
 		return;
 	}
-	wxImage img (fstr, wxBITMAP_TYPE_PNG);
-	if (! img.Ok())
+	wxImage img(fstr, wxBITMAP_TYPE_PNG);
+	if (!img.Ok())
 	{
 		wxLogError(_("Failed to load toolbar icon image '%s'"), iconPath.GetFullPath().c_str());
 		return;
@@ -118,9 +151,22 @@
 
 void ToolButtonBar::OnTool(wxCommandEvent& evt)
 {
-	std::map<int, Button>::iterator it = m_Buttons.find(evt.GetId());
-	wxCHECK_RET(it != m_Buttons.end(), _T("Invalid toolbar button"));
-	m_ToolManager.SetCurrentTool(it->second.name);
-	if (! it->second.sectionPage.IsEmpty())
-		m_SectionLayout->SelectPage(it->second.sectionPage);
-}
+	int action = evt.GetId();
+	if(action >= 1000)
+	{
+		//is an action
+		action-=1000;
+		
+		std::map<int, ButtonAction>::iterator it = m_ButtonsActions.find(action);
+		wxCHECK_RET(it != m_ButtonsActions.end(), _T("Invalid toolbar button"));
+		it->second.m_function();
+	} 
+	else 
+	{	
+		std::map<int, Button>::iterator it = m_Buttons.find(action);
+		wxCHECK_RET(it != m_Buttons.end(), _T("Invalid toolbar button"));
+		m_ToolManager.SetCurrentTool(it->second.name);
+		if (! it->second.sectionPage.IsEmpty())
+			m_SectionLayout->SelectPage(it->second.sectionPage);
+	}
+}
\ No newline at end of file
Index: source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.h
===================================================================
--- source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.h	(revision 15094)
+++ source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.h	(working copy)
@@ -18,11 +18,14 @@
 //#include "wx/tglbtn.h"
 
 #include <map>
+#include <boost/function.hpp>
 
 class ITool;
 class SectionLayout;
 class ToolManager;
 
+typedef boost::function<void()> fnAction;
+
 class ToolButton : public wxButton
 {
 public:
@@ -47,7 +50,16 @@
 	ToolButtonBar(ToolManager& toolManager, wxWindow* parent, SectionLayout* sectionLayout, int baseID, long style);
 	void AddToolButton(const wxString& shortLabel, const wxString& longLabel,
 		const wxString& iconPNGFilename, const wxString& toolName, const wxString& sectionPage);
+	void AddToolAction(const wxString& shortLabel, const wxString& longLabel,
+		const wxString& iconPNGFilename, fnAction fn);
 
+	struct ButtonAction
+	{
+		ButtonAction(){}
+		ButtonAction(fnAction action):m_function(action){}
+		fnAction m_function;
+	};
+
 protected:
 	void OnTool(wxCommandEvent& evt);
 
@@ -54,6 +66,7 @@
 private:
 	ToolManager& m_ToolManager;
 	int m_Id;
+	int m_IdAction;
 	int m_Size;
 	struct Button
 	{
@@ -62,7 +75,9 @@
 		wxString name;
 		wxString sectionPage;
 	};
+	
 	std::map<int, Button> m_Buttons;
+	std::map<int, ButtonAction> m_ButtonsActions;
 	SectionLayout* m_SectionLayout;
 
 	DECLARE_EVENT_TABLE();
Index: source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp
===================================================================
--- source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp	(revision 15094)
+++ source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp	(working copy)
@@ -46,6 +46,8 @@
 #include "Tools/Common/Brushes.h"
 #include "Tools/Common/MiscState.h"
 
+#include <boost/bind.hpp>
+
 static HighResTimer g_Timer;
 
 using namespace AtlasMessage;
@@ -543,6 +545,8 @@
 	ToolButtonBar* toolbar = new ToolButtonBar(m_ToolManager, this, &m_SectionLayout, id, style);
 	// TODO: configurable small vs large icon images
 
+	toolbar->AddToolAction(_("Save"), _("Save"), _T("save.png"), boost::bind(&ScenarioEditor::OnToolSave,this));
+	toolbar->AddSeparator();
 	// (button label; tooltip text; image; internal tool name; section to switch to)
 	toolbar->AddToolButton(_("Default"),       _("Default"),                   _T("default.png"),          _T(""),                 _T(""));
 	toolbar->AddToolButton(_("Move"),          _("Move/rotate object"),        _T("moveobject.png"),       _T("TransformObject"),  _T("")/*_T("ObjectSidebar")*/);
@@ -713,6 +717,12 @@
 	}
 }
 
+void ScenarioEditor::OnToolSave()
+{
+	wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED,ID_Save);
+	this->AddPendingEvent(evt);
+}
+
 void ScenarioEditor::OnSave(wxCommandEvent& event)
 {
 	if (m_OpenFilename.IsEmpty())
Index: source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h
===================================================================
--- source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h	(revision 15094)
+++ source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h	(working copy)
@@ -35,6 +35,8 @@
 	void OnTimer(wxTimerEvent& event);
 	void OnIdle(wxIdleEvent& event);
 	wxToolBar* OnCreateToolBar(long style, wxWindowID id, const wxString &name);
+
+	void OnToolSave();
 	
  	void OnNew(wxCommandEvent& event);
 	void OnOpen(wxCommandEvent& event);
