[Carousel] Protection
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@ void CarouselWindow::update()
|
||||
first = max(0, first);
|
||||
coord_t lastPosition = 0;
|
||||
coord_t spacing = 10;
|
||||
if (count > 1)
|
||||
if (items.size() > 0 && count > 0)
|
||||
spacing = (width() - items[0]->back->width() * (count - 1) - items[0]->front->width()) / (count - 1);
|
||||
|
||||
int index = 0;
|
||||
|
||||
+7
-5
@@ -55,7 +55,7 @@ class CarouselWindow: public Window
|
||||
{
|
||||
}
|
||||
|
||||
void deleteLater(bool detach = true, bool trash = true) override
|
||||
void deleteLater(bool detach = true, bool trash = true) override // NOLINT(google-default-arguments)
|
||||
{
|
||||
if (_deleted)
|
||||
return;
|
||||
@@ -86,9 +86,11 @@ class CarouselWindow: public Window
|
||||
void select(int index, bool scroll = true)
|
||||
{
|
||||
selection = index;
|
||||
auto item = items[selection];
|
||||
if (item->selectHandler) {
|
||||
item->selectHandler();
|
||||
if (selection >= 0) {
|
||||
auto item = items[selection];
|
||||
if (item->selectHandler) {
|
||||
item->selectHandler();
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
@@ -96,7 +98,7 @@ class CarouselWindow: public Window
|
||||
protected:
|
||||
std::vector<CarouselItem *> items;
|
||||
int selection = 0;
|
||||
uint8_t count;
|
||||
unsigned count;
|
||||
void update();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user