Allow ModalWindows not to be closed when touching outside
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ class ChoiceBase : public FormField
|
|||||||
ChoiceType type;
|
ChoiceType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Choice : public ChoiceBase {
|
class Choice: public ChoiceBase {
|
||||||
public:
|
public:
|
||||||
Choice(FormGroup * parent, const rect_t & rect, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = 0);
|
Choice(FormGroup * parent, const rect_t & rect, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = 0);
|
||||||
Choice(FormGroup * parent, const rect_t & rect, std::vector<std::string> values, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = 0);
|
Choice(FormGroup * parent, const rect_t & rect, std::vector<std::string> values, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = 0);
|
||||||
|
|||||||
+1
-1
@@ -154,7 +154,7 @@ void MenuWindowContent::paint(BitmapBuffer * dc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Menu::Menu(Window * parent, bool multiple):
|
Menu::Menu(Window * parent, bool multiple):
|
||||||
ModalWindow(parent),
|
ModalWindow(parent, true),
|
||||||
content(createMenuWindow(this)),
|
content(createMenuWindow(this)),
|
||||||
multiple(multiple)
|
multiple(multiple)
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -27,13 +27,13 @@
|
|||||||
class Menu;
|
class Menu;
|
||||||
class MenuWindowContent;
|
class MenuWindowContent;
|
||||||
|
|
||||||
class MenuBody : public Window
|
class MenuBody: public Window
|
||||||
{
|
{
|
||||||
friend class MenuWindowContent;
|
friend class MenuWindowContent;
|
||||||
friend class Menu;
|
friend class Menu;
|
||||||
|
|
||||||
class MenuLine {
|
class MenuLine {
|
||||||
friend class MenuBody;
|
friend class MenuBody;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuLine(std::string text, std::function<void()> onPress, std::function<bool()> isChecked):
|
MenuLine(std::string text, std::function<void()> onPress, std::function<bool()> isChecked):
|
||||||
|
|||||||
+3
-2
@@ -22,8 +22,9 @@
|
|||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "layer.h"
|
#include "layer.h"
|
||||||
|
|
||||||
ModalWindow::ModalWindow(Window * parent):
|
ModalWindow::ModalWindow(Window * parent, bool closeWhenClickOutside):
|
||||||
Window(parent->getFullScreenWindow(), {0, 0, LCD_W, LCD_H})
|
Window(parent->getFullScreenWindow(), {0, 0, LCD_W, LCD_H}),
|
||||||
|
closeWhenClickOutside(closeWhenClickOutside)
|
||||||
{
|
{
|
||||||
Layer::push(this);
|
Layer::push(this);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -24,7 +24,7 @@
|
|||||||
class ModalWindow: public Window
|
class ModalWindow: public Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ModalWindow(Window * parent);
|
explicit ModalWindow(Window * parent, bool closeWhenClickOutside = false);
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() const override
|
std::string getName() const override
|
||||||
@@ -45,7 +45,7 @@ class ModalWindow: public Window
|
|||||||
|
|
||||||
bool onTouchEnd(coord_t x, coord_t y) override
|
bool onTouchEnd(coord_t x, coord_t y) override
|
||||||
{
|
{
|
||||||
if (!Window::onTouchEnd(x, y) && closeAllowed) {
|
if (!Window::onTouchEnd(x, y) && closeWhenClickOutside) {
|
||||||
onKeyPress();
|
onKeyPress();
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
@@ -59,13 +59,13 @@ class ModalWindow: public Window
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setCloseAllowed(bool value = true)
|
void setCloseWhenClickOutside(bool value = true)
|
||||||
{
|
{
|
||||||
closeAllowed = value;
|
closeWhenClickOutside = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool closeAllowed = true;
|
bool closeWhenClickOutside;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ModalWindowContent: public Window
|
class ModalWindowContent: public Window
|
||||||
|
|||||||
Reference in New Issue
Block a user