Changes Atlas toolbar construction to use CreateToolBar instead of explicitly setting it (which doesn't work on wxOSX 2.9).

Adds a call to Atlas_GLSetCurrent after setting Atlas resolution on OS X
(otherwise the canvas doesn't seem to update properly).

This was SVN commit r10129.
This commit is contained in:
historic_bruno 2011-08-28 21:10:45 +00:00
parent c1b6b6d76e
commit 769a927446
5 changed files with 37 additions and 20 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2009 Wildfire Games. /* Copyright (C) 2011 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -69,8 +69,8 @@ BEGIN_EVENT_TABLE(ToolButtonBar, wxToolBar)
EVT_TOOL(wxID_ANY, ToolButtonBar::OnTool) EVT_TOOL(wxID_ANY, ToolButtonBar::OnTool)
END_EVENT_TABLE() END_EVENT_TABLE()
ToolButtonBar::ToolButtonBar(ToolManager& toolManager, wxWindow* parent, SectionLayout* sectionLayout, int baseID) ToolButtonBar::ToolButtonBar(ToolManager& toolManager, wxWindow* parent, SectionLayout* sectionLayout, int baseID, long style)
: wxToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTB_FLAT|wxTB_HORIZONTAL) : 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)
{ {
/* "msw.remap: If 1 (the default), wxToolBar bitmap colours will be remapped /* "msw.remap: If 1 (the default), wxToolBar bitmap colours will be remapped

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2009 Wildfire Games. /* Copyright (C) 2011 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -44,7 +44,7 @@ private:
class ToolButtonBar : public wxToolBar class ToolButtonBar : public wxToolBar
{ {
public: public:
ToolButtonBar(ToolManager& toolManager, wxWindow* parent, SectionLayout* sectionLayout, int baseID); ToolButtonBar(ToolManager& toolManager, wxWindow* parent, SectionLayout* sectionLayout, int baseID, long style);
void AddToolButton(const wxString& shortLabel, const wxString& longLabel, void AddToolButton(const wxString& shortLabel, const wxString& longLabel,
const wxString& iconPNGFilename, const wxString& toolName, const wxString& sectionPage); const wxString& iconPNGFilename, const wxString& toolName, const wxString& sectionPage);

View File

@ -31,9 +31,9 @@
#include "General/AtlasEventLoop.h" #include "General/AtlasEventLoop.h"
#include "General/Datafile.h" #include "General/Datafile.h"
#include "CustomControls/HighResTimer/HighResTimer.h"
#include "CustomControls/Buttons/ToolButton.h" #include "CustomControls/Buttons/ToolButton.h"
#include "CustomControls/Canvas/Canvas.h" #include "CustomControls/Canvas/Canvas.h"
#include "CustomControls/HighResTimer/HighResTimer.h"
#include "GameInterface/MessagePasser.h" #include "GameInterface/MessagePasser.h"
#include "GameInterface/Messages.h" #include "GameInterface/Messages.h"
@ -449,20 +449,11 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent, ScriptInterface& scriptInterfac
m_SectionLayout.SetWindow(this); m_SectionLayout.SetWindow(this);
// Toolbar: // Toolbar:
// wxOSX/Cocoa 2.9 doesn't seem to like SetToolBar, so we use CreateToolBar which implicitly associates
// the toolbar with the frame, and use OnCreateToolBar to construct our custom toolbar
// (this should be equivalent behavior on all platforms)
CreateToolBar(wxNO_BORDER|wxTB_FLAT|wxTB_HORIZONTAL, ID_Toolbar);
ToolButtonBar* toolbar = new ToolButtonBar(m_ToolManager, this, &m_SectionLayout, ID_Toolbar);
// TODO: configurable small vs large icon images
// (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")*/);
toolbar->AddToolButton(_("Elevation"), _("Alter terrain elevation"), _T("alterelevation.png"), _T("AlterElevation"), _T("")/*_T("TerrainSidebar")*/);
toolbar->AddToolButton(_("Smooth"), _("Smooth terrain elevation"), _T("smoothelevation.png"), _T("SmoothElevation"), _T("")/*_T("TerrainSidebar")*/);
toolbar->AddToolButton(_("Flatten"), _("Flatten terrain elevation"), _T("flattenelevation.png"), _T("FlattenElevation"), _T("")/*_T("TerrainSidebar")*/);
toolbar->AddToolButton(_("Paint Terrain"), _("Paint terrain texture"), _T("paintterrain.png"), _T("PaintTerrain"), _T("")/*_T("TerrainSidebar")*/);
toolbar->Realize();
SetToolBar(toolbar);
// Set the default tool to be selected // Set the default tool to be selected
m_ToolManager.SetCurrentTool(_T("")); m_ToolManager.SetCurrentTool(_T(""));
@ -535,6 +526,24 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent, ScriptInterface& scriptInterfac
#endif #endif
} }
wxToolBar* ScenarioEditor::OnCreateToolBar(long style, wxWindowID id, const wxString& WXUNUSED(name))
{
ToolButtonBar* toolbar = new ToolButtonBar(m_ToolManager, this, &m_SectionLayout, id, style);
// TODO: configurable small vs large icon images
// (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")*/);
toolbar->AddToolButton(_("Elevation"), _("Alter terrain elevation"), _T("alterelevation.png"), _T("AlterElevation"), _T("")/*_T("TerrainSidebar")*/);
toolbar->AddToolButton(_("Smooth"), _("Smooth terrain elevation"), _T("smoothelevation.png"), _T("SmoothElevation"), _T("")/*_T("TerrainSidebar")*/);
toolbar->AddToolButton(_("Flatten"), _("Flatten terrain elevation"), _T("flattenelevation.png"), _T("FlattenElevation"), _T("")/*_T("TerrainSidebar")*/);
toolbar->AddToolButton(_("Paint Terrain"), _("Paint terrain texture"), _T("paintterrain.png"), _T("PaintTerrain"), _T("")/*_T("TerrainSidebar")*/);
toolbar->Realize();
return toolbar;
}
float ScenarioEditor::GetSpeedModifier() float ScenarioEditor::GetSpeedModifier()
{ {
if (wxGetKeyState(WXK_SHIFT) && wxGetKeyState(WXK_CONTROL)) if (wxGetKeyState(WXK_SHIFT) && wxGetKeyState(WXK_CONTROL))

View File

@ -18,6 +18,8 @@
#ifndef INCLUDED_SCENARIOEDITOR #ifndef INCLUDED_SCENARIOEDITOR
#define INCLUDED_SCENARIOEDITOR #define INCLUDED_SCENARIOEDITOR
#include "wx/toolbar.h"
#include "General/AtlasWindowCommandProc.h" #include "General/AtlasWindowCommandProc.h"
#include "General/Observable.h" #include "General/Observable.h"
#include "Tools/Common/ObjectSettings.h" #include "Tools/Common/ObjectSettings.h"
@ -34,6 +36,7 @@ public:
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
void OnTimer(wxTimerEvent& event); void OnTimer(wxTimerEvent& event);
void OnIdle(wxIdleEvent& event); void OnIdle(wxIdleEvent& event);
wxToolBar* OnCreateToolBar(long style, wxWindowID id, const wxString &name);
void OnNew(wxCommandEvent& event); void OnNew(wxCommandEvent& event);
void OnOpen(wxCommandEvent& event); void OnOpen(wxCommandEvent& event);

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games. /* Copyright (C) 2011 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -162,6 +162,11 @@ MESSAGEHANDLER(SetCanvas)
MESSAGEHANDLER(ResizeScreen) MESSAGEHANDLER(ResizeScreen)
{ {
CVideoMode::UpdateRenderer(msg->width, msg->height); CVideoMode::UpdateRenderer(msg->width, msg->height);
#if OS_MACOSX
// OS X seems to require this to update the GL canvas
Atlas_GLSetCurrent(const_cast<void*>(g_GameLoop->glCanvas));
#endif
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////