about summary refs log tree commit diff stats
path: root/src/subway_map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/subway_map.cpp')
-rw-r--r--src/subway_map.cpp30
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
122void 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
122void SubwayMap::OnPaint(wxPaintEvent &event) { 142void 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
393void SubwayMap::OnMouseLeave(wxMouseEvent &event) { SetScrollSpeed(0, 0); } 415void SubwayMap::OnMouseLeave(wxMouseEvent &event) {
416 SetScrollSpeed(0, 0);
417 mouse_position_ = std::nullopt;
418}
394 419
395void SubwayMap::OnTimer(wxTimerEvent &event) { 420void 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));