diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-07 14:33:11 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-07 14:33:11 -0500 |
| commit | ba59d40760e2a5a11bfbe2f7cf6b0e2a71b590d7 (patch) | |
| tree | b261336945f9f9a5c5c33d5160a039445ba297ea | |
| parent | c3849f011be0ecfbf359a163e5e2423272c0c3d0 (diff) | |
| download | lingo-ap-tracker-ba59d40760e2a5a11bfbe2f7cf6b0e2a71b590d7.tar.gz lingo-ap-tracker-ba59d40760e2a5a11bfbe2f7cf6b0e2a71b590d7.tar.bz2 lingo-ap-tracker-ba59d40760e2a5a11bfbe2f7cf6b0e2a71b590d7.zip | |
Better high-DPI handling for rest of app
| -rw-r--r-- | src/area_popup.cpp | 68 | ||||
| -rw-r--r-- | src/area_popup.h | 3 | ||||
| -rw-r--r-- | src/connection_dialog.cpp | 9 | ||||
| -rw-r--r-- | src/ipc_dialog.cpp | 5 | ||||
| -rw-r--r-- | src/report_popup.cpp | 52 | ||||
| -rw-r--r-- | src/report_popup.h | 3 | ||||
| -rw-r--r-- | src/subway_map.cpp | 7 | ||||
| -rw-r--r-- | src/tracker_panel.cpp | 15 | ||||
| -rw-r--r-- | src/tracker_panel.h | 4 |
9 files changed, 114 insertions, 52 deletions
| diff --git a/src/area_popup.cpp b/src/area_popup.cpp index 467a2bc..aabf20b 100644 --- a/src/area_popup.cpp +++ b/src/area_popup.cpp | |||
| @@ -15,20 +15,16 @@ AreaPopup::AreaPopup(wxWindow* parent, int area_id) | |||
| 15 | : wxScrolledCanvas(parent, wxID_ANY), area_id_(area_id) { | 15 | : wxScrolledCanvas(parent, wxID_ANY), area_id_(area_id) { |
| 16 | SetBackgroundStyle(wxBG_STYLE_PAINT); | 16 | SetBackgroundStyle(wxBG_STYLE_PAINT); |
| 17 | 17 | ||
| 18 | unchecked_eye_ = | 18 | LoadIcons(); |
| 19 | wxBitmap(wxImage(GetAbsolutePath("assets/unchecked.png").c_str(), | ||
| 20 | wxBITMAP_TYPE_PNG) | ||
| 21 | .Scale(32, 32)); | ||
| 22 | checked_eye_ = wxBitmap( | ||
| 23 | wxImage(GetAbsolutePath("assets/checked.png").c_str(), wxBITMAP_TYPE_PNG) | ||
| 24 | .Scale(32, 32)); | ||
| 25 | 19 | ||
| 20 | // TODO: This is slow on high-DPI screens. | ||
| 26 | SetScrollRate(5, 5); | 21 | SetScrollRate(5, 5); |
| 27 | 22 | ||
| 28 | SetBackgroundColour(*wxBLACK); | 23 | SetBackgroundColour(*wxBLACK); |
| 29 | Hide(); | 24 | Hide(); |
| 30 | 25 | ||
| 31 | Bind(wxEVT_PAINT, &AreaPopup::OnPaint, this); | 26 | Bind(wxEVT_PAINT, &AreaPopup::OnPaint, this); |
| 27 | Bind(wxEVT_DPI_CHANGED, &AreaPopup::OnDPIChanged, this); | ||
| 32 | 28 | ||
| 33 | UpdateIndicators(); | 29 | UpdateIndicators(); |
| 34 | } | 30 | } |
| @@ -36,15 +32,17 @@ AreaPopup::AreaPopup(wxWindow* parent, int area_id) | |||
| 36 | void AreaPopup::UpdateIndicators() { | 32 | void AreaPopup::UpdateIndicators() { |
| 37 | const MapArea& map_area = GD_GetMapArea(area_id_); | 33 | const MapArea& map_area = GD_GetMapArea(area_id_); |
| 38 | 34 | ||
| 35 | wxFont the_font = GetFont().Scale(GetDPIScaleFactor()); | ||
| 36 | |||
| 39 | // Start calculating extents. | 37 | // Start calculating extents. |
| 40 | wxMemoryDC mem_dc; | 38 | wxMemoryDC mem_dc; |
| 41 | mem_dc.SetFont(GetFont().Bold()); | 39 | mem_dc.SetFont(the_font.Bold()); |
| 42 | wxSize header_extent = mem_dc.GetTextExtent(map_area.name); | 40 | wxSize header_extent = mem_dc.GetTextExtent(map_area.name); |
| 43 | 41 | ||
| 44 | int acc_height = header_extent.GetHeight() + 20; | 42 | int acc_height = header_extent.GetHeight() + FromDIP(20); |
| 45 | int col_width = 0; | 43 | int col_width = 0; |
| 46 | 44 | ||
| 47 | mem_dc.SetFont(GetFont()); | 45 | mem_dc.SetFont(the_font); |
| 48 | 46 | ||
| 49 | TrackerPanel* tracker_panel = dynamic_cast<TrackerPanel*>(GetParent()); | 47 | TrackerPanel* tracker_panel = dynamic_cast<TrackerPanel*>(GetParent()); |
| 50 | 48 | ||
| @@ -68,7 +66,8 @@ void AreaPopup::UpdateIndicators() { | |||
| 68 | real_locations.push_back(section_id); | 66 | real_locations.push_back(section_id); |
| 69 | 67 | ||
| 70 | wxSize item_extent = mem_dc.GetTextExtent(location.name); | 68 | wxSize item_extent = mem_dc.GetTextExtent(location.name); |
| 71 | int item_height = std::max(32, item_extent.GetHeight()) + 10; | 69 | int item_height = |
| 70 | std::max(FromDIP(32), item_extent.GetHeight()) + FromDIP(10); | ||
| 72 | acc_height += item_height; | 71 | acc_height += item_height; |
| 73 | 72 | ||
| 74 | if (item_extent.GetWidth() > col_width) { | 73 | if (item_extent.GetWidth() > col_width) { |
| @@ -80,7 +79,8 @@ void AreaPopup::UpdateIndicators() { | |||
| 80 | for (int painting_id : map_area.paintings) { | 79 | for (int painting_id : map_area.paintings) { |
| 81 | const PaintingExit& painting = GD_GetPaintingExit(painting_id); | 80 | const PaintingExit& painting = GD_GetPaintingExit(painting_id); |
| 82 | wxSize item_extent = mem_dc.GetTextExtent(painting.display_name); | 81 | wxSize item_extent = mem_dc.GetTextExtent(painting.display_name); |
| 83 | int item_height = std::max(32, item_extent.GetHeight()) + 10; | 82 | int item_height = |
| 83 | std::max(FromDIP(32), item_extent.GetHeight()) + FromDIP(10); | ||
| 84 | acc_height += item_height; | 84 | acc_height += item_height; |
| 85 | 85 | ||
| 86 | if (item_extent.GetWidth() > col_width) { | 86 | if (item_extent.GetWidth() > col_width) { |
| @@ -89,8 +89,8 @@ void AreaPopup::UpdateIndicators() { | |||
| 89 | } | 89 | } |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | int item_width = col_width + 10 + 32; | 92 | int item_width = col_width + FromDIP(10 + 32); |
| 93 | int full_width = std::max(header_extent.GetWidth(), item_width) + 20; | 93 | int full_width = std::max(header_extent.GetWidth(), item_width) + FromDIP(20); |
| 94 | 94 | ||
| 95 | Fit(); | 95 | Fit(); |
| 96 | SetVirtualSize(full_width, acc_height); | 96 | SetVirtualSize(full_width, acc_height); |
| @@ -101,14 +101,14 @@ void AreaPopup::UpdateIndicators() { | |||
| 101 | mem_dc.SetBrush(*wxBLACK_BRUSH); | 101 | mem_dc.SetBrush(*wxBLACK_BRUSH); |
| 102 | mem_dc.DrawRectangle({0, 0}, {full_width, acc_height}); | 102 | mem_dc.DrawRectangle({0, 0}, {full_width, acc_height}); |
| 103 | 103 | ||
| 104 | mem_dc.SetFont(GetFont().Bold()); | 104 | mem_dc.SetFont(the_font.Bold()); |
| 105 | mem_dc.SetTextForeground(*wxWHITE); | 105 | mem_dc.SetTextForeground(*wxWHITE); |
| 106 | mem_dc.DrawText(map_area.name, | 106 | mem_dc.DrawText(map_area.name, |
| 107 | {(full_width - header_extent.GetWidth()) / 2, 10}); | 107 | {(full_width - header_extent.GetWidth()) / 2, FromDIP(10)}); |
| 108 | 108 | ||
| 109 | int cur_height = header_extent.GetHeight() + 20; | 109 | int cur_height = header_extent.GetHeight() + FromDIP(20); |
| 110 | 110 | ||
| 111 | mem_dc.SetFont(GetFont()); | 111 | mem_dc.SetFont(the_font); |
| 112 | 112 | ||
| 113 | for (int section_id : real_locations) { | 113 | for (int section_id : real_locations) { |
| 114 | const Location& location = map_area.locations.at(section_id); | 114 | const Location& location = map_area.locations.at(section_id); |
| @@ -131,7 +131,7 @@ void AreaPopup::UpdateIndicators() { | |||
| 131 | 131 | ||
| 132 | wxBitmap* eye_ptr = checked ? &checked_eye_ : &unchecked_eye_; | 132 | wxBitmap* eye_ptr = checked ? &checked_eye_ : &unchecked_eye_; |
| 133 | 133 | ||
| 134 | mem_dc.DrawBitmap(*eye_ptr, {10, cur_height}); | 134 | mem_dc.DrawBitmap(*eye_ptr, {FromDIP(10), cur_height}); |
| 135 | 135 | ||
| 136 | bool reachable = IsLocationReachable(location.ap_location_id); | 136 | bool reachable = IsLocationReachable(location.ap_location_id); |
| 137 | const wxColour* text_color = reachable ? wxWHITE : wxRED; | 137 | const wxColour* text_color = reachable ? wxWHITE : wxRED; |
| @@ -140,9 +140,10 @@ void AreaPopup::UpdateIndicators() { | |||
| 140 | wxSize item_extent = mem_dc.GetTextExtent(location.name); | 140 | wxSize item_extent = mem_dc.GetTextExtent(location.name); |
| 141 | mem_dc.DrawText( | 141 | mem_dc.DrawText( |
| 142 | location.name, | 142 | location.name, |
| 143 | {10 + 32 + 10, cur_height + (32 - mem_dc.GetFontMetrics().height) / 2}); | 143 | {FromDIP(10 + 32 + 10), |
| 144 | cur_height + (FromDIP(32) - mem_dc.GetFontMetrics().height) / 2}); | ||
| 144 | 145 | ||
| 145 | cur_height += 10 + 32; | 146 | cur_height += FromDIP(10 + 32); |
| 146 | } | 147 | } |
| 147 | 148 | ||
| 148 | if (AP_IsPaintingShuffle() && !tracker_panel->IsPanelsMode()) { | 149 | if (AP_IsPaintingShuffle() && !tracker_panel->IsPanelsMode()) { |
| @@ -155,14 +156,14 @@ void AreaPopup::UpdateIndicators() { | |||
| 155 | 156 | ||
| 156 | bool checked = reachable && AP_IsPaintingChecked(painting.internal_id); | 157 | bool checked = reachable && AP_IsPaintingChecked(painting.internal_id); |
| 157 | wxBitmap* eye_ptr = checked ? &checked_eye_ : &unchecked_eye_; | 158 | wxBitmap* eye_ptr = checked ? &checked_eye_ : &unchecked_eye_; |
| 158 | mem_dc.DrawBitmap(*eye_ptr, {10, cur_height}); | 159 | mem_dc.DrawBitmap(*eye_ptr, {FromDIP(10), cur_height}); |
| 159 | 160 | ||
| 160 | wxSize item_extent = mem_dc.GetTextExtent(painting.display_name); | 161 | wxSize item_extent = mem_dc.GetTextExtent(painting.display_name); |
| 161 | mem_dc.DrawText(painting.display_name, | 162 | mem_dc.DrawText(painting.display_name, |
| 162 | {10 + 32 + 10, | 163 | {FromDIP(10 + 32 + 10), |
| 163 | cur_height + (32 - mem_dc.GetFontMetrics().height) / 2}); | 164 | cur_height + (FromDIP(32) - mem_dc.GetFontMetrics().height) / 2}); |
| 164 | 165 | ||
| 165 | cur_height += 10 + 32; | 166 | cur_height += FromDIP(10 + 32); |
| 166 | } | 167 | } |
| 167 | } | 168 | } |
| 168 | } | 169 | } |
| @@ -174,3 +175,20 @@ void AreaPopup::OnPaint(wxPaintEvent& event) { | |||
| 174 | 175 | ||
| 175 | event.Skip(); | 176 | event.Skip(); |
| 176 | } | 177 | } |
| 178 | |||
| 179 | void AreaPopup::OnDPIChanged(wxDPIChangedEvent& event) { | ||
| 180 | LoadIcons(); | ||
| 181 | UpdateIndicators(); | ||
| 182 | } | ||
| 183 | |||
| 184 | void AreaPopup::LoadIcons() { | ||
| 185 | // TODO: We do not have to read these in and scale them for every single | ||
| 186 | // popup. | ||
| 187 | unchecked_eye_ = | ||
| 188 | wxBitmap(wxImage(GetAbsolutePath("assets/unchecked.png").c_str(), | ||
| 189 | wxBITMAP_TYPE_PNG) | ||
| 190 | .Scale(FromDIP(32), FromDIP(32))); | ||
| 191 | checked_eye_ = wxBitmap( | ||
| 192 | wxImage(GetAbsolutePath("assets/checked.png").c_str(), wxBITMAP_TYPE_PNG) | ||
| 193 | .Scale(FromDIP(32), FromDIP(32))); | ||
| 194 | } | ||
| diff --git a/src/area_popup.h b/src/area_popup.h index 00c644d..3326406 100644 --- a/src/area_popup.h +++ b/src/area_popup.h | |||
| @@ -15,6 +15,9 @@ class AreaPopup : public wxScrolledCanvas { | |||
| 15 | 15 | ||
| 16 | private: | 16 | private: |
| 17 | void OnPaint(wxPaintEvent& event); | 17 | void OnPaint(wxPaintEvent& event); |
| 18 | void OnDPIChanged(wxDPIChangedEvent& event); | ||
| 19 | |||
| 20 | void LoadIcons(); | ||
| 18 | 21 | ||
| 19 | int area_id_; | 22 | int area_id_; |
| 20 | 23 | ||
| diff --git a/src/connection_dialog.cpp b/src/connection_dialog.cpp index 45a5b53..b55a138 100644 --- a/src/connection_dialog.cpp +++ b/src/connection_dialog.cpp | |||
| @@ -7,17 +7,18 @@ ConnectionDialog::ConnectionDialog() | |||
| 7 | server_box_ = new wxTextCtrl( | 7 | server_box_ = new wxTextCtrl( |
| 8 | this, -1, | 8 | this, -1, |
| 9 | wxString::FromUTF8(GetTrackerConfig().connection_details.ap_server), | 9 | wxString::FromUTF8(GetTrackerConfig().connection_details.ap_server), |
| 10 | wxDefaultPosition, {300, -1}); | 10 | wxDefaultPosition, FromDIP(wxSize{300, -1})); |
| 11 | player_box_ = new wxTextCtrl( | 11 | player_box_ = new wxTextCtrl( |
| 12 | this, -1, | 12 | this, -1, |
| 13 | wxString::FromUTF8(GetTrackerConfig().connection_details.ap_player), | 13 | wxString::FromUTF8(GetTrackerConfig().connection_details.ap_player), |
| 14 | wxDefaultPosition, {300, -1}); | 14 | wxDefaultPosition, FromDIP(wxSize{300, -1})); |
| 15 | password_box_ = new wxTextCtrl( | 15 | password_box_ = new wxTextCtrl( |
| 16 | this, -1, | 16 | this, -1, |
| 17 | wxString::FromUTF8(GetTrackerConfig().connection_details.ap_password), | 17 | wxString::FromUTF8(GetTrackerConfig().connection_details.ap_password), |
| 18 | wxDefaultPosition, {300, -1}); | 18 | wxDefaultPosition, FromDIP(wxSize{300, -1})); |
| 19 | 19 | ||
| 20 | wxFlexGridSizer* form_sizer = new wxFlexGridSizer(2, 10, 10); | 20 | wxFlexGridSizer* form_sizer = |
| 21 | new wxFlexGridSizer(2, FromDIP(10), FromDIP(10)); | ||
| 21 | 22 | ||
| 22 | form_sizer->Add( | 23 | form_sizer->Add( |
| 23 | new wxStaticText(this, -1, "Server:"), | 24 | new wxStaticText(this, -1, "Server:"), |
| diff --git a/src/ipc_dialog.cpp b/src/ipc_dialog.cpp index 1e09a2f..6763b7f 100644 --- a/src/ipc_dialog.cpp +++ b/src/ipc_dialog.cpp | |||
| @@ -13,12 +13,13 @@ IpcDialog::IpcDialog() : wxDialog(nullptr, wxID_ANY, "Connect to game") { | |||
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | address_box_ = new wxTextCtrl(this, -1, wxString::FromUTF8(address_value), | 15 | address_box_ = new wxTextCtrl(this, -1, wxString::FromUTF8(address_value), |
| 16 | wxDefaultPosition, {300, -1}); | 16 | wxDefaultPosition, FromDIP(wxSize{300, -1})); |
| 17 | 17 | ||
| 18 | wxButton* reset_button = new wxButton(this, -1, "Use Default"); | 18 | wxButton* reset_button = new wxButton(this, -1, "Use Default"); |
| 19 | reset_button->Bind(wxEVT_BUTTON, &IpcDialog::OnResetClicked, this); | 19 | reset_button->Bind(wxEVT_BUTTON, &IpcDialog::OnResetClicked, this); |
| 20 | 20 | ||
| 21 | wxFlexGridSizer* form_sizer = new wxFlexGridSizer(3, 10, 10); | 21 | wxFlexGridSizer* form_sizer = |
| 22 | new wxFlexGridSizer(3, FromDIP(10), FromDIP(10)); | ||
| 22 | form_sizer->Add( | 23 | form_sizer->Add( |
| 23 | new wxStaticText(this, -1, "Address:"), | 24 | new wxStaticText(this, -1, "Address:"), |
| 24 | wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | 25 | wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); |
| diff --git a/src/report_popup.cpp b/src/report_popup.cpp index d772b32..74216c3 100644 --- a/src/report_popup.cpp +++ b/src/report_popup.cpp | |||
| @@ -12,20 +12,16 @@ ReportPopup::ReportPopup(wxWindow* parent) | |||
| 12 | : wxScrolledCanvas(parent, wxID_ANY) { | 12 | : wxScrolledCanvas(parent, wxID_ANY) { |
| 13 | SetBackgroundStyle(wxBG_STYLE_PAINT); | 13 | SetBackgroundStyle(wxBG_STYLE_PAINT); |
| 14 | 14 | ||
| 15 | unchecked_eye_ = | 15 | LoadIcons(); |
| 16 | wxBitmap(wxImage(GetAbsolutePath("assets/unchecked.png").c_str(), | ||
| 17 | wxBITMAP_TYPE_PNG) | ||
| 18 | .Scale(32, 32)); | ||
| 19 | checked_eye_ = wxBitmap( | ||
| 20 | wxImage(GetAbsolutePath("assets/checked.png").c_str(), wxBITMAP_TYPE_PNG) | ||
| 21 | .Scale(32, 32)); | ||
| 22 | 16 | ||
| 17 | // TODO: This is slow on high-DPI screens. | ||
| 23 | SetScrollRate(5, 5); | 18 | SetScrollRate(5, 5); |
| 24 | 19 | ||
| 25 | SetBackgroundColour(*wxBLACK); | 20 | SetBackgroundColour(*wxBLACK); |
| 26 | Hide(); | 21 | Hide(); |
| 27 | 22 | ||
| 28 | Bind(wxEVT_PAINT, &ReportPopup::OnPaint, this); | 23 | Bind(wxEVT_PAINT, &ReportPopup::OnPaint, this); |
| 24 | Bind(wxEVT_DPI_CHANGED, &ReportPopup::OnDPIChanged, this); | ||
| 29 | } | 25 | } |
| 30 | 26 | ||
| 31 | void ReportPopup::SetDoorId(int door_id) { | 27 | void ReportPopup::SetDoorId(int door_id) { |
| @@ -41,14 +37,18 @@ void ReportPopup::Reset() { | |||
| 41 | void ReportPopup::UpdateIndicators() { | 37 | void ReportPopup::UpdateIndicators() { |
| 42 | wxMemoryDC mem_dc; | 38 | wxMemoryDC mem_dc; |
| 43 | 39 | ||
| 40 | wxFont the_font = GetFont().Scale(GetDPIScaleFactor()); | ||
| 41 | mem_dc.SetFont(the_font); | ||
| 42 | |||
| 44 | const std::map<std::string, bool>& report = GetDoorRequirements(door_id_); | 43 | const std::map<std::string, bool>& report = GetDoorRequirements(door_id_); |
| 45 | 44 | ||
| 46 | int acc_height = 10; | 45 | int acc_height = FromDIP(10); |
| 47 | int col_width = 0; | 46 | int col_width = 0; |
| 48 | 47 | ||
| 49 | for (const auto& [text, obtained] : report) { | 48 | for (const auto& [text, obtained] : report) { |
| 50 | wxSize item_extent = mem_dc.GetTextExtent(text); | 49 | wxSize item_extent = mem_dc.GetTextExtent(text); |
| 51 | int item_height = std::max(32, item_extent.GetHeight()) + 10; | 50 | int item_height = |
| 51 | std::max(FromDIP(32), item_extent.GetHeight()) + FromDIP(10); | ||
| 52 | acc_height += item_height; | 52 | acc_height += item_height; |
| 53 | 53 | ||
| 54 | if (item_extent.GetWidth() > col_width) { | 54 | if (item_extent.GetWidth() > col_width) { |
| @@ -56,8 +56,8 @@ void ReportPopup::UpdateIndicators() { | |||
| 56 | } | 56 | } |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | int item_width = col_width + 10 + 32; | 59 | int item_width = col_width + FromDIP(10 + 32); |
| 60 | int full_width = item_width + 20; | 60 | int full_width = item_width + FromDIP(20); |
| 61 | 61 | ||
| 62 | Fit(); | 62 | Fit(); |
| 63 | SetVirtualSize(full_width, acc_height); | 63 | SetVirtualSize(full_width, acc_height); |
| @@ -68,22 +68,23 @@ void ReportPopup::UpdateIndicators() { | |||
| 68 | mem_dc.SetBrush(*wxBLACK_BRUSH); | 68 | mem_dc.SetBrush(*wxBLACK_BRUSH); |
| 69 | mem_dc.DrawRectangle({0, 0}, {full_width, acc_height}); | 69 | mem_dc.DrawRectangle({0, 0}, {full_width, acc_height}); |
| 70 | 70 | ||
| 71 | mem_dc.SetFont(GetFont()); | 71 | mem_dc.SetFont(the_font); |
| 72 | 72 | ||
| 73 | int cur_height = 10; | 73 | int cur_height = FromDIP(10); |
| 74 | 74 | ||
| 75 | for (const auto& [text, obtained] : report) { | 75 | for (const auto& [text, obtained] : report) { |
| 76 | wxBitmap* eye_ptr = obtained ? &checked_eye_ : &unchecked_eye_; | 76 | wxBitmap* eye_ptr = obtained ? &checked_eye_ : &unchecked_eye_; |
| 77 | 77 | ||
| 78 | mem_dc.DrawBitmap(*eye_ptr, wxPoint{10, cur_height}); | 78 | mem_dc.DrawBitmap(*eye_ptr, wxPoint{FromDIP(10), cur_height}); |
| 79 | 79 | ||
| 80 | mem_dc.SetTextForeground(obtained ? *wxWHITE : *wxRED); | 80 | mem_dc.SetTextForeground(obtained ? *wxWHITE : *wxRED); |
| 81 | wxSize item_extent = mem_dc.GetTextExtent(text); | 81 | wxSize item_extent = mem_dc.GetTextExtent(text); |
| 82 | mem_dc.DrawText( | 82 | mem_dc.DrawText( |
| 83 | text, wxPoint{10 + 32 + 10, | 83 | text, wxPoint{FromDIP(10 + 32 + 10), |
| 84 | cur_height + (32 - mem_dc.GetFontMetrics().height) / 2}); | 84 | cur_height + |
| 85 | (FromDIP(32) - mem_dc.GetFontMetrics().height) / 2}); | ||
| 85 | 86 | ||
| 86 | cur_height += 10 + 32; | 87 | cur_height += FromDIP(10 + 32); |
| 87 | } | 88 | } |
| 88 | } | 89 | } |
| 89 | 90 | ||
| @@ -96,3 +97,20 @@ void ReportPopup::OnPaint(wxPaintEvent& event) { | |||
| 96 | 97 | ||
| 97 | event.Skip(); | 98 | event.Skip(); |
| 98 | } | 99 | } |
| 100 | |||
| 101 | void ReportPopup::OnDPIChanged(wxDPIChangedEvent& event) { | ||
| 102 | LoadIcons(); | ||
| 103 | UpdateIndicators(); | ||
| 104 | } | ||
| 105 | |||
| 106 | void ReportPopup::LoadIcons() { | ||
| 107 | // TODO: We do not have to read these in and scale them for every single | ||
| 108 | // popup. | ||
| 109 | unchecked_eye_ = | ||
| 110 | wxBitmap(wxImage(GetAbsolutePath("assets/unchecked.png").c_str(), | ||
| 111 | wxBITMAP_TYPE_PNG) | ||
| 112 | .Scale(FromDIP(32), FromDIP(32))); | ||
| 113 | checked_eye_ = wxBitmap( | ||
| 114 | wxImage(GetAbsolutePath("assets/checked.png").c_str(), wxBITMAP_TYPE_PNG) | ||
| 115 | .Scale(FromDIP(32), FromDIP(32))); | ||
| 116 | } | ||
| diff --git a/src/report_popup.h b/src/report_popup.h index 9e141bf..4ccc913 100644 --- a/src/report_popup.h +++ b/src/report_popup.h | |||
| @@ -19,6 +19,9 @@ class ReportPopup : public wxScrolledCanvas { | |||
| 19 | 19 | ||
| 20 | private: | 20 | private: |
| 21 | void OnPaint(wxPaintEvent& event); | 21 | void OnPaint(wxPaintEvent& event); |
| 22 | void OnDPIChanged(wxDPIChangedEvent& event); | ||
| 23 | |||
| 24 | void LoadIcons(); | ||
| 22 | 25 | ||
| 23 | int door_id_ = -1; | 26 | int door_id_ = -1; |
| 24 | 27 | ||
| diff --git a/src/subway_map.cpp b/src/subway_map.cpp index c554b16..f742d12 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp | |||
| @@ -50,7 +50,7 @@ SubwayMap::SubwayMap(wxWindow *parent) : wxPanel(parent, wxID_ANY) { | |||
| 50 | Bind(wxEVT_LEFT_DOWN, &SubwayMap::OnMouseClick, this); | 50 | Bind(wxEVT_LEFT_DOWN, &SubwayMap::OnMouseClick, this); |
| 51 | Bind(wxEVT_TIMER, &SubwayMap::OnTimer, this); | 51 | Bind(wxEVT_TIMER, &SubwayMap::OnTimer, this); |
| 52 | 52 | ||
| 53 | zoom_slider_ = new wxSlider(this, wxID_ANY, 0, 0, 8, {15, 15}); | 53 | zoom_slider_ = new wxSlider(this, wxID_ANY, 0, 0, 8, FromDIP(wxPoint{15, 15})); |
| 54 | zoom_slider_->Bind(wxEVT_SLIDER, &SubwayMap::OnZoomSlide, this); | 54 | zoom_slider_->Bind(wxEVT_SLIDER, &SubwayMap::OnZoomSlide, this); |
| 55 | 55 | ||
| 56 | help_button_ = new wxButton(this, wxID_ANY, "Help"); | 56 | help_button_ = new wxButton(this, wxID_ANY, "Help"); |
| @@ -252,6 +252,9 @@ void SubwayMap::OnPaint(wxPaintEvent &event) { | |||
| 252 | SetZoomPos({zoom_x_, zoom_y_}); | 252 | SetZoomPos({zoom_x_, zoom_y_}); |
| 253 | 253 | ||
| 254 | SetUpHelpButton(); | 254 | SetUpHelpButton(); |
| 255 | |||
| 256 | zoom_slider_->SetSize(FromDIP(15), FromDIP(15), wxDefaultCoord, | ||
| 257 | wxDefaultCoord, wxSIZE_AUTO); | ||
| 255 | } | 258 | } |
| 256 | 259 | ||
| 257 | wxBufferedPaintDC dc(this); | 260 | wxBufferedPaintDC dc(this); |
| @@ -620,6 +623,8 @@ void SubwayMap::Redraw() { | |||
| 620 | } | 623 | } |
| 621 | 624 | ||
| 622 | void SubwayMap::SetUpHelpButton() { | 625 | void SubwayMap::SetUpHelpButton() { |
| 626 | help_button_->SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, | ||
| 627 | wxDefaultCoord, wxSIZE_AUTO); | ||
| 623 | help_button_->SetPosition({ | 628 | help_button_->SetPosition({ |
| 624 | GetSize().GetWidth() - help_button_->GetSize().GetWidth() - 15, | 629 | GetSize().GetWidth() - help_button_->GetSize().GetWidth() - 15, |
| 625 | 15, | 630 | 15, |
| diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index 3f51cd5..81b58cc 100644 --- a/src/tracker_panel.cpp +++ b/src/tracker_panel.cpp | |||
| @@ -66,9 +66,9 @@ void TrackerPanel::SetPanelsMode() { panels_mode_ = true; } | |||
| 66 | 66 | ||
| 67 | void TrackerPanel::SetSavedataPath(std::string savedata_path) { | 67 | void TrackerPanel::SetSavedataPath(std::string savedata_path) { |
| 68 | if (!savedata_path_) { | 68 | if (!savedata_path_) { |
| 69 | wxButton *refresh_button = | 69 | refresh_button_ = new wxButton(this, wxID_ANY, "Refresh"); |
| 70 | new wxButton(this, wxID_ANY, "Refresh", {15, 15}); | 70 | refresh_button_->Bind(wxEVT_BUTTON, &TrackerPanel::OnRefreshSavedata, this); |
| 71 | refresh_button->Bind(wxEVT_BUTTON, &TrackerPanel::OnRefreshSavedata, this); | 71 | SetUpRefreshButton(); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | savedata_path_ = savedata_path; | 74 | savedata_path_ = savedata_path; |
| @@ -97,6 +97,10 @@ void TrackerPanel::RefreshSavedata() { | |||
| 97 | void TrackerPanel::OnPaint(wxPaintEvent &event) { | 97 | void TrackerPanel::OnPaint(wxPaintEvent &event) { |
| 98 | if (GetSize() != rendered_.GetSize()) { | 98 | if (GetSize() != rendered_.GetSize()) { |
| 99 | Redraw(); | 99 | Redraw(); |
| 100 | |||
| 101 | if (refresh_button_ != nullptr) { | ||
| 102 | SetUpRefreshButton(); | ||
| 103 | } | ||
| 100 | } | 104 | } |
| 101 | 105 | ||
| 102 | wxBufferedPaintDC dc(this); | 106 | wxBufferedPaintDC dc(this); |
| @@ -316,3 +320,8 @@ void TrackerPanel::Redraw() { | |||
| 316 | area.popup->SetPosition({popup_x, popup_y}); | 320 | area.popup->SetPosition({popup_x, popup_y}); |
| 317 | } | 321 | } |
| 318 | } | 322 | } |
| 323 | |||
| 324 | void TrackerPanel::SetUpRefreshButton() { | ||
| 325 | refresh_button_->SetSize(FromDIP(15), FromDIP(15), wxDefaultCoord, | ||
| 326 | wxDefaultCoord, wxSIZE_AUTO); | ||
| 327 | } | ||
| diff --git a/src/tracker_panel.h b/src/tracker_panel.h index 822d181..b7067f5 100644 --- a/src/tracker_panel.h +++ b/src/tracker_panel.h | |||
| @@ -48,11 +48,15 @@ class TrackerPanel : public wxPanel { | |||
| 48 | 48 | ||
| 49 | void RefreshSavedata(); | 49 | void RefreshSavedata(); |
| 50 | 50 | ||
| 51 | void SetUpRefreshButton(); | ||
| 52 | |||
| 51 | wxImage map_image_; | 53 | wxImage map_image_; |
| 52 | wxImage player_image_; | 54 | wxImage player_image_; |
| 53 | wxBitmap rendered_; | 55 | wxBitmap rendered_; |
| 54 | wxBitmap scaled_player_; | 56 | wxBitmap scaled_player_; |
| 55 | 57 | ||
| 58 | wxButton *refresh_button_ = nullptr; | ||
| 59 | |||
| 56 | int offset_x_ = 0; | 60 | int offset_x_ = 0; |
| 57 | int offset_y_ = 0; | 61 | int offset_y_ = 0; |
| 58 | double scale_x_ = 0; | 62 | double scale_x_ = 0; |
