Cosmetics
This commit is contained in:
+1
-1
@@ -85,7 +85,7 @@ class BaseNumberEdit : public FormField {
|
||||
_setValue = handler;
|
||||
}
|
||||
|
||||
int32_t getValue()
|
||||
int32_t getValue() const
|
||||
{
|
||||
return _getValue();
|
||||
}
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ class TransparentBitmapBackground: public TransparentBufferedWindow<Window>
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "TransparentBitmapBackground";
|
||||
}
|
||||
|
||||
+4
-4
@@ -31,12 +31,12 @@ class Button: public FormField {
|
||||
public:
|
||||
Button(FormGroup * parent, const rect_t & rect, std::function<uint8_t(void)> pressHandler = nullptr, WindowFlags windowFlags = 0):
|
||||
FormField(parent, rect, windowFlags),
|
||||
pressHandler(pressHandler)
|
||||
pressHandler(std::move(pressHandler))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "Button";
|
||||
}
|
||||
@@ -112,7 +112,7 @@ class TextButton: public Button {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "TextButton \"" + text + "\"";
|
||||
}
|
||||
@@ -141,7 +141,7 @@ class IconButton: public Button {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "IconButton(" + std::to_string(icon) + ")";
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ void CarouselWindow::update()
|
||||
setInnerWidth(lastPosition);
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void Carousel::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||
@@ -64,3 +65,4 @@ void Carousel::onEvent(event_t event)
|
||||
Window::onEvent(event);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ class Carousel: public Window {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "Carousel";
|
||||
}
|
||||
@@ -114,7 +114,7 @@ class Carousel: public Window {
|
||||
nextButton->enable(index < (int)body->items.size() - 1);
|
||||
}
|
||||
|
||||
int getSelection()
|
||||
int getSelection() const
|
||||
{
|
||||
return body->selection;
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ class CheckBox : public FormField {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "CheckBox";
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ class Choice : public ChoiceBase {
|
||||
void addItems(const char * items[], uint8_t count);
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "Choice";
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ class ColorBox: public Window {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "ColorBox";
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ class ColorEdit : public FormGroup {
|
||||
ColorEdit(FormGroup * parent, const rect_t & rect, std::function<uint16_t()> getValue, std::function<void(uint16_t)> setValue = nullptr);
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "ColorEdit";
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ class DialogWindowContent: public ModalWindowContent {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "DialogWindowContent";
|
||||
}
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ class ExpansionPanelHeader: virtual public FormGroup {
|
||||
explicit ExpansionPanelHeader(ExpansionPanel * parent);
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "ExpansionPanelHeader";
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class ExpansionPanel: public FormGroup {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "ExpansionPanel";
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ class FileChoice: public ChoiceBase {
|
||||
FileChoice(FormGroup * parent, const rect_t & rect, std::string folder, const char * extension, int maxlen, std::function<std::string()> getValue, std::function<void(std::string)> setValue);
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "FileChoice";
|
||||
}
|
||||
|
||||
+2
-2
@@ -94,7 +94,7 @@ class FormGroup: public FormField {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "FormGroup";
|
||||
}
|
||||
@@ -135,7 +135,7 @@ class FormWindow: public FormGroup {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "FormWindow";
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class NumberKeyboard : public Keyboard {
|
||||
~NumberKeyboard() override;
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "NumberKeyboard";
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ class TextKeyboard : public Keyboard {
|
||||
~TextKeyboard() override;
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "TextKeyboard";
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ class MainWindow: public Window {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "MainWindow";
|
||||
}
|
||||
|
||||
+3
-2
@@ -73,13 +73,14 @@ bool MenuBody::onTouchEnd(coord_t /*x*/, coord_t y)
|
||||
|
||||
void MenuBody::paint(BitmapBuffer * dc)
|
||||
{
|
||||
for (auto i = 0; i < (int)lines.size(); i++) {
|
||||
for (unsigned i = 0; i < lines.size(); i++) {
|
||||
auto & line = lines[i];
|
||||
LcdFlags flags = MENU_COLOR | MENU_FONT;
|
||||
if (selectedIndex == i) {
|
||||
flags = MENU_HIGHLIGHT_COLOR | MENU_FONT;
|
||||
if (MENU_HIGHLIGHT_BGCOLOR != MENU_BGCOLOR)
|
||||
if (MENU_HIGHLIGHT_BGCOLOR != MENU_BGCOLOR) {
|
||||
dc->drawSolidFilledRect(0, i * MENUS_LINE_HEIGHT, width(), MENUS_LINE_HEIGHT, MENU_HIGHLIGHT_BGCOLOR);
|
||||
}
|
||||
}
|
||||
if (line.drawLine) {
|
||||
line.drawLine(dc, 0, i * MENUS_LINE_HEIGHT /*+ (lineHeight - 20) / 2*/, flags);
|
||||
|
||||
+5
-5
@@ -66,7 +66,7 @@ class MenuBody: public Window {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "MenuBody";
|
||||
}
|
||||
@@ -74,12 +74,12 @@ class MenuBody: public Window {
|
||||
|
||||
void select(int index);
|
||||
|
||||
int selection()
|
||||
int selection() const
|
||||
{
|
||||
return selectedIndex;
|
||||
}
|
||||
|
||||
int count()
|
||||
int count() const
|
||||
{
|
||||
return lines.size();
|
||||
}
|
||||
@@ -112,7 +112,7 @@ class MenuBody: public Window {
|
||||
|
||||
void setCancelHandler(std::function<void()> handler)
|
||||
{
|
||||
onCancel = handler;
|
||||
onCancel = std::move(handler);
|
||||
}
|
||||
|
||||
void paint(BitmapBuffer * dc) override;
|
||||
@@ -139,7 +139,7 @@ class MenuWindowContent: public ModalWindowContent {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "MenuWindowContent";
|
||||
}
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ class ModalWindow: public Window
|
||||
explicit ModalWindow(Window * parent);
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "ModalWindow";
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class ModalWindowContent: public Window {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "ModalWindowContent";
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class NumberEdit : public BaseNumberEdit {
|
||||
std::function<int32_t()> getValue, std::function<void(int32_t)> setValue = nullptr, WindowFlags windowFlags = 0, LcdFlags textFlags = 0);
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "NumberEdit(" + std::to_string(getValue()) + ")";
|
||||
}
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ class Progress : public Window {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "Progress";
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class Progress : public Window {
|
||||
void paint(BitmapBuffer * dc) override;
|
||||
|
||||
protected:
|
||||
int value;
|
||||
int value = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ class Slider: public FormField {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "Slider";
|
||||
}
|
||||
|
||||
+3
-3
@@ -32,7 +32,7 @@ class StaticText: public Window {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "StaticText \"" + text + "\"";
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class Subtitle: public StaticText {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "Subtitle \"" + text + "\"";
|
||||
}
|
||||
@@ -100,7 +100,7 @@ class StaticBitmap: public Window {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "StaticBitmap";
|
||||
}
|
||||
|
||||
+3
-3
@@ -46,7 +46,7 @@ class Table: public Window {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "Table::Header";
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class Table: public Window {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "Table::Body";
|
||||
}
|
||||
@@ -134,7 +134,7 @@ class Table: public Window {
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "Table";
|
||||
}
|
||||
|
||||
+3
-3
@@ -35,7 +35,7 @@ class TextEdit : public FormField {
|
||||
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
std::string getName() const override
|
||||
{
|
||||
return "TextEdit";
|
||||
}
|
||||
@@ -46,12 +46,12 @@ class TextEdit : public FormField {
|
||||
changeHandler = handler;
|
||||
}
|
||||
|
||||
uint8_t getMaxLength()
|
||||
uint8_t getMaxLength() const
|
||||
{
|
||||
return length;
|
||||
}
|
||||
|
||||
char * getData()
|
||||
char * getData() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
+14
-6
@@ -138,7 +138,7 @@ void Window::setFocus(uint8_t flag)
|
||||
|
||||
void Window::setScrollPositionX(coord_t value)
|
||||
{
|
||||
coord_t newScrollPosition = max<coord_t>(0, min<coord_t>(innerWidth - width(), value));
|
||||
auto newScrollPosition = max<coord_t>(0, min<coord_t>(innerWidth - width(), value));
|
||||
if (newScrollPosition != scrollPositionX) {
|
||||
scrollPositionX = newScrollPosition;
|
||||
invalidate();
|
||||
@@ -147,7 +147,12 @@ void Window::setScrollPositionX(coord_t value)
|
||||
|
||||
void Window::setScrollPositionY(coord_t value)
|
||||
{
|
||||
coord_t newScrollPosition = max<coord_t>(0, min<coord_t>(innerHeight - height(), value));
|
||||
auto newScrollPosition = min<coord_t>(innerHeight - height(), value);
|
||||
|
||||
if (newScrollPosition < 0 && innerHeight != INFINITE_HEIGHT) {
|
||||
newScrollPosition = 0;
|
||||
}
|
||||
|
||||
if (newScrollPosition != scrollPositionY) {
|
||||
scrollPositionY = newScrollPosition;
|
||||
invalidate();
|
||||
@@ -192,7 +197,7 @@ void Window::scrollTo(const rect_t & rect)
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::hasOpaqueRect(const rect_t & rect)
|
||||
bool Window::hasOpaqueRect(const rect_t & rect) const
|
||||
{
|
||||
if (!this->rect.contains(rect))
|
||||
return false;
|
||||
@@ -253,12 +258,12 @@ void Window::fullPaint(BitmapBuffer * dc)
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::isChildFullSize(Window * child)
|
||||
bool Window::isChildFullSize(const Window * child) const
|
||||
{
|
||||
return child->top() == 0 && child->height() == height() && child->left() == 0 && child->width() == width();
|
||||
}
|
||||
|
||||
bool Window::isChildVisible(Window * window)
|
||||
bool Window::isChildVisible(const Window * window) const
|
||||
{
|
||||
for (auto rit = children.rbegin(); rit != children.rend(); rit++) {
|
||||
auto child = *rit;
|
||||
@@ -333,7 +338,10 @@ void Window::checkEvents()
|
||||
if (pageHeight) {
|
||||
coord_t relativeScrollPosition = scrollPositionY % pageHeight;
|
||||
if (relativeScrollPosition) {
|
||||
setScrollPositionY(getScrollPositionY() - relativeScrollPosition + (relativeScrollPosition > pageHeight / 2 ? pageHeight : 0));
|
||||
if (relativeScrollPosition > 0)
|
||||
setScrollPositionY(getScrollPositionY() - relativeScrollPosition + (relativeScrollPosition > pageHeight / 2 ? pageHeight : 0));
|
||||
else
|
||||
setScrollPositionY(getScrollPositionY() - relativeScrollPosition - (relativeScrollPosition > -pageHeight / 2 ? 0 : pageHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-10
@@ -39,6 +39,8 @@ typedef uint32_t WindowFlags;
|
||||
#undef TRANSPARENT
|
||||
#endif
|
||||
|
||||
constexpr int INFINITE_HEIGHT = INT32_MAX;
|
||||
|
||||
constexpr WindowFlags OPAQUE = 1u << 0u;
|
||||
constexpr WindowFlags TRANSPARENT = 1u << 1u;
|
||||
constexpr WindowFlags NO_SCROLLBAR = 1u << 2u;
|
||||
@@ -65,19 +67,19 @@ class Window {
|
||||
virtual ~Window();
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
virtual std::string getName()
|
||||
virtual std::string getName() const
|
||||
{
|
||||
return "Window";
|
||||
}
|
||||
|
||||
std::string getRectString()
|
||||
std::string getRectString() const
|
||||
{
|
||||
char result[32];
|
||||
sprintf(result, "[%d, %d, %d, %d]", left(), top(), width(), height());
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string getIndentString()
|
||||
std::string getIndentString() const
|
||||
{
|
||||
std::string result;
|
||||
auto tmp = parent;
|
||||
@@ -88,7 +90,7 @@ class Window {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string getWindowDebugString(const char * name = nullptr)
|
||||
std::string getWindowDebugString(const char * name = nullptr) const
|
||||
{
|
||||
return getName() + (name ? std::string(" [") + name + "] " : " ") + getRectString();
|
||||
}
|
||||
@@ -252,7 +254,7 @@ class Window {
|
||||
pageHeight = h;
|
||||
}
|
||||
|
||||
uint8_t getPageCount()
|
||||
uint8_t getPageCount() const
|
||||
{
|
||||
if (pageWidth)
|
||||
return innerWidth / pageWidth;
|
||||
@@ -262,7 +264,7 @@ class Window {
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t getPageIndex()
|
||||
uint8_t getPageIndex() const
|
||||
{
|
||||
if (pageWidth)
|
||||
return (getScrollPositionX() + (pageWidth / 2)) / pageWidth;
|
||||
@@ -305,11 +307,11 @@ class Window {
|
||||
|
||||
void setScrollPositionY(coord_t value);
|
||||
|
||||
bool isChildVisible(Window * window);
|
||||
bool isChildVisible(const Window * window) const;
|
||||
|
||||
bool isChildFullSize(Window * window);
|
||||
bool isChildFullSize(const Window * window) const;
|
||||
|
||||
bool isVisible()
|
||||
bool isVisible() const
|
||||
{
|
||||
return parent && parent->isChildVisible(this);
|
||||
}
|
||||
@@ -400,7 +402,7 @@ class Window {
|
||||
|
||||
bool forwardTouchEnd(coord_t x, coord_t y);
|
||||
|
||||
bool hasOpaqueRect(const rect_t & rect);
|
||||
bool hasOpaqueRect(const rect_t & rect) const;
|
||||
};
|
||||
|
||||
#endif // _WINDOW_H_
|
||||
|
||||
Reference in New Issue
Block a user