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