diff options
Diffstat (limited to 'src/tracker_frame.cpp')
-rw-r--r-- | src/tracker_frame.cpp | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index e944704..a15a6b4 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | #include <wx/aboutdlg.h> | 3 | #include <wx/aboutdlg.h> |
4 | #include <wx/choicebk.h> | 4 | #include <wx/choicebk.h> |
5 | #include <wx/notebook.h> | ||
5 | #include <wx/webrequest.h> | 6 | #include <wx/webrequest.h> |
6 | 7 | ||
7 | #include <nlohmann/json.hpp> | 8 | #include <nlohmann/json.hpp> |
@@ -19,7 +20,9 @@ | |||
19 | enum TrackerFrameIds { | 20 | enum TrackerFrameIds { |
20 | ID_CONNECT = 1, | 21 | ID_CONNECT = 1, |
21 | ID_CHECK_FOR_UPDATES = 2, | 22 | ID_CHECK_FOR_UPDATES = 2, |
22 | ID_SETTINGS = 3 | 23 | ID_SETTINGS = 3, |
24 | ID_ZOOM_IN = 4, | ||
25 | ID_ZOOM_OUT = 5, | ||
23 | }; | 26 | }; |
24 | 27 | ||
25 | wxDEFINE_EVENT(STATE_RESET, wxCommandEvent); | 28 | wxDEFINE_EVENT(STATE_RESET, wxCommandEvent); |
@@ -38,12 +41,20 @@ TrackerFrame::TrackerFrame() | |||
38 | menuFile->Append(ID_SETTINGS, "&Settings"); | 41 | menuFile->Append(ID_SETTINGS, "&Settings"); |
39 | menuFile->Append(wxID_EXIT); | 42 | menuFile->Append(wxID_EXIT); |
40 | 43 | ||
44 | wxMenu *menuView = new wxMenu(); | ||
45 | zoom_in_menu_item_ = menuView->Append(ID_ZOOM_IN, "Zoom In\tCtrl-+"); | ||
46 | zoom_out_menu_item_ = menuView->Append(ID_ZOOM_OUT, "Zoom Out\tCtrl--"); | ||
47 | |||
48 | zoom_in_menu_item_->Enable(false); | ||
49 | zoom_out_menu_item_->Enable(false); | ||
50 | |||
41 | wxMenu *menuHelp = new wxMenu(); | 51 | wxMenu *menuHelp = new wxMenu(); |
42 | menuHelp->Append(wxID_ABOUT); | 52 | menuHelp->Append(wxID_ABOUT); |
43 | menuHelp->Append(ID_CHECK_FOR_UPDATES, "Check for Updates"); | 53 | menuHelp->Append(ID_CHECK_FOR_UPDATES, "Check for Updates"); |
44 | 54 | ||
45 | wxMenuBar *menuBar = new wxMenuBar(); | 55 | wxMenuBar *menuBar = new wxMenuBar(); |
46 | menuBar->Append(menuFile, "&File"); | 56 | menuBar->Append(menuFile, "&File"); |
57 | menuBar->Append(menuView, "&View"); | ||
47 | menuBar->Append(menuHelp, "&Help"); | 58 | menuBar->Append(menuHelp, "&Help"); |
48 | 59 | ||
49 | SetMenuBar(menuBar); | 60 | SetMenuBar(menuBar); |
@@ -57,6 +68,9 @@ TrackerFrame::TrackerFrame() | |||
57 | Bind(wxEVT_MENU, &TrackerFrame::OnSettings, this, ID_SETTINGS); | 68 | Bind(wxEVT_MENU, &TrackerFrame::OnSettings, this, ID_SETTINGS); |
58 | Bind(wxEVT_MENU, &TrackerFrame::OnCheckForUpdates, this, | 69 | Bind(wxEVT_MENU, &TrackerFrame::OnCheckForUpdates, this, |
59 | ID_CHECK_FOR_UPDATES); | 70 | ID_CHECK_FOR_UPDATES); |
71 | Bind(wxEVT_MENU, &TrackerFrame::OnZoomIn, this, ID_ZOOM_IN); | ||
72 | Bind(wxEVT_MENU, &TrackerFrame::OnZoomOut, this, ID_ZOOM_OUT); | ||
73 | Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, &TrackerFrame::OnChangePage, this); | ||
60 | Bind(STATE_RESET, &TrackerFrame::OnStateReset, this); | 74 | Bind(STATE_RESET, &TrackerFrame::OnStateReset, this); |
61 | Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this); | 75 | Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this); |
62 | Bind(STATUS_CHANGED, &TrackerFrame::OnStatusChanged, this); | 76 | Bind(STATUS_CHANGED, &TrackerFrame::OnStatusChanged, this); |
@@ -66,15 +80,15 @@ TrackerFrame::TrackerFrame() | |||
66 | wxChoicebook *choicebook = new wxChoicebook(this, wxID_ANY); | 80 | wxChoicebook *choicebook = new wxChoicebook(this, wxID_ANY); |
67 | choicebook->AddPage(achievements_pane_, "Achievements"); | 81 | choicebook->AddPage(achievements_pane_, "Achievements"); |
68 | 82 | ||
69 | wxNotebook *rightpane = new wxNotebook(this, wxID_ANY); | 83 | notebook_ = new wxNotebook(this, wxID_ANY); |
70 | tracker_panel_ = new TrackerPanel(rightpane); | 84 | tracker_panel_ = new TrackerPanel(notebook_); |
71 | subway_map_ = new SubwayMap(rightpane); | 85 | subway_map_ = new SubwayMap(notebook_); |
72 | rightpane->AddPage(tracker_panel_, "Map"); | 86 | notebook_->AddPage(tracker_panel_, "Map"); |
73 | rightpane->AddPage(subway_map_, "Subway"); | 87 | notebook_->AddPage(subway_map_, "Subway"); |
74 | 88 | ||
75 | wxBoxSizer *top_sizer = new wxBoxSizer(wxHORIZONTAL); | 89 | wxBoxSizer *top_sizer = new wxBoxSizer(wxHORIZONTAL); |
76 | top_sizer->Add(choicebook, wxSizerFlags().Expand().Proportion(1)); | 90 | top_sizer->Add(choicebook, wxSizerFlags().Expand().Proportion(1)); |
77 | top_sizer->Add(rightpane, wxSizerFlags().Expand().Proportion(3)); | 91 | top_sizer->Add(notebook_, wxSizerFlags().Expand().Proportion(3)); |
78 | 92 | ||
79 | SetSizerAndFit(top_sizer); | 93 | SetSizerAndFit(top_sizer); |
80 | SetSize(1280, 728); | 94 | SetSize(1280, 728); |
@@ -174,6 +188,23 @@ void TrackerFrame::OnCheckForUpdates(wxCommandEvent &event) { | |||
174 | CheckForUpdates(/*manual=*/true); | 188 | CheckForUpdates(/*manual=*/true); |
175 | } | 189 | } |
176 | 190 | ||
191 | void TrackerFrame::OnZoomIn(wxCommandEvent &event) { | ||
192 | if (notebook_->GetSelection() == 1) { | ||
193 | subway_map_->Zoom(true); | ||
194 | } | ||
195 | } | ||
196 | |||
197 | void TrackerFrame::OnZoomOut(wxCommandEvent& event) { | ||
198 | if (notebook_->GetSelection() == 1) { | ||
199 | subway_map_->Zoom(false); | ||
200 | } | ||
201 | } | ||
202 | |||
203 | void TrackerFrame::OnChangePage(wxBookCtrlEvent &event) { | ||
204 | zoom_in_menu_item_->Enable(event.GetSelection() == 1); | ||
205 | zoom_out_menu_item_->Enable(event.GetSelection() == 1); | ||
206 | } | ||
207 | |||
177 | void TrackerFrame::OnStateReset(wxCommandEvent& event) { | 208 | void TrackerFrame::OnStateReset(wxCommandEvent& event) { |
178 | tracker_panel_->UpdateIndicators(); | 209 | tracker_panel_->UpdateIndicators(); |
179 | achievements_pane_->UpdateIndicators(); | 210 | achievements_pane_->UpdateIndicators(); |