diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-05-19 12:24:00 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-05-19 12:24:00 -0400 |
| commit | 983f01cb8a2eaecd162e5734de88c461ef197b34 (patch) | |
| tree | 86f8987f63a1ab5ffa613104dae3d8cd10f3239f /src/subway_map.cpp | |
| parent | eaa21c53b96b945d8809dc5f4a9353ecaaacc266 (diff) | |
| download | lingo-ap-tracker-983f01cb8a2eaecd162e5734de88c461ef197b34.tar.gz lingo-ap-tracker-983f01cb8a2eaecd162e5734de88c461ef197b34.tar.bz2 lingo-ap-tracker-983f01cb8a2eaecd162e5734de88c461ef197b34.zip | |
Zoom in/out menu items with keyboard shortcuts
Diffstat (limited to 'src/subway_map.cpp')
| -rw-r--r-- | src/subway_map.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
| diff --git a/src/subway_map.cpp b/src/subway_map.cpp index 98d544c..69bf51b 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp | |||
| @@ -119,6 +119,26 @@ void SubwayMap::UpdateSunwarp(SubwaySunwarp from_sunwarp, | |||
| 119 | GD_GetSubwayItemForSunwarp(to_sunwarp)); | 119 | GD_GetSubwayItemForSunwarp(to_sunwarp)); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | void SubwayMap::Zoom(bool in) { | ||
| 123 | wxPoint focus_point; | ||
| 124 | |||
| 125 | if (mouse_position_) { | ||
| 126 | focus_point = *mouse_position_; | ||
| 127 | } else { | ||
| 128 | focus_point = {GetSize().GetWidth() / 2, GetSize().GetHeight() / 2}; | ||
| 129 | } | ||
| 130 | |||
| 131 | if (in) { | ||
| 132 | if (zoom_ < 3.0) { | ||
| 133 | SetZoom(zoom_ + 0.25, focus_point); | ||
| 134 | } | ||
| 135 | } else { | ||
| 136 | if (zoom_ > 1.0) { | ||
| 137 | SetZoom(zoom_ - 0.25, focus_point); | ||
| 138 | } | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 122 | void SubwayMap::OnPaint(wxPaintEvent &event) { | 142 | void SubwayMap::OnPaint(wxPaintEvent &event) { |
| 123 | if (GetSize() != rendered_.GetSize()) { | 143 | if (GetSize() != rendered_.GetSize()) { |
| 124 | wxSize panel_size = GetSize(); | 144 | wxSize panel_size = GetSize(); |
| @@ -372,6 +392,8 @@ void SubwayMap::OnMouseMove(wxMouseEvent &event) { | |||
| 372 | 392 | ||
| 373 | SetScrollSpeed(scroll_x, scroll_y); | 393 | SetScrollSpeed(scroll_x, scroll_y); |
| 374 | 394 | ||
| 395 | mouse_position_ = event.GetPosition(); | ||
| 396 | |||
| 375 | event.Skip(); | 397 | event.Skip(); |
| 376 | } | 398 | } |
| 377 | 399 | ||
| @@ -390,7 +412,10 @@ void SubwayMap::OnMouseScroll(wxMouseEvent &event) { | |||
| 390 | event.Skip(); | 412 | event.Skip(); |
| 391 | } | 413 | } |
| 392 | 414 | ||
| 393 | void SubwayMap::OnMouseLeave(wxMouseEvent &event) { SetScrollSpeed(0, 0); } | 415 | void SubwayMap::OnMouseLeave(wxMouseEvent &event) { |
| 416 | SetScrollSpeed(0, 0); | ||
| 417 | mouse_position_ = std::nullopt; | ||
| 418 | } | ||
| 394 | 419 | ||
| 395 | void SubwayMap::OnTimer(wxTimerEvent &event) { | 420 | void SubwayMap::OnTimer(wxTimerEvent &event) { |
| 396 | SetZoomPos({zoom_x_ + scroll_x_, zoom_y_ + scroll_y_}); | 421 | SetZoomPos({zoom_x_ + scroll_x_, zoom_y_ + scroll_y_}); |
| @@ -464,7 +489,8 @@ void SubwayMap::Redraw() { | |||
| 464 | 489 | ||
| 465 | wxPoint real_area_pos = {subway_item.x, subway_item.y}; | 490 | wxPoint real_area_pos = {subway_item.x, subway_item.y}; |
| 466 | 491 | ||
| 467 | int real_area_size = (draw_type == ItemDrawType::kOwl ? OWL_ACTUAL_SIZE : AREA_ACTUAL_SIZE); | 492 | int real_area_size = |
| 493 | (draw_type == ItemDrawType::kOwl ? OWL_ACTUAL_SIZE : AREA_ACTUAL_SIZE); | ||
| 468 | 494 | ||
| 469 | if (draw_type == ItemDrawType::kBox) { | 495 | if (draw_type == ItemDrawType::kBox) { |
| 470 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 1)); | 496 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 1)); |
