From 350aff3a60386ecebc2be42d1ff2e71ec0230adc Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 19 Jan 2024 15:56:14 -0500 Subject: Fix some bad memory access stuff --- src/game_data.cpp | 181 +++++++++++++++++++++++++++++------------------------- 1 file changed, 99 insertions(+), 82 deletions(-) (limited to 'src') diff --git a/src/game_data.cpp b/src/game_data.cpp index 5204262..8f237b0 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -98,16 +98,14 @@ struct GameData { for (const auto &room_it : lingo_config) { int room_id = AddOrGetRoom(room_it.first.as()); - Room &room_obj = rooms_[room_id]; for (const auto &entrance_it : room_it.second["entrances"]) { int from_room_id = AddOrGetRoom(entrance_it.first.as()); - Room &from_room_obj = rooms_[from_room_id]; switch (entrance_it.second.Type()) { case YAML::NodeType::Scalar: { // This is just "true". - from_room_obj.exits.push_back({.destination_room = room_id}); + rooms_[from_room_id].exits.push_back({.destination_room = room_id}); break; } case YAML::NodeType::Map: { @@ -115,7 +113,7 @@ struct GameData { exit_obj.destination_room = room_id; if (entrance_it.second["door"]) { - std::string door_room = room_obj.name; + std::string door_room = rooms_[room_id].name; if (entrance_it.second["room"]) { door_room = entrance_it.second["room"].as(); } @@ -127,7 +125,7 @@ struct GameData { exit_obj.painting = entrance_it.second["painting"].as(); } - from_room_obj.exits.push_back(exit_obj); + rooms_[from_room_id].exits.push_back(exit_obj); break; } case YAML::NodeType::Sequence: { @@ -135,7 +133,7 @@ struct GameData { Exit exit_obj; exit_obj.destination_room = room_id; - std::string door_room = room_obj.name; + std::string door_room = rooms_[room_id].name; if (option["room"]) { door_room = option["room"].as(); } @@ -146,7 +144,7 @@ struct GameData { exit_obj.painting = option["painting"].as(); } - from_room_obj.exits.push_back(exit_obj); + rooms_[from_room_id].exits.push_back(exit_obj); } break; @@ -162,18 +160,17 @@ struct GameData { if (room_it.second["panels"]) { for (const auto &panel_it : room_it.second["panels"]) { - int panel_id = - AddOrGetPanel(room_obj.name, panel_it.first.as()); - Panel &panel_obj = panels_[panel_id]; - room_obj.panels.push_back(panel_id); + int panel_id = AddOrGetPanel(rooms_[room_id].name, + panel_it.first.as()); + rooms_[room_id].panels.push_back(panel_id); if (panel_it.second["colors"]) { if (panel_it.second["colors"].IsScalar()) { - panel_obj.colors.push_back(GetColorForString( + panels_[panel_id].colors.push_back(GetColorForString( panel_it.second["colors"].as())); } else { for (const auto &color_node : panel_it.second["colors"]) { - panel_obj.colors.push_back( + panels_[panel_id].colors.push_back( GetColorForString(color_node.as())); } } @@ -181,11 +178,11 @@ struct GameData { if (panel_it.second["required_room"]) { if (panel_it.second["required_room"].IsScalar()) { - panel_obj.required_rooms.push_back(AddOrGetRoom( + panels_[panel_id].required_rooms.push_back(AddOrGetRoom( panel_it.second["required_room"].as())); } else { for (const auto &rr_node : panel_it.second["required_room"]) { - panel_obj.required_rooms.push_back( + panels_[panel_id].required_rooms.push_back( AddOrGetRoom(rr_node.as())); } } @@ -193,23 +190,22 @@ struct GameData { if (panel_it.second["required_door"]) { if (panel_it.second["required_door"].IsMap()) { - std::string rd_room = room_obj.name; + std::string rd_room = rooms_[room_id].name; if (panel_it.second["required_door"]["room"]) { rd_room = panel_it.second["required_door"]["room"].as(); } - panel_obj.required_doors.push_back(AddOrGetDoor( + panels_[panel_id].required_doors.push_back(AddOrGetDoor( rd_room, panel_it.second["required_door"]["door"].as())); } else { for (const auto &rr_node : panel_it.second["required_door"]) { - std::string rd_room = room_obj.name; + std::string rd_room = rooms_[room_id].name; if (rr_node["room"]) { rd_room = rr_node["room"].as(); - } - - panel_obj.required_doors.push_back( + }; + panels_[panel_id].required_doors.push_back( AddOrGetDoor(rd_room, rr_node["door"].as())); } } @@ -217,61 +213,68 @@ struct GameData { if (panel_it.second["required_panel"]) { if (panel_it.second["required_panel"].IsMap()) { - std::string rp_room = room_obj.name; + std::string rp_room = rooms_[room_id].name; if (panel_it.second["required_panel"]["room"]) { rp_room = panel_it.second["required_panel"]["room"].as(); } - panel_obj.required_panels.push_back(AddOrGetPanel( - rp_room, panel_it.second["required_panel"]["panel"] - .as())); + int rp_id = AddOrGetPanel( + rp_room, + panel_it.second["required_panel"]["panel"].as()); + panels_[panel_id].required_panels.push_back(rp_id); } else { for (const auto &rp_node : panel_it.second["required_panel"]) { - std::string rp_room = room_obj.name; + std::string rp_room = rooms_[room_id].name; if (rp_node["room"]) { rp_room = rp_node["room"].as(); } - panel_obj.required_panels.push_back( - AddOrGetPanel(rp_room, rp_node["panel"].as())); + int rp_id = + AddOrGetPanel(rp_room, rp_node["panel"].as()); + panels_[panel_id].required_panels.push_back(rp_id); } } } if (panel_it.second["check"]) { - panel_obj.check = panel_it.second["check"].as(); + panels_[panel_id].check = panel_it.second["check"].as(); } if (panel_it.second["achievement"]) { - panel_obj.achievement = true; - panel_obj.achievement_name = + panels_[panel_id].achievement = true; + panels_[panel_id].achievement_name = panel_it.second["achievement"].as(); achievement_panels_.push_back(panel_id); } if (panel_it.second["hunt"]) { - panel_obj.hunt = panel_it.second["hunt"].as(); + panels_[panel_id].hunt = panel_it.second["hunt"].as(); } if (panel_it.second["exclude_reduce"]) { - panel_obj.exclude_reduce = + panels_[panel_id].exclude_reduce = panel_it.second["exclude_reduce"].as(); } if (panel_it.second["non_counting"]) { - panel_obj.non_counting = panel_it.second["non_counting"].as(); + panels_[panel_id].non_counting = + panel_it.second["non_counting"].as(); } - if (ids_config["panels"] && ids_config["panels"][room_obj.name] && - ids_config["panels"][room_obj.name][panel_obj.name]) { - panel_obj.ap_location_id = - ids_config["panels"][room_obj.name][panel_obj.name].as(); + if (ids_config["panels"] && + ids_config["panels"][rooms_[room_id].name] && + ids_config["panels"][rooms_[room_id].name] + [panels_[panel_id].name]) { + panels_[panel_id].ap_location_id = + ids_config["panels"][rooms_[room_id].name] + [panels_[panel_id].name] + .as(); } else { std::ostringstream errmsg; - errmsg << "Missing AP location ID for panel " << room_obj.name - << " - " << panel_obj.name; + errmsg << "Missing AP location ID for panel " + << rooms_[room_id].name << " - " << panels_[panel_id].name; TrackerLog(errmsg.str()); } } @@ -279,10 +282,9 @@ struct GameData { if (room_it.second["doors"]) { for (const auto &door_it : room_it.second["doors"]) { - int door_id = - AddOrGetDoor(room_obj.name, door_it.first.as()); + int door_id = AddOrGetDoor(rooms_[room_id].name, + door_it.first.as()); door_definition_order_.push_back(door_id); - Door &door_obj = doors_[door_id]; bool has_external_panels = false; std::vector panel_names; @@ -290,103 +292,117 @@ struct GameData { for (const auto &panel_node : door_it.second["panels"]) { if (panel_node.IsScalar()) { panel_names.push_back(panel_node.as()); - door_obj.panels.push_back( - AddOrGetPanel(room_obj.name, panel_node.as())); + doors_[door_id].panels.push_back(AddOrGetPanel( + rooms_[room_id].name, panel_node.as())); } else { has_external_panels = true; panel_names.push_back(panel_node["panel"].as()); - door_obj.panels.push_back( + doors_[door_id].panels.push_back( AddOrGetPanel(panel_node["room"].as(), panel_node["panel"].as())); } } if (door_it.second["skip_location"]) { - door_obj.skip_location = door_it.second["skip_location"].as(); + doors_[door_id].skip_location = + door_it.second["skip_location"].as(); } if (door_it.second["skip_item"]) { - door_obj.skip_item = door_it.second["skip_item"].as(); + doors_[door_id].skip_item = door_it.second["skip_item"].as(); } if (door_it.second["event"]) { - door_obj.skip_location = door_it.second["event"].as(); - door_obj.skip_item = door_it.second["event"].as(); - door_obj.is_event = door_it.second["event"].as(); + doors_[door_id].skip_location = door_it.second["event"].as(); + doors_[door_id].skip_item = door_it.second["event"].as(); + doors_[door_id].is_event = door_it.second["event"].as(); } if (door_it.second["item_name"]) { - door_obj.item_name = door_it.second["item_name"].as(); + doors_[door_id].item_name = + door_it.second["item_name"].as(); } else if (!door_it.second["skip_item"] && !door_it.second["event"]) { - door_obj.item_name = room_obj.name + " - " + door_obj.name; + doors_[door_id].item_name = + rooms_[room_id].name + " - " + doors_[door_id].name; } if (!door_it.second["skip_item"] && !door_it.second["event"]) { - if (ids_config["doors"] && ids_config["doors"][room_obj.name] && - ids_config["doors"][room_obj.name][door_obj.name] && - ids_config["doors"][room_obj.name][door_obj.name]["item"]) { - door_obj.ap_item_id = - ids_config["doors"][room_obj.name][door_obj.name]["item"] - .as(); + if (ids_config["doors"] && + ids_config["doors"][rooms_[room_id].name] && + ids_config["doors"][rooms_[room_id].name] + [doors_[door_id].name] && + ids_config["doors"][rooms_[room_id].name][doors_[door_id].name] + ["item"]) { + doors_[door_id].ap_item_id = + ids_config["doors"][rooms_[room_id].name] + [doors_[door_id].name]["item"] + .as(); } else { std::ostringstream errmsg; - errmsg << "Missing AP item ID for door " << room_obj.name << " - " - << door_obj.name; + errmsg << "Missing AP item ID for door " << rooms_[room_id].name + << " - " << doors_[door_id].name; TrackerLog(errmsg.str()); } } if (door_it.second["group"]) { - door_obj.group_name = door_it.second["group"].as(); + doors_[door_id].group_name = + door_it.second["group"].as(); if (ids_config["door_groups"] && - ids_config["door_groups"][door_obj.group_name]) { - door_obj.group_ap_item_id = - ids_config["door_groups"][door_obj.group_name].as(); + ids_config["door_groups"][doors_[door_id].group_name]) { + doors_[door_id].group_ap_item_id = + ids_config["door_groups"][doors_[door_id].group_name] + .as(); } else { std::ostringstream errmsg; errmsg << "Missing AP item ID for door group " - << door_obj.group_name; + << doors_[door_id].group_name; TrackerLog(errmsg.str()); } } if (door_it.second["location_name"]) { - door_obj.location_name = + doors_[door_id].location_name = door_it.second["location_name"].as(); } else if (!door_it.second["skip_location"] && !door_it.second["event"]) { if (has_external_panels) { std::ostringstream errmsg; errmsg - << room_obj.name << " - " << door_obj.name + << rooms_[room_id].name << " - " << doors_[door_id].name << " has panels from other rooms but does not have an " "explicit " "location name and is not marked skip_location or event"; TrackerLog(errmsg.str()); } - door_obj.location_name = - room_obj.name + " - " + hatkirby::implode(panel_names, ", "); + doors_[door_id].location_name = + rooms_[room_id].name + " - " + + hatkirby::implode(panel_names, ", "); } if (!door_it.second["skip_location"] && !door_it.second["event"]) { - if (ids_config["doors"] && ids_config["doors"][room_obj.name] && - ids_config["doors"][room_obj.name][door_obj.name] && - ids_config["doors"][room_obj.name][door_obj.name]["location"]) { - door_obj.ap_location_id = - ids_config["doors"][room_obj.name][door_obj.name]["location"] - .as(); + if (ids_config["doors"] && + ids_config["doors"][rooms_[room_id].name] && + ids_config["doors"][rooms_[room_id].name] + [doors_[door_id].name] && + ids_config["doors"][rooms_[room_id].name][doors_[door_id].name] + ["location"]) { + doors_[door_id].ap_location_id = + ids_config["doors"][rooms_[room_id].name] + [doors_[door_id].name]["location"] + .as(); } else { std::ostringstream errmsg; - errmsg << "Missing AP location ID for door " << room_obj.name - << " - " << door_obj.name; + errmsg << "Missing AP location ID for door " + << rooms_[room_id].name << " - " << doors_[door_id].name; TrackerLog(errmsg.str()); } } if (door_it.second["include_reduce"]) { - door_obj.exclude_reduce = + doors_[door_id].exclude_reduce = !door_it.second["include_reduce"].as(); } } @@ -402,7 +418,7 @@ struct GameData { painting_exit.id = painting_id; if (painting["required_door"]) { - std::string rd_room = room_obj.name; + std::string rd_room = rooms_[room_id].name; if (painting["required_door"]["room"]) { rd_room = painting["required_door"]["room"].as(); } @@ -411,7 +427,7 @@ struct GameData { rd_room, painting["required_door"]["door"].as()); } - room_obj.paintings.push_back(painting_exit); + rooms_[room_id].paintings.push_back(painting_exit); } } } @@ -438,7 +454,8 @@ struct GameData { int door_id = -1; if (stage.IsScalar()) { - door_id = AddOrGetDoor(room_obj.name, stage.as()); + door_id = + AddOrGetDoor(rooms_[room_id].name, stage.as()); } else { door_id = AddOrGetDoor(stage["room"].as(), stage["door"].as()); -- cgit 1.4.1 From 402d559af2a727f106fa7fa59132b6710a5ae84e Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 19 Jan 2024 18:12:32 -0500 Subject: Open window at a bigger size --- src/tracker_frame.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index 4e3a8a8..a8c1063 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp @@ -30,8 +30,6 @@ TrackerFrame::TrackerFrame() AP_SetTrackerFrame(this); - SetSize(1280, 728); - wxMenu *menuFile = new wxMenu(); menuFile->Append(ID_CONNECT, "&Connect"); menuFile->Append(ID_SETTINGS, "&Settings"); @@ -70,6 +68,7 @@ TrackerFrame::TrackerFrame() top_sizer->Add(tracker_panel_, wxSizerFlags().Expand().Proportion(3)); SetSizerAndFit(top_sizer); + SetSize(1280, 728); if (!GetTrackerConfig().asked_to_check_for_updates) { GetTrackerConfig().asked_to_check_for_updates = true; -- cgit 1.4.1 From 0a3c0c6882db2976c2b6fdbebbc127747ed63703 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 19 Jan 2024 18:16:41 -0500 Subject: Area popups are now painted Instead of being a bunch of controls. This fixes the problem with the window being slow to drag around, and with items in lists disappearing. Overall W for me. --- CMakeLists.txt | 1 - src/area_popup.cpp | 118 +++++++++++++++++++++++++++++++++----------------- src/area_popup.h | 11 ++--- src/eye_indicator.cpp | 51 ---------------------- src/eye_indicator.h | 30 ------------- src/tracker_panel.cpp | 10 +++-- 6 files changed, 91 insertions(+), 130 deletions(-) delete mode 100644 src/eye_indicator.cpp delete mode 100644 src/eye_indicator.h (limited to 'src') diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e08b68..d82919a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,6 @@ add_executable(lingo_ap_tracker "src/area_popup.cpp" "src/ap_state.cpp" "src/connection_dialog.cpp" - "src/eye_indicator.cpp" "src/tracker_state.cpp" "src/tracker_config.cpp" "src/logger.cpp" diff --git a/src/area_popup.cpp b/src/area_popup.cpp index 6bbc0cf..8f694bb 100644 --- a/src/area_popup.cpp +++ b/src/area_popup.cpp @@ -2,73 +2,113 @@ #include "ap_state.h" #include "game_data.h" +#include "global.h" #include "tracker_config.h" #include "tracker_state.h" AreaPopup::AreaPopup(wxWindow* parent, int area_id) - : wxScrolledWindow(parent, wxID_ANY), area_id_(area_id) { - const MapArea& map_area = GD_GetMapArea(area_id); - - wxFlexGridSizer* section_sizer = new wxFlexGridSizer(2, 10, 10); - - for (const Location& location : map_area.locations) { - EyeIndicator* eye_indicator = new EyeIndicator(this); - section_sizer->Add(eye_indicator, wxSizerFlags().Expand()); - eye_indicators_.push_back(eye_indicator); - - wxStaticText* section_label = new wxStaticText(this, -1, location.name); - section_label->SetForegroundColour(*wxWHITE); - section_sizer->Add( - section_label, - wxSizerFlags().Align(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL)); - section_labels_.push_back(section_label); - } - - wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL); - - wxStaticText* top_label = new wxStaticText(this, -1, map_area.name); - top_label->SetForegroundColour(*wxWHITE); - top_label->SetFont(top_label->GetFont().Bold()); - top_sizer->Add(top_label, - wxSizerFlags().Center().DoubleBorder(wxUP | wxLEFT | wxRIGHT)); - - top_sizer->Add(section_sizer, wxSizerFlags().DoubleBorder(wxALL).Expand()); + : wxScrolledCanvas(parent, wxID_ANY), area_id_(area_id) { + unchecked_eye_ = + wxBitmap(wxImage(GetAbsolutePath("assets/unchecked.png").c_str(), + wxBITMAP_TYPE_PNG) + .Scale(32, 32)); + checked_eye_ = wxBitmap( + wxImage(GetAbsolutePath("assets/checked.png").c_str(), wxBITMAP_TYPE_PNG) + .Scale(32, 32)); - SetSizerAndFit(top_sizer); SetScrollRate(5, 5); SetBackgroundColour(*wxBLACK); Hide(); + + Bind(wxEVT_PAINT, &AreaPopup::OnPaint, this); + + UpdateIndicators(); } void AreaPopup::UpdateIndicators() { const MapArea& map_area = GD_GetMapArea(area_id_); + + // Start calculating extents. + wxMemoryDC mem_dc; + mem_dc.SetFont(GetFont().Bold()); + wxSize header_extent = mem_dc.GetTextExtent(map_area.name); + + int acc_height = header_extent.GetHeight() + 20; + int col_width = 0; + + mem_dc.SetFont(GetFont()); + + std::vector real_locations; + for (int section_id = 0; section_id < map_area.locations.size(); section_id++) { const Location& location = map_area.locations.at(section_id); - wxSizer* container_sizer = - section_labels_[section_id]->GetContainingSizer(); if (!AP_IsLocationVisible(location.classification) && !(location.hunt && GetTrackerConfig().show_hunt_panels)) { - container_sizer->Hide(section_labels_[section_id]); - container_sizer->Hide(eye_indicators_[section_id]); continue; - } else { - container_sizer->Show(section_labels_[section_id]); - container_sizer->Show(eye_indicators_[section_id]); } + real_locations.push_back(section_id); + + wxSize item_extent = mem_dc.GetTextExtent(location.name); + int item_height = std::max(32, item_extent.GetHeight()) + 10; + acc_height += item_height; + + if (item_extent.GetWidth() > col_width) { + col_width = item_extent.GetWidth(); + } + } + + int item_width = col_width + 10 + 32; + int full_width = std::max(header_extent.GetWidth(), item_width) + 20; + + SetVirtualSize(full_width, acc_height); + + rendered_ = wxBitmap(full_width, acc_height); + mem_dc.SelectObject(rendered_); + mem_dc.SetPen(*wxTRANSPARENT_PEN); + mem_dc.SetBrush(*wxBLACK_BRUSH); + mem_dc.DrawRectangle({0, 0}, {full_width, acc_height}); + + mem_dc.SetFont(GetFont().Bold()); + mem_dc.SetTextForeground(*wxWHITE); + mem_dc.DrawText(map_area.name, + {(full_width - header_extent.GetWidth()) / 2, 10}); + + int cur_height = header_extent.GetHeight() + 20; + + mem_dc.SetFont(GetFont()); + + for (int section_id : real_locations) { + const Location& location = map_area.locations.at(section_id); + bool checked = AP_HasCheckedGameLocation(location.ap_location_id) || (location.hunt && AP_HasCheckedHuntPanel(location.ap_location_id)); + + wxBitmap* eye_ptr = checked ? &checked_eye_ : &unchecked_eye_; + + mem_dc.DrawBitmap(*eye_ptr, {10, cur_height}); + bool reachable = IsLocationReachable(location.ap_location_id); const wxColour* text_color = reachable ? wxWHITE : wxRED; + mem_dc.SetTextForeground(*text_color); - section_labels_[section_id]->SetForegroundColour(*text_color); - eye_indicators_[section_id]->SetChecked(checked); + wxSize item_extent = mem_dc.GetTextExtent(location.name); + mem_dc.DrawText( + location.name, + {10 + 32 + 10, cur_height + (32 - mem_dc.GetFontMetrics().height) / 2}); + + cur_height += 10 + 32; } +} + +void AreaPopup::OnPaint(wxPaintEvent& event) { + wxPaintDC dc(this); + PrepareDC(dc); + dc.DrawBitmap(rendered_, 0, 0); - section_labels_[0]->GetContainingSizer()->Layout(); - GetSizer()->Fit(this); + event.Skip(); } diff --git a/src/area_popup.h b/src/area_popup.h index d5f6a50..00c644d 100644 --- a/src/area_popup.h +++ b/src/area_popup.h @@ -7,19 +7,20 @@ #include #endif -#include "eye_indicator.h" - -class AreaPopup : public wxScrolledWindow { +class AreaPopup : public wxScrolledCanvas { public: AreaPopup(wxWindow* parent, int area_id); void UpdateIndicators(); private: + void OnPaint(wxPaintEvent& event); + int area_id_; - std::vector section_labels_; - std::vector eye_indicators_; + wxBitmap unchecked_eye_; + wxBitmap checked_eye_; + wxBitmap rendered_; }; #endif /* end of include guard: AREA_POPUP_H_03FAC988 */ diff --git a/src/eye_indicator.cpp b/src/eye_indicator.cpp deleted file mode 100644 index 61ad780..0000000 --- a/src/eye_indicator.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "eye_indicator.h" - -#include "global.h" - -EyeIndicator::EyeIndicator(wxWindow* parent) : wxWindow(parent, wxID_ANY) { - SetMinSize({32, 32}); - - Redraw(); - - Bind(wxEVT_PAINT, &EyeIndicator::OnPaint, this); -} - -void EyeIndicator::SetChecked(bool checked) { - if (intended_checked_ != checked) { - intended_checked_ = checked; - - Redraw(); - } -} - -const wxImage& EyeIndicator::GetUncheckedImage() { - static wxImage* unchecked_image = new wxImage( - GetAbsolutePath("assets/unchecked.png").c_str(), wxBITMAP_TYPE_PNG); - return *unchecked_image; -} - -const wxImage& EyeIndicator::GetCheckedImage() { - static wxImage* checked_image = new wxImage( - GetAbsolutePath("assets/checked.png").c_str(), wxBITMAP_TYPE_PNG); - return *checked_image; -} - -void EyeIndicator::OnPaint(wxPaintEvent& event) { - if (GetSize() != rendered_.GetSize() || - intended_checked_ != rendered_checked_) { - Redraw(); - } - - wxPaintDC dc(this); - dc.DrawBitmap(rendered_, 0, 0); - - event.Skip(); -} - -void EyeIndicator::Redraw() { - rendered_ = - wxBitmap((intended_checked_ ? GetCheckedImage() : GetUncheckedImage()) - .Scale(GetSize().GetWidth(), GetSize().GetHeight(), - wxIMAGE_QUALITY_NORMAL)); - rendered_checked_ = intended_checked_; -} diff --git a/src/eye_indicator.h b/src/eye_indicator.h deleted file mode 100644 index e8fd890..0000000 --- a/src/eye_indicator.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef EYE_INDICATOR_H_778150F2 -#define EYE_INDICATOR_H_778150F2 - -#include - -#ifndef WX_PRECOMP -#include -#endif - -class EyeIndicator : public wxWindow { - public: - EyeIndicator(wxWindow* parent); - - void SetChecked(bool checked); - - private: - static const wxImage& GetUncheckedImage(); - static const wxImage& GetCheckedImage(); - - void OnPaint(wxPaintEvent& event); - - void Redraw(); - - bool intended_checked_ = false; - - wxBitmap rendered_; - bool rendered_checked_ = false; -}; - -#endif /* end of include guard: EYE_INDICATOR_H_778150F2 */ diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index 81cb595..3102110 100644 --- a/src/tracker_panel.cpp +++ b/src/tracker_panel.cpp @@ -35,11 +35,11 @@ TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { } void TrackerPanel::UpdateIndicators() { - Redraw(); - for (AreaIndicator &area : areas_) { area.popup->UpdateIndicators(); } + + Redraw(); } void TrackerPanel::OnPaint(wxPaintEvent &event) { @@ -178,8 +178,10 @@ void TrackerPanel::Redraw() { int popup_y = final_y + map_area.map_y * final_width / image_size.GetWidth(); - area.popup->SetMaxSize(panel_size); - area.popup->GetSizer()->Fit(area.popup); + area.popup->SetClientSize( + area.popup->GetVirtualSize().GetWidth(), + std::min(panel_size.GetHeight(), + area.popup->GetVirtualSize().GetHeight())); if (popup_x + area.popup->GetSize().GetWidth() > panel_size.GetWidth()) { popup_x = panel_size.GetWidth() - area.popup->GetSize().GetWidth(); -- cgit 1.4.1 From eafe71d801e8b5e1b7bbfc9041b5fba9522dfd72 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 19 Jan 2024 18:18:20 -0500 Subject: Bump version --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/version.h b/src/version.h index ed5efaa..ea5e748 100644 --- a/src/version.h +++ b/src/version.h @@ -35,6 +35,6 @@ std::ostream& operator<<(std::ostream& out, const Version& ver) { return out << "v" << ver.major << "." << ver.minor << "." << ver.revision; } -constexpr const Version kTrackerVersion = Version(0, 6, 2); +constexpr const Version kTrackerVersion = Version(0, 6, 3); #endif /* end of include guard: VERSION_H_C757E53C */ \ No newline at end of file -- cgit 1.4.1 From fd2f7564212cab906b701bbb384e3cafbb2601e4 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 27 Jan 2024 18:58:01 -0500 Subject: Fix area popups not shrinking --- src/area_popup.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/area_popup.cpp b/src/area_popup.cpp index 8f694bb..9c97d78 100644 --- a/src/area_popup.cpp +++ b/src/area_popup.cpp @@ -64,6 +64,7 @@ void AreaPopup::UpdateIndicators() { int item_width = col_width + 10 + 32; int full_width = std::max(header_extent.GetWidth(), item_width) + 20; + Fit(); SetVirtualSize(full_width, acc_height); rendered_ = wxBitmap(full_width, acc_height); -- cgit 1.4.1 From 4e7b8284cc8f0a9d7870f6546cd7d9a326680e95 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 27 Jan 2024 18:58:18 -0500 Subject: Bump version --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/version.h b/src/version.h index ea5e748..e9c8264 100644 --- a/src/version.h +++ b/src/version.h @@ -35,6 +35,6 @@ std::ostream& operator<<(std::ostream& out, const Version& ver) { return out << "v" << ver.major << "." << ver.minor << "." << ver.revision; } -constexpr const Version kTrackerVersion = Version(0, 6, 3); +constexpr const Version kTrackerVersion = Version(0, 6, 4); #endif /* end of include guard: VERSION_H_C757E53C */ \ No newline at end of file -- cgit 1.4.1