ModalWindow layer added
This commit is contained in:
+1
-25
@@ -108,10 +108,7 @@ void MenuWindow::paint(BitmapBuffer * dc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Menu::Menu():
|
Menu::Menu():
|
||||||
Window(&mainWindow, {0, 0, LCD_W, LCD_H}),
|
ModalWindow(),
|
||||||
#if !defined(HARDWARE_TOUCH)
|
|
||||||
previousFocus(focusWindow),
|
|
||||||
#endif
|
|
||||||
menuWindow(createMenuWindow(this))
|
menuWindow(createMenuWindow(this))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -154,11 +151,6 @@ void Menu::removeLines()
|
|||||||
updatePosition();
|
updatePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::paint(BitmapBuffer * dc)
|
|
||||||
{
|
|
||||||
dc->drawFilledRect(0, 0, width(), height(), SOLID, OVERLAY_COLOR | OPACITY(5));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void Menu::onEvent(event_t event)
|
void Menu::onEvent(event_t event)
|
||||||
{
|
{
|
||||||
@@ -170,19 +162,3 @@ void Menu::onEvent(event_t event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
|
||||||
bool Menu::onTouchEnd(coord_t x, coord_t y)
|
|
||||||
{
|
|
||||||
if (!Window::onTouchEnd(x, y)) {
|
|
||||||
deleteLater();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Menu::onTouchSlide(coord_t x, coord_t y, coord_t startX, coord_t startY, coord_t slideX, coord_t slideY)
|
|
||||||
{
|
|
||||||
Window::onTouchSlide(x, y, startX, startY, slideX, slideY);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|||||||
+2
-26
@@ -23,7 +23,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "mainwindow.h"
|
#include "modal_window.h"
|
||||||
|
|
||||||
class Menu;
|
class Menu;
|
||||||
class MenuWindow;
|
class MenuWindow;
|
||||||
@@ -140,7 +140,7 @@ class MenuWindow: public Window {
|
|||||||
std::string title;
|
std::string title;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Menu: public Window {
|
class Menu: public ModalWindow {
|
||||||
public:
|
public:
|
||||||
Menu();
|
Menu();
|
||||||
|
|
||||||
@@ -149,16 +149,6 @@ class Menu: public Window {
|
|||||||
menuWindow->body.setCancelHandler(handler);
|
menuWindow->body.setCancelHandler(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteLater()
|
|
||||||
{
|
|
||||||
#if !defined(HARDWARE_TOUCH)
|
|
||||||
if (previousFocus) {
|
|
||||||
previousFocus->setFocus();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Window::deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() override
|
std::string getName() override
|
||||||
{
|
{
|
||||||
@@ -187,25 +177,11 @@ class Menu: public Window {
|
|||||||
menuWindow->body.select(index);
|
menuWindow->body.select(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint(BitmapBuffer * dc) override;
|
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
|
||||||
bool onTouchStart(coord_t x, coord_t y) override
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Window * previousFocus = nullptr;
|
|
||||||
MenuWindow * menuWindow;
|
MenuWindow * menuWindow;
|
||||||
Window * toolbar = nullptr;
|
Window * toolbar = nullptr;
|
||||||
void updatePosition();
|
void updatePosition();
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) OpenTX
|
||||||
|
*
|
||||||
|
* Source:
|
||||||
|
* https://github.com/opentx/libopenui
|
||||||
|
*
|
||||||
|
* This file is a part of libopenui library.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MODAL_WINDOW_H_
|
||||||
|
#define _MODAL_WINDOW_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <functional>
|
||||||
|
#include <utility>
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
class ModalWindow: public Window
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ModalWindow():
|
||||||
|
Window(&mainWindow, {0, 0, LCD_W, LCD_H})
|
||||||
|
#if !defined(HARDWARE_TOUCH)
|
||||||
|
, previousFocus(focusWindow)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(DEBUG_WINDOWS)
|
||||||
|
std::string getName() override
|
||||||
|
{
|
||||||
|
return "ModalWindow";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void deleteLater()
|
||||||
|
{
|
||||||
|
#if !defined(HARDWARE_TOUCH)
|
||||||
|
if (previousFocus) {
|
||||||
|
previousFocus->setFocus();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
Window::deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void paint(BitmapBuffer * dc) override
|
||||||
|
{
|
||||||
|
dc->drawFilledRect(0, 0, width(), height(), SOLID, OVERLAY_COLOR | OPACITY(5));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
bool onTouchStart(coord_t x, coord_t y) override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool onTouchEnd(coord_t x, coord_t y)
|
||||||
|
{
|
||||||
|
if (!Window::onTouchEnd(x, y)) {
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool onTouchSlide(coord_t x, coord_t y, coord_t startX, coord_t startY, coord_t slideX, coord_t slideY)
|
||||||
|
{
|
||||||
|
Window::onTouchSlide(x, y, startX, startY, slideX, slideY);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Window * previousFocus = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _MODAL_WINDOW_H_
|
||||||
Reference in New Issue
Block a user