Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul committed Nov 24, 2024
1 parent 7c21cad commit ed31e3a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
10 changes: 6 additions & 4 deletions examples/component-demo/ListViewDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ struct ListViewDemo : public sst::jucegui::components::WindowPanel
}
void mouseDown(const juce::MouseEvent &e) override
{
parent->listView->rowSelected(row, !selected,
parent->listView->rowSelected(
row, !selected,
sst::jucegui::components::ListView::selectionAddActionForModifier(e.mods));
}
};
Expand Down Expand Up @@ -98,9 +99,10 @@ struct ListViewDemo : public sst::jucegui::components::WindowPanel
for (int i = 5; i < 7; ++i)
{
auto tb = std::make_unique<sst::jucegui::components::TextPushButton>();
auto amt = (i == 5 ? sst::jucegui::components::ListView::SelectionMode::SINGLE_SELECTION :
sst::jucegui::components::ListView::SelectionMode::MULTI_SELECTION);
tb->setLabel(i== 5 ? "SingSel" : "MultSel");
auto amt =
(i == 5 ? sst::jucegui::components::ListView::SelectionMode::SINGLE_SELECTION
: sst::jucegui::components::ListView::SelectionMode::MULTI_SELECTION);
tb->setLabel(i == 5 ? "SingSel" : "MultSel");
tb->setOnCallback([amt, w = juce::Component::SafePointer(this)]() {
if (!w)
return;
Expand Down
6 changes: 2 additions & 4 deletions include/sst/jucegui/components/ListView.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,15 @@ struct ListView : public juce::Component,
ADD_NON_CONTIGUOUS,
ADD_CONTIGUOUS
};
void rowSelected(uint32_t r, bool select,
SelectionAddAction addMode = SINGLE);
void rowSelected(uint32_t r, bool select, SelectionAddAction addMode = SINGLE);
static SelectionAddAction selectionAddActionForModifier(const juce::ModifierKeys &);

std::function<uint32_t()> getRowCount{nullptr};
std::function<uint32_t()> getRowHeight{nullptr};
std::function<std::unique_ptr<juce::Component>()> makeRowComponent{nullptr};
std::function<void(const std::unique_ptr<juce::Component> &, uint32_t)> assignComponentToRow{
nullptr};
std::function<void(const std::unique_ptr<juce::Component> &, bool)> setRowSelection{
nullptr};
std::function<void(const std::unique_ptr<juce::Component> &, bool)> setRowSelection{nullptr};

std::unique_ptr<Viewport> viewPort;

Expand Down
7 changes: 2 additions & 5 deletions src/sst/jucegui/components/ListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ void ListView::refresh()
repaint();
}

void ListView::rowSelected(uint32_t r, bool b,
SelectionAddAction addMode)
void ListView::rowSelected(uint32_t r, bool b, SelectionAddAction addMode)
{
if (selectionMode == SINGLE_SELECTION ||
(selectionMode == MULTI_SELECTION && addMode == SINGLE))
Expand Down Expand Up @@ -156,7 +155,7 @@ void ListView::rowSelected(uint32_t r, bool b,
it++;
}
}
for (int i=start; i <= end; ++i)
for (int i = start; i <= end; ++i)
{
if (innards->selectedRows.find(i) == innards->selectedRows.end())
{
Expand All @@ -178,7 +177,6 @@ void ListView::rowSelected(uint32_t r, bool b,
innards->selectedRows.erase(r);
}
}

}

void ListView::setSelectionMode(SelectionMode s)
Expand All @@ -201,5 +199,4 @@ ListView::SelectionAddAction ListView::selectionAddActionForModifier(const juce:
return SINGLE;
}


} // namespace sst::jucegui::components

0 comments on commit ed31e3a

Please sign in to comment.