Skip to content

Commit

Permalink
refactor: palette window (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
phacUFPE authored Jun 18, 2024
1 parent 529a925 commit cb53448
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 185 deletions.
14 changes: 7 additions & 7 deletions source/palette_brushlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ bool BrushPalettePanel::SelectBrush(const Brush* whatBrush) {
}

if (panel->SelectBrush(whatBrush)) {
for (const auto &palettePanel : tool_bars) {
for (const auto palettePanel : tool_bars) {
palettePanel->SelectBrush(nullptr);
}
return true;
}

for (const auto &palettePanel : tool_bars) {
for (const auto palettePanel : tool_bars) {
if (palettePanel->SelectBrush(whatBrush)) {
panel->SelectBrush(nullptr);
return true;
Expand All @@ -181,7 +181,7 @@ bool BrushPalettePanel::SelectBrush(const Brush* whatBrush) {
panel = dynamic_cast<BrushPanel*>(choicebook->GetPage(pageIndex));
if (panel && panel->SelectBrush(whatBrush)) {
choicebook->ChangeSelection(pageIndex);
for (const auto &palettePanel : tool_bars) {
for (const auto palettePanel : tool_bars) {
palettePanel->SelectBrush(nullptr);
}
return true;
Expand Down Expand Up @@ -357,7 +357,7 @@ bool BrushPanel::SelectBrush(const Brush* whatBrush) {
return brushbox->SelectBrush(whatBrush);
}

for (const auto &brush : tileset->brushlist) {
for (const auto brush : tileset->brushlist) {
if (brush == whatBrush) {
LoadContents();
return brushbox->SelectBrush(whatBrush);
Expand All @@ -380,7 +380,7 @@ void BrushPanel::OnClickListBoxRow(wxCommandEvent &event) {
ASSERT(brushbox);
const auto index = event.GetSelection();

if (const auto &paletteWindow = g_gui.GetParentWindowByType<PaletteWindow*>(this); paletteWindow != nullptr) {
if (const auto paletteWindow = g_gui.GetParentWindowByType<PaletteWindow*>(this); paletteWindow != nullptr) {
g_gui.ActivatePalette(paletteWindow);
}

Expand Down Expand Up @@ -410,7 +410,7 @@ BrushIconBox::BrushIconBox(wxWindow* parent, const TilesetCategory* tileset, Ren

auto rowsizer = newd wxBoxSizer(wxHORIZONTAL);

for (const auto &brush : tileset->brushlist) {
for (const auto brush : tileset->brushlist) {
const auto brushButton = newd BrushButton(this, brush, rsz);
rowsizer->Add(brushButton);
brushButtons.emplace_back(brushButton);
Expand Down Expand Up @@ -448,7 +448,7 @@ bool BrushIconBox::SelectBrush(const Brush* whatBrush) {
return false;
}

const auto &it = std::ranges::find_if(brushButtons.begin(), brushButtons.end(), [&](const auto &brushButton) {
const auto it = std::ranges::find_if(brushButtons.begin(), brushButtons.end(), [&](const auto brushButton) {
return brushButton->brush == whatBrush;
});

Expand Down
8 changes: 4 additions & 4 deletions source/palette_brushlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class BrushBoxInterface {
class BrushListBox : public wxVListBox, public BrushBoxInterface {
public:
BrushListBox(wxWindow* parent, const TilesetCategory* tileset);
~BrushListBox() = default;
~BrushListBox() final = default;

wxWindow* GetSelfWindow() {
return this;
Expand Down Expand Up @@ -129,7 +129,7 @@ class BrushIconBox : public wxScrolledWindow, public BrushBoxInterface {
class BrushPanel : public wxPanel {
public:
BrushPanel(wxWindow* parent, const TilesetCategory* tileset);
~BrushPanel() = default;
~BrushPanel() final = default;

// Interface
// Flushes this panel and consequent views will feature reloaded data
Expand Down Expand Up @@ -171,7 +171,7 @@ class BrushPanel : public wxPanel {
class BrushPalettePanel : public PalettePanel {
public:
BrushPalettePanel(wxWindow* parent, const TilesetContainer &tilesets, TilesetCategoryType category, wxWindowID id = wxID_ANY);
~BrushPalettePanel() = default;
~BrushPalettePanel() final = default;

void AddTilesetEditor(wxSizer* sizer);

Expand All @@ -194,7 +194,7 @@ class BrushPalettePanel : public PalettePanel {
// Returns the currently selected brush (first brush if panel is not loaded)
Brush* GetSelectedBrush() const;
// Select the brush in the parameter, this only changes the look of the panel
bool SelectBrush(const Brush* whatBrush);
bool SelectBrush(const Brush* whatBrush) override;

// Called when this page is displayed
void OnSwitchIn();
Expand Down
Loading

0 comments on commit cb53448

Please sign in to comment.