FabIconButton splitted from Button

This commit is contained in:
Bertrand Songis
2019-10-03 23:03:52 +02:00
parent 19a164f873
commit 0199a7d6d5
6 changed files with 6802 additions and 44 deletions
+1
View File
@@ -5,6 +5,7 @@ set(LIBOPENUI_SRC
window.cpp
form.cpp
button.cpp
fab_icon_button.cpp
static.cpp
checkbox.cpp
slider.cpp
-27
View File
@@ -109,30 +109,3 @@ void IconButton::paint(BitmapBuffer * dc)
{
dc->drawBitmap(0, 0, theme->getIcon(icon, checked() ? STATE_PRESSED : STATE_DEFAULT));
}
const uint8_t __alpha_button_on[] {
#include "alpha_button_on.lbm"
};
Bitmap ALPHA_BUTTON_ON(BMP_ARGB4444, (const uint16_t*)__alpha_button_on);
const uint8_t __alpha_button_off[] {
#include "alpha_button_off.lbm"
};
Bitmap ALPHA_BUTTON_OFF(BMP_ARGB4444, (const uint16_t*)__alpha_button_off);
FabIconButton::FabIconButton(Window * parent, coord_t x, coord_t y, uint8_t icon, std::function<uint8_t(void)> pressHandler, uint8_t flags):
Button(parent, { x - 34, y - 34, 68, 68 }, pressHandler, flags),
icon(icon)
{
}
void FabIconButton::paint(BitmapBuffer * dc)
{
dc->drawBitmap(0, 0, checked() ? &ALPHA_BUTTON_ON : &ALPHA_BUTTON_OFF);
const BitmapBuffer * mask = theme->getIconMask(icon);
if (mask) {
dc->drawMask((68 - mask->getWidth()) / 2, (68 - mask->getHeight()) / 2, mask, TEXT_BGCOLOR);
}
}
-17
View File
@@ -160,21 +160,4 @@ class IconButton: public Button {
uint8_t icon;
};
class FabIconButton: public Button {
public:
FabIconButton(Window * parent, coord_t x, coord_t y, uint8_t icon, std::function<uint8_t(void)> pressHandler, uint8_t flags=0);
#if defined(DEBUG_WINDOWS)
std::string getName() override
{
return "FabIconButton(" + std::to_string(icon) + ")";
}
#endif
void paint(BitmapBuffer * dc) override;
protected:
uint8_t icon;
};
#endif
+49
View File
@@ -0,0 +1,49 @@
/*
* 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.
*/
#include "libopenui_config.h"
#include "fab_icon_button.h"
#include "font.h"
#include "theme.h"
const uint8_t __alpha_button_on[] {
#include "alpha_button_on.lbm"
};
Bitmap ALPHA_BUTTON_ON(BMP_ARGB4444, (const uint16_t*)__alpha_button_on);
const uint8_t __alpha_button_off[] {
#include "alpha_button_off.lbm"
};
Bitmap ALPHA_BUTTON_OFF(BMP_ARGB4444, (const uint16_t*)__alpha_button_off);
FabIconButton::FabIconButton(Window * parent, coord_t x, coord_t y, uint8_t icon, std::function<uint8_t(void)> pressHandler, uint8_t flags):
Button(parent, { x - 34, y - 34, 68, 68 }, pressHandler, flags),
icon(icon)
{
}
void FabIconButton::paint(BitmapBuffer * dc)
{
dc->drawBitmap(0, 0, checked() ? &ALPHA_BUTTON_ON : &ALPHA_BUTTON_OFF);
const BitmapBuffer * mask = theme->getIconMask(icon);
if (mask) {
dc->drawMask((68 - mask->getWidth()) / 2, (68 - mask->getHeight()) / 2, mask, TEXT_BGCOLOR);
}
}
+42
View File
@@ -0,0 +1,42 @@
/*
* 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 _FAB_ICON_BUTTON_H_
#define _FAB_ICON_BUTTON_H_
#include "button.h"
class FabIconButton: public Button {
public:
FabIconButton(Window * parent, coord_t x, coord_t y, uint8_t icon, std::function<uint8_t(void)> pressHandler, uint8_t flags=0);
#if defined(DEBUG_WINDOWS)
std::string getName() override
{
return "FabIconButton(" + std::to_string(icon) + ")";
}
#endif
void paint(BitmapBuffer * dc) override;
protected:
uint8_t icon;
};
#endif
File diff suppressed because it is too large Load Diff