Fix sliding on inactive part of tab bar grabbing input focus (#1180)
* fix #298, keys not working, after sliding on tabs bar * fix for touch end event with start x,y coordinate is triggered after the last slide event * remove selecting tabs on the tab top bar by sliding as it does break sliding the tab bar.
This commit is contained in:
@@ -71,16 +71,39 @@ void TabsCarousel::paint(BitmapBuffer * dc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
bool TabsCarousel::onTouchStart(coord_t x, coord_t y)
|
||||||
|
{
|
||||||
|
if(sliding)
|
||||||
|
sliding = false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool TabsCarousel::onTouchEnd(coord_t x, coord_t y)
|
bool TabsCarousel::onTouchEnd(coord_t x, coord_t y)
|
||||||
{
|
{
|
||||||
|
if(sliding)
|
||||||
|
return true;
|
||||||
|
|
||||||
unsigned index = (x - padding_left) / MENU_HEADER_BUTTON_WIDTH;
|
unsigned index = (x - padding_left) / MENU_HEADER_BUTTON_WIDTH;
|
||||||
|
|
||||||
if (index >= menu->tabs.size()) {
|
if (index >= menu->tabs.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
menu->setCurrentTab(index);
|
menu->setCurrentTab(index);
|
||||||
setCurrentIndex(index);
|
setCurrentIndex(index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TabsCarousel::onTouchSlide(coord_t x, coord_t y, coord_t startX, coord_t startY, coord_t slideX, coord_t slideY)
|
||||||
|
{
|
||||||
|
sliding = true;
|
||||||
|
|
||||||
|
Window::onTouchSlide(x,y,startX,startY,slideX,slideY);
|
||||||
|
menu->setCurrentTab(currentIndex);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TabsGroup::TabsGroup(uint8_t icon):
|
TabsGroup::TabsGroup(uint8_t icon):
|
||||||
|
|||||||
@@ -102,13 +102,18 @@ class TabsCarousel: public Window {
|
|||||||
void paint(BitmapBuffer * dc) override;
|
void paint(BitmapBuffer * dc) override;
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
bool onTouchStart(coord_t x, coord_t y) override;
|
||||||
bool onTouchEnd(coord_t x, coord_t y) override;
|
bool onTouchEnd(coord_t x, coord_t y) override;
|
||||||
|
bool onTouchSlide(coord_t x, coord_t y, coord_t startX, coord_t startY, coord_t slideX, coord_t slideY) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
constexpr static uint8_t padding_left = 3;
|
constexpr static uint8_t padding_left = 3;
|
||||||
TabsGroup * menu;
|
TabsGroup * menu;
|
||||||
uint8_t currentIndex = 0;
|
uint8_t currentIndex = 0;
|
||||||
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
bool sliding = false;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class TabsGroupHeader: public FormGroup {
|
class TabsGroupHeader: public FormGroup {
|
||||||
|
|||||||
Reference in New Issue
Block a user