From 42c18bdf3bcb61da246e218985cd498dbc24541e Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 17 Mar 2015 17:11:02 -0400 Subject: Splitters in map editor now move as dragged and start at reasonable sizes --- tools/mapedit/src/frame.cpp | 41 +++++++++++++++++++++++++++-------------- tools/mapedit/src/frame.h | 5 +++++ 2 files changed, 32 insertions(+), 14 deletions(-) (limited to 'tools') diff --git a/tools/mapedit/src/frame.cpp b/tools/mapedit/src/frame.cpp index 6fb70c8..2540175 100644 --- a/tools/mapedit/src/frame.cpp +++ b/tools/mapedit/src/frame.cpp @@ -1,7 +1,6 @@ #include "frame.h" #include "widget.h" #include "tile_widget.h" -#include #include #include "panel.h" #include @@ -32,7 +31,9 @@ enum { ADD_ENTITY_BUTTON, CANCEL_ENTITY_BUTTON, SET_STARTPOS_BUTTON, - CANCEL_STARTPOS_BUTTON + CANCEL_STARTPOS_BUTTON, + LAYOUT_ONE_SPLITTER, + LAYOUT_THREE_SPLITTER }; wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame) @@ -64,6 +65,8 @@ wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame) EVT_BUTTON(CANCEL_ENTITY_BUTTON, MapeditFrame::OnCancelAddEntity) EVT_BUTTON(SET_STARTPOS_BUTTON, MapeditFrame::OnSetStartpos) EVT_BUTTON(CANCEL_STARTPOS_BUTTON, MapeditFrame::OnCancelSetStartpos) + EVT_SPLITTER_SASH_POS_CHANGING(LAYOUT_ONE_SPLITTER, MapeditFrame::OnOneMovingSash) + EVT_SPLITTER_SASH_POS_CHANGING(LAYOUT_THREE_SPLITTER, MapeditFrame::OnThreeMovingSash) wxEND_EVENT_TABLE() MapeditFrame::MapeditFrame(std::unique_ptr world) : wxFrame(NULL, wxID_ANY, "Map Editor") @@ -133,14 +136,14 @@ MapeditFrame::MapeditFrame(std::unique_ptr world) : wxFrame(NULL, wxID_AN // Layout 2: Non-splitter between layout 3 and notebook // Layout 3: Splitter between map editor and properties editor - wxSplitterWindow* layout1 = new wxSplitterWindow(this, wxID_ANY); - mapTree = new wxTreeCtrl(layout1, MAP_EDITOR_TREE, wxDefaultPosition, wxSize(150, 0), wxTR_HIDE_ROOT | wxTR_HAS_BUTTONS); + layout1 = new wxSplitterWindow(this, LAYOUT_ONE_SPLITTER); + mapTree = new wxTreeCtrl(layout1, MAP_EDITOR_TREE, wxDefaultPosition, wxSize(200, -1), wxTR_HIDE_ROOT | wxTR_HAS_BUTTONS); wxTreeItemId mapTreeRoot = mapTree->AddRoot("root"); populateMapTree(mapTreeRoot, this->world->getRootMaps()); wxPanel* layout2 = new wxPanel(layout1, wxID_ANY); - wxSplitterWindow* layout3 = new wxSplitterWindow(layout2, wxID_ANY); + layout3 = new wxSplitterWindow(layout2, LAYOUT_THREE_SPLITTER); layout3->SetSashGravity(1.0); notebook = new wxNotebook(layout2, MAP_EDITOR_NOTEBOOK); @@ -152,7 +155,7 @@ MapeditFrame::MapeditFrame(std::unique_ptr world) : wxFrame(NULL, wxID_AN mapEditor->frame = this; // Set up property editor - wxPanel* propertyEditor = new wxPanel(layout3, wxID_ANY, wxDefaultPosition, wxSize(-1, 100)); + wxPanel* propertyEditor = new wxPanel(layout3, wxID_ANY);//, wxDefaultPosition, wxSize(-1, 100)); titleBox = new UndoableTextBox(propertyEditor, MAP_TITLE_TEXTBOX, currentMap->getTitle(), "Edit Map Title", this); titleBox->SetMaxLength(40); @@ -169,12 +172,12 @@ MapeditFrame::MapeditFrame(std::unique_ptr world) : wxFrame(NULL, wxID_AN wxBoxSizer* propertySizer1 = new wxBoxSizer(wxHORIZONTAL); propertySizer1->Add(titleLabel, 0, wxALIGN_RIGHT | wxLEFT, 10); propertySizer1->Add(titleBox, 1, wxALIGN_LEFT | wxLEFT | wxRIGHT, 10); - propertySizer->Add(propertySizer1, 1, wxEXPAND | wxTOP, 10); + propertySizer->Add(propertySizer1, 0, wxEXPAND | wxTOP, 10); wxBoxSizer* propertySizer2 = new wxBoxSizer(wxHORIZONTAL); propertySizer2->Add(startposLabel, 0, wxALIGN_RIGHT | wxLEFT, 10); propertySizer2->Add(setStartposButton, 0, wxALIGN_LEFT | wxLEFT, 10); propertySizer2->Add(cancelStartposButton, 0, wxALIGN_LEFT | wxLEFT, 10); - propertySizer->Add(propertySizer2, 1, wxEXPAND | wxTOP, 10); + propertySizer->Add(propertySizer2, 0, wxEXPAND | wxTOP | wxBOTTOM, 10); propertyEditor->SetSizer(propertySizer); propertySizer->SetSizeHints(propertyEditor); @@ -217,13 +220,10 @@ MapeditFrame::MapeditFrame(std::unique_ptr world) : wxFrame(NULL, wxID_AN entitySizer->SetSizeHints(entityEditor); // Finish setting up the layouts - layout3->SplitHorizontally(mapEditor, propertyEditor); - layout1->SplitVertically(mapTree, layout2); - wxBoxSizer* sizer1 = new wxBoxSizer(wxHORIZONTAL); sizer1->Add(layout1, 1, wxEXPAND, 0); sizer1->Add(mapTree, 0, wxALIGN_TOP | wxALIGN_LEFT, 0); - sizer1->Add(layout2, 1, wxEXPAND, 0); + sizer1->Add(layout2, 2, wxEXPAND, 0); layout1->SetSizer(sizer1); sizer1->SetSizeHints(layout1); @@ -234,12 +234,15 @@ MapeditFrame::MapeditFrame(std::unique_ptr world) : wxFrame(NULL, wxID_AN sizer2->SetSizeHints(layout2); wxBoxSizer* splitterSizer = new wxBoxSizer(wxVERTICAL); - splitterSizer->Add(layout3, 1, wxEXPAND, 0); + splitterSizer->Add(layout3, 0, wxEXPAND, 0); splitterSizer->Add(mapEditor, 1, wxEXPAND, 0); - splitterSizer->Add(propertyEditor, 0, wxALIGN_TOP | wxALIGN_LEFT, 0); + splitterSizer->Add(propertyEditor, 0, wxALIGN_BOTTOM | wxALIGN_LEFT, 0); layout3->SetSizer(splitterSizer); splitterSizer->SetSizeHints(layout3); + layout3->SplitHorizontally(mapEditor, propertyEditor, -propertyEditor->GetSize().GetHeight()); + layout1->SplitVertically(mapTree, layout2, mapTree->GetSize().GetWidth()); + // Toolbar time! toolbar = CreateToolBar(); toolbar->AddTool(TOOL_FILE_NEW, "New", wxBitmap(wxImage("res/page.png"))); @@ -574,6 +577,16 @@ void MapeditFrame::OnRedo(wxCommandEvent&) UpdateUndoLabels(); } +void MapeditFrame::OnOneMovingSash(wxSplitterEvent& event) +{ + layout1->SetSashPosition(event.GetSashPosition(), true); +} + +void MapeditFrame::OnThreeMovingSash(wxSplitterEvent& event) +{ + layout3->SetSashPosition(event.GetSashPosition(), true); +} + void MapeditFrame::NewWorld() { LaunchWindow(std::unique_ptr(new World())); diff --git a/tools/mapedit/src/frame.h b/tools/mapedit/src/frame.h index b0f27e9..ffa6c7d 100644 --- a/tools/mapedit/src/frame.h +++ b/tools/mapedit/src/frame.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "undo.h" class MapPtrCtr : public wxTreeItemData { @@ -65,6 +66,8 @@ class MapeditFrame : public wxFrame { void OnRightClickTree(wxTreeEvent& event); void OnSetStartpos(wxCommandEvent& event); void OnCancelSetStartpos(wxCommandEvent& event); + void OnOneMovingSash(wxSplitterEvent& event); + void OnThreeMovingSash(wxSplitterEvent& event); std::unique_ptr world; Map* currentMap; @@ -73,6 +76,8 @@ class MapeditFrame : public wxFrame { TileWidget* tileEditor; wxToolBar* toolbar; wxMenu* menuFile; + wxSplitterWindow* layout1; + wxSplitterWindow* layout3; // Notebook wxNotebook* notebook; -- cgit 1.4.1