From 8702c11db08f78b6c91ef950ce280f2289b1a6e6 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 15 Mar 2015 15:50:04 -0400 Subject: Added scrolling and zooming to map editor --- tools/mapedit/src/frame.cpp | 55 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'tools/mapedit/src/frame.cpp') diff --git a/tools/mapedit/src/frame.cpp b/tools/mapedit/src/frame.cpp index 858620e..537cd16 100644 --- a/tools/mapedit/src/frame.cpp +++ b/tools/mapedit/src/frame.cpp @@ -1,30 +1,75 @@ #include "frame.h" #include "widget.h" #include "tile_widget.h" +#include +#include "panel.h" + +enum { + MENU_VIEW_ZOOM_IN, + MENU_VIEW_ZOOM_OUT +}; wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame) EVT_MENU(wxID_EXIT, MapeditFrame::OnExit) + EVT_MENU(MENU_VIEW_ZOOM_IN, MapeditFrame::ZoomIn) + EVT_MENU(MENU_VIEW_ZOOM_OUT, MapeditFrame::ZoomOut) wxEND_EVENT_TABLE() MapeditFrame::MapeditFrame(Map map) : wxFrame(NULL, wxID_ANY, "Map Editor", wxPoint(50, 50), wxSize(GAME_WIDTH*3, GAME_HEIGHT*2)), map(map) { wxMenu* menuFile = new wxMenu; menuFile->Append(wxID_EXIT); + + wxMenu* menuView = new wxMenu; + menuView->Append(MENU_VIEW_ZOOM_IN, "Zoom In\tCtrl-+"); + menuView->Append(MENU_VIEW_ZOOM_OUT, "Zoom Out\tCtrl--"); wxMenuBar* menuBar = new wxMenuBar; menuBar->Append(menuFile, "&File"); + menuBar->Append(menuView, "&View"); SetMenuBar(menuBar); - wxPanel* panel = new wxPanel(this, wxID_ANY); - int clientWidth, clientHeight; - GetClientSize(&clientWidth, &clientHeight); + wxBoxSizer* sizermain = new wxBoxSizer(wxVERTICAL); + wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY); + splitter->SetSashGravity(0.0); + splitter->SetMinimumPaneSize(50); + sizermain->Add(splitter, 1, wxEXPAND, 0); + + wxPanel* tileEditorPanel = new wxPanel(splitter, wxID_ANY); + tileEditor = new TileWidget(tileEditorPanel, wxID_ANY, 6, 6, wxPoint(0,0)); + wxBoxSizer* tileSizer = new wxBoxSizer(wxVERTICAL); + tileSizer->Add(tileEditor, 1, wxEXPAND, 0); + tileEditorPanel->SetSizer(tileSizer); + + wxPanel* mapEditorPanel = new wxPanel(splitter, wxID_ANY); + mapEditor = new MapeditWidget(mapEditorPanel, wxID_ANY, &this->map, tileEditor, wxPoint(0,0)); + wxBoxSizer* mapSizer = new wxBoxSizer(wxVERTICAL); + mapSizer->Add(mapEditor, 1, wxEXPAND, 0); + mapEditorPanel->SetSizer(mapSizer); - TileWidget* tileEdit = new TileWidget(panel, wxID_ANY, 6, wxPoint(0,0), wxSize(TILE_WIDTH*3*6, clientHeight)); - MapeditWidget* wid = new MapeditWidget(panel, wxID_ANY, &this->map, tileEdit, wxPoint(TILE_WIDTH*3*6+8,0), wxSize(GAME_WIDTH*1.5, GAME_HEIGHT*1.5)); + splitter->SplitVertically(tileEditorPanel, mapEditorPanel); + + this->SetSizer(sizermain); + sizermain->SetSizeHints(this); } void MapeditFrame::OnExit(wxCommandEvent& event) { Close(true); } + +MapeditWidget* MapeditFrame::GetMapEditor() +{ + return mapEditor; +} + +void MapeditFrame::ZoomIn(wxCommandEvent& event) +{ + mapEditor->ZoomIn(); +} + +void MapeditFrame::ZoomOut(wxCommandEvent& event) +{ + mapEditor->ZoomOut(); +} -- cgit 1.4.1