diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/mapedit/src/frame.cpp | 41 | ||||
| -rw-r--r-- | tools/mapedit/src/frame.h | 5 |
2 files changed, 32 insertions, 14 deletions
| 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 @@ | |||
| 1 | #include "frame.h" | 1 | #include "frame.h" |
| 2 | #include "widget.h" | 2 | #include "widget.h" |
| 3 | #include "tile_widget.h" | 3 | #include "tile_widget.h" |
| 4 | #include <wx/splitter.h> | ||
| 5 | #include <wx/statline.h> | 4 | #include <wx/statline.h> |
| 6 | #include "panel.h" | 5 | #include "panel.h" |
| 7 | #include <list> | 6 | #include <list> |
| @@ -32,7 +31,9 @@ enum { | |||
| 32 | ADD_ENTITY_BUTTON, | 31 | ADD_ENTITY_BUTTON, |
| 33 | CANCEL_ENTITY_BUTTON, | 32 | CANCEL_ENTITY_BUTTON, |
| 34 | SET_STARTPOS_BUTTON, | 33 | SET_STARTPOS_BUTTON, |
| 35 | CANCEL_STARTPOS_BUTTON | 34 | CANCEL_STARTPOS_BUTTON, |
| 35 | LAYOUT_ONE_SPLITTER, | ||
| 36 | LAYOUT_THREE_SPLITTER | ||
| 36 | }; | 37 | }; |
| 37 | 38 | ||
| 38 | wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame) | 39 | wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame) |
| @@ -64,6 +65,8 @@ wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame) | |||
| 64 | EVT_BUTTON(CANCEL_ENTITY_BUTTON, MapeditFrame::OnCancelAddEntity) | 65 | EVT_BUTTON(CANCEL_ENTITY_BUTTON, MapeditFrame::OnCancelAddEntity) |
| 65 | EVT_BUTTON(SET_STARTPOS_BUTTON, MapeditFrame::OnSetStartpos) | 66 | EVT_BUTTON(SET_STARTPOS_BUTTON, MapeditFrame::OnSetStartpos) |
| 66 | EVT_BUTTON(CANCEL_STARTPOS_BUTTON, MapeditFrame::OnCancelSetStartpos) | 67 | EVT_BUTTON(CANCEL_STARTPOS_BUTTON, MapeditFrame::OnCancelSetStartpos) |
| 68 | EVT_SPLITTER_SASH_POS_CHANGING(LAYOUT_ONE_SPLITTER, MapeditFrame::OnOneMovingSash) | ||
| 69 | EVT_SPLITTER_SASH_POS_CHANGING(LAYOUT_THREE_SPLITTER, MapeditFrame::OnThreeMovingSash) | ||
| 67 | wxEND_EVENT_TABLE() | 70 | wxEND_EVENT_TABLE() |
| 68 | 71 | ||
| 69 | MapeditFrame::MapeditFrame(std::unique_ptr<World> world) : wxFrame(NULL, wxID_ANY, "Map Editor") | 72 | MapeditFrame::MapeditFrame(std::unique_ptr<World> world) : wxFrame(NULL, wxID_ANY, "Map Editor") |
| @@ -133,14 +136,14 @@ MapeditFrame::MapeditFrame(std::unique_ptr<World> world) : wxFrame(NULL, wxID_AN | |||
| 133 | // Layout 2: Non-splitter between layout 3 and notebook | 136 | // Layout 2: Non-splitter between layout 3 and notebook |
| 134 | // Layout 3: Splitter between map editor and properties editor | 137 | // Layout 3: Splitter between map editor and properties editor |
| 135 | 138 | ||
| 136 | wxSplitterWindow* layout1 = new wxSplitterWindow(this, wxID_ANY); | 139 | layout1 = new wxSplitterWindow(this, LAYOUT_ONE_SPLITTER); |
| 137 | mapTree = new wxTreeCtrl(layout1, MAP_EDITOR_TREE, wxDefaultPosition, wxSize(150, 0), wxTR_HIDE_ROOT | wxTR_HAS_BUTTONS); | 140 | mapTree = new wxTreeCtrl(layout1, MAP_EDITOR_TREE, wxDefaultPosition, wxSize(200, -1), wxTR_HIDE_ROOT | wxTR_HAS_BUTTONS); |
| 138 | wxTreeItemId mapTreeRoot = mapTree->AddRoot("root"); | 141 | wxTreeItemId mapTreeRoot = mapTree->AddRoot("root"); |
| 139 | populateMapTree(mapTreeRoot, this->world->getRootMaps()); | 142 | populateMapTree(mapTreeRoot, this->world->getRootMaps()); |
| 140 | 143 | ||
| 141 | wxPanel* layout2 = new wxPanel(layout1, wxID_ANY); | 144 | wxPanel* layout2 = new wxPanel(layout1, wxID_ANY); |
| 142 | 145 | ||
| 143 | wxSplitterWindow* layout3 = new wxSplitterWindow(layout2, wxID_ANY); | 146 | layout3 = new wxSplitterWindow(layout2, LAYOUT_THREE_SPLITTER); |
| 144 | layout3->SetSashGravity(1.0); | 147 | layout3->SetSashGravity(1.0); |
| 145 | 148 | ||
| 146 | notebook = new wxNotebook(layout2, MAP_EDITOR_NOTEBOOK); | 149 | notebook = new wxNotebook(layout2, MAP_EDITOR_NOTEBOOK); |
| @@ -152,7 +155,7 @@ MapeditFrame::MapeditFrame(std::unique_ptr<World> world) : wxFrame(NULL, wxID_AN | |||
| 152 | mapEditor->frame = this; | 155 | mapEditor->frame = this; |
| 153 | 156 | ||
| 154 | // Set up property editor | 157 | // Set up property editor |
| 155 | wxPanel* propertyEditor = new wxPanel(layout3, wxID_ANY, wxDefaultPosition, wxSize(-1, 100)); | 158 | wxPanel* propertyEditor = new wxPanel(layout3, wxID_ANY);//, wxDefaultPosition, wxSize(-1, 100)); |
| 156 | titleBox = new UndoableTextBox(propertyEditor, MAP_TITLE_TEXTBOX, currentMap->getTitle(), "Edit Map Title", this); | 159 | titleBox = new UndoableTextBox(propertyEditor, MAP_TITLE_TEXTBOX, currentMap->getTitle(), "Edit Map Title", this); |
| 157 | titleBox->SetMaxLength(40); | 160 | titleBox->SetMaxLength(40); |
| 158 | 161 | ||
| @@ -169,12 +172,12 @@ MapeditFrame::MapeditFrame(std::unique_ptr<World> world) : wxFrame(NULL, wxID_AN | |||
| 169 | wxBoxSizer* propertySizer1 = new wxBoxSizer(wxHORIZONTAL); | 172 | wxBoxSizer* propertySizer1 = new wxBoxSizer(wxHORIZONTAL); |
| 170 | propertySizer1->Add(titleLabel, 0, wxALIGN_RIGHT | wxLEFT, 10); | 173 | propertySizer1->Add(titleLabel, 0, wxALIGN_RIGHT | wxLEFT, 10); |
| 171 | propertySizer1->Add(titleBox, 1, wxALIGN_LEFT | wxLEFT | wxRIGHT, 10); | 174 | propertySizer1->Add(titleBox, 1, wxALIGN_LEFT | wxLEFT | wxRIGHT, 10); |
| 172 | propertySizer->Add(propertySizer1, 1, wxEXPAND | wxTOP, 10); | 175 | propertySizer->Add(propertySizer1, 0, wxEXPAND | wxTOP, 10); |
| 173 | wxBoxSizer* propertySizer2 = new wxBoxSizer(wxHORIZONTAL); | 176 | wxBoxSizer* propertySizer2 = new wxBoxSizer(wxHORIZONTAL); |
| 174 | propertySizer2->Add(startposLabel, 0, wxALIGN_RIGHT | wxLEFT, 10); | 177 | propertySizer2->Add(startposLabel, 0, wxALIGN_RIGHT | wxLEFT, 10); |
| 175 | propertySizer2->Add(setStartposButton, 0, wxALIGN_LEFT | wxLEFT, 10); | 178 | propertySizer2->Add(setStartposButton, 0, wxALIGN_LEFT | wxLEFT, 10); |
| 176 | propertySizer2->Add(cancelStartposButton, 0, wxALIGN_LEFT | wxLEFT, 10); | 179 | propertySizer2->Add(cancelStartposButton, 0, wxALIGN_LEFT | wxLEFT, 10); |
| 177 | propertySizer->Add(propertySizer2, 1, wxEXPAND | wxTOP, 10); | 180 | propertySizer->Add(propertySizer2, 0, wxEXPAND | wxTOP | wxBOTTOM, 10); |
| 178 | propertyEditor->SetSizer(propertySizer); | 181 | propertyEditor->SetSizer(propertySizer); |
| 179 | propertySizer->SetSizeHints(propertyEditor); | 182 | propertySizer->SetSizeHints(propertyEditor); |
| 180 | 183 | ||
| @@ -217,13 +220,10 @@ MapeditFrame::MapeditFrame(std::unique_ptr<World> world) : wxFrame(NULL, wxID_AN | |||
| 217 | entitySizer->SetSizeHints(entityEditor); | 220 | entitySizer->SetSizeHints(entityEditor); |
| 218 | 221 | ||
| 219 | // Finish setting up the layouts | 222 | // Finish setting up the layouts |
| 220 | layout3->SplitHorizontally(mapEditor, propertyEditor); | ||
| 221 | layout1->SplitVertically(mapTree, layout2); | ||
| 222 | |||
| 223 | wxBoxSizer* sizer1 = new wxBoxSizer(wxHORIZONTAL); | 223 | wxBoxSizer* sizer1 = new wxBoxSizer(wxHORIZONTAL); |
| 224 | sizer1->Add(layout1, 1, wxEXPAND, 0); | 224 | sizer1->Add(layout1, 1, wxEXPAND, 0); |
| 225 | sizer1->Add(mapTree, 0, wxALIGN_TOP | wxALIGN_LEFT, 0); | 225 | sizer1->Add(mapTree, 0, wxALIGN_TOP | wxALIGN_LEFT, 0); |
| 226 | sizer1->Add(layout2, 1, wxEXPAND, 0); | 226 | sizer1->Add(layout2, 2, wxEXPAND, 0); |
| 227 | layout1->SetSizer(sizer1); | 227 | layout1->SetSizer(sizer1); |
| 228 | sizer1->SetSizeHints(layout1); | 228 | sizer1->SetSizeHints(layout1); |
| 229 | 229 | ||
| @@ -234,12 +234,15 @@ MapeditFrame::MapeditFrame(std::unique_ptr<World> world) : wxFrame(NULL, wxID_AN | |||
| 234 | sizer2->SetSizeHints(layout2); | 234 | sizer2->SetSizeHints(layout2); |
| 235 | 235 | ||
| 236 | wxBoxSizer* splitterSizer = new wxBoxSizer(wxVERTICAL); | 236 | wxBoxSizer* splitterSizer = new wxBoxSizer(wxVERTICAL); |
| 237 | splitterSizer->Add(layout3, 1, wxEXPAND, 0); | 237 | splitterSizer->Add(layout3, 0, wxEXPAND, 0); |
| 238 | splitterSizer->Add(mapEditor, 1, wxEXPAND, 0); | 238 | splitterSizer->Add(mapEditor, 1, wxEXPAND, 0); |
| 239 | splitterSizer->Add(propertyEditor, 0, wxALIGN_TOP | wxALIGN_LEFT, 0); | 239 | splitterSizer->Add(propertyEditor, 0, wxALIGN_BOTTOM | wxALIGN_LEFT, 0); |
| 240 | layout3->SetSizer(splitterSizer); | 240 | layout3->SetSizer(splitterSizer); |
| 241 | splitterSizer->SetSizeHints(layout3); | 241 | splitterSizer->SetSizeHints(layout3); |
| 242 | 242 | ||
| 243 | layout3->SplitHorizontally(mapEditor, propertyEditor, -propertyEditor->GetSize().GetHeight()); | ||
| 244 | layout1->SplitVertically(mapTree, layout2, mapTree->GetSize().GetWidth()); | ||
| 245 | |||
| 243 | // Toolbar time! | 246 | // Toolbar time! |
| 244 | toolbar = CreateToolBar(); | 247 | toolbar = CreateToolBar(); |
| 245 | toolbar->AddTool(TOOL_FILE_NEW, "New", wxBitmap(wxImage("res/page.png"))); | 248 | toolbar->AddTool(TOOL_FILE_NEW, "New", wxBitmap(wxImage("res/page.png"))); |
| @@ -574,6 +577,16 @@ void MapeditFrame::OnRedo(wxCommandEvent&) | |||
| 574 | UpdateUndoLabels(); | 577 | UpdateUndoLabels(); |
| 575 | } | 578 | } |
| 576 | 579 | ||
| 580 | void MapeditFrame::OnOneMovingSash(wxSplitterEvent& event) | ||
| 581 | { | ||
| 582 | layout1->SetSashPosition(event.GetSashPosition(), true); | ||
| 583 | } | ||
| 584 | |||
| 585 | void MapeditFrame::OnThreeMovingSash(wxSplitterEvent& event) | ||
| 586 | { | ||
| 587 | layout3->SetSashPosition(event.GetSashPosition(), true); | ||
| 588 | } | ||
| 589 | |||
| 577 | void MapeditFrame::NewWorld() | 590 | void MapeditFrame::NewWorld() |
| 578 | { | 591 | { |
| 579 | LaunchWindow(std::unique_ptr<World>(new World())); | 592 | LaunchWindow(std::unique_ptr<World>(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 @@ | |||
| 14 | #include <wx/notebook.h> | 14 | #include <wx/notebook.h> |
| 15 | #include <memory> | 15 | #include <memory> |
| 16 | #include <wx/treectrl.h> | 16 | #include <wx/treectrl.h> |
| 17 | #include <wx/splitter.h> | ||
| 17 | #include "undo.h" | 18 | #include "undo.h" |
| 18 | 19 | ||
| 19 | class MapPtrCtr : public wxTreeItemData { | 20 | class MapPtrCtr : public wxTreeItemData { |
| @@ -65,6 +66,8 @@ class MapeditFrame : public wxFrame { | |||
| 65 | void OnRightClickTree(wxTreeEvent& event); | 66 | void OnRightClickTree(wxTreeEvent& event); |
| 66 | void OnSetStartpos(wxCommandEvent& event); | 67 | void OnSetStartpos(wxCommandEvent& event); |
| 67 | void OnCancelSetStartpos(wxCommandEvent& event); | 68 | void OnCancelSetStartpos(wxCommandEvent& event); |
| 69 | void OnOneMovingSash(wxSplitterEvent& event); | ||
| 70 | void OnThreeMovingSash(wxSplitterEvent& event); | ||
| 68 | 71 | ||
| 69 | std::unique_ptr<World> world; | 72 | std::unique_ptr<World> world; |
| 70 | Map* currentMap; | 73 | Map* currentMap; |
| @@ -73,6 +76,8 @@ class MapeditFrame : public wxFrame { | |||
| 73 | TileWidget* tileEditor; | 76 | TileWidget* tileEditor; |
| 74 | wxToolBar* toolbar; | 77 | wxToolBar* toolbar; |
| 75 | wxMenu* menuFile; | 78 | wxMenu* menuFile; |
| 79 | wxSplitterWindow* layout1; | ||
| 80 | wxSplitterWindow* layout3; | ||
| 76 | 81 | ||
| 77 | // Notebook | 82 | // Notebook |
| 78 | wxNotebook* notebook; | 83 | wxNotebook* notebook; |
