chore(color): more layout cleanup and minor bug fixes (#5171)

This commit is contained in:
philmoz
2024-06-17 05:40:08 +00:00
committed by GitHub
parent 66c0a2769f
commit e7509349b3
69 changed files with 806 additions and 1110 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
#include "button.h"
#include "theme.h"
#include "static.h"
#include "themes/etx_lv_theme.h"
static void button_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
-1
View File
@@ -19,7 +19,6 @@
#include "choice.h"
#include "menu.h"
#include "theme.h"
#include "themes/etx_lv_theme.h"
// Choice
+1 -1
View File
@@ -18,9 +18,9 @@
#include "dialog.h"
#include "opentx.h"
#include "mainwindow.h"
#include "progress.h"
#include "theme.h"
#include "themes/etx_lv_theme.h"
//-----------------------------------------------------------------------------
+1 -1
View File
@@ -20,10 +20,10 @@
#include <algorithm>
#include "opentx.h"
#include "libopenui_file.h"
#include "menu.h"
#include "menutoolbar.h"
#include "theme.h"
class FileChoiceMenuToolbar : public MenuToolbar
{
+26 -6
View File
@@ -22,6 +22,7 @@
#include "keyboard_base.h"
#include "layout.h"
#include "themes/etx_lv_theme.h"
#include "sdcard.h"
// timers_driver.h
uint32_t timersGetMsTick();
@@ -76,12 +77,6 @@ void MainWindow::run(bool trash)
}
}
void MainWindow::setBackground(const BitmapBuffer* bitmap)
{
lv_canvas_set_buffer(background, bitmap->getData(), bitmap->width(),
bitmap->height(), LV_IMG_CF_TRUE_COLOR);
}
void MainWindow::shutdown()
{
// Called when USB is connected in SD card mode
@@ -100,3 +95,28 @@ void MainWindow::shutdown()
background = lv_canvas_create(lvobj);
lv_obj_center(background);
}
void MainWindow::setBackgroundImage(const char* fileName)
{
// ensure you delete old bitmap
if (backgroundBitmap != nullptr) delete backgroundBitmap;
if (fileName == nullptr) fileName = "";
backgroundImageFileName = fileName;
// Try to load bitmap. If this fails backgroundBitmap will be NULL and default
// will be loaded in update() method
backgroundBitmap =
BitmapBuffer::loadBitmap(backgroundImageFileName.c_str(), BMP_RGB565);
if (!backgroundBitmap) {
backgroundBitmap = BitmapBuffer::loadBitmap(
THEMES_PATH "/EdgeTX/background.png", BMP_RGB565);
}
if (backgroundBitmap) {
lv_canvas_set_buffer(background, backgroundBitmap->getData(), backgroundBitmap->width(),
backgroundBitmap->height(), LV_IMG_CF_TRUE_COLOR);
}
}
+25 -23
View File
@@ -23,40 +23,42 @@
class MainWindow: public Window
{
protected:
// singleton
MainWindow();
protected:
// singleton
MainWindow();
public:
static MainWindow * instance();
public:
static MainWindow * instance();
#if defined(TESTS)
static void create()
{
_instance = new MainWindow();
}
static void create()
{
_instance = new MainWindow();
}
#endif
#if defined(DEBUG_WINDOWS)
std::string getName() const override
{
return "MainWindow";
}
std::string getName() const override
{
return "MainWindow";
}
#endif
void setActiveScreen() {
lv_scr_load(lvobj);
}
void setActiveScreen() {
lv_scr_load(lvobj);
}
void run(bool trash=true);
void run(bool trash=true);
void setBackground(const BitmapBuffer* bitmap);
void setBackgroundImage(const char* fileName);
void shutdown();
void shutdown();
protected:
lv_obj_t* background = nullptr;
protected:
lv_obj_t* background = nullptr;
std::string backgroundImageFileName;
const BitmapBuffer *backgroundBitmap = nullptr;
static MainWindow * _instance;
static void emptyTrash();
static MainWindow * _instance;
static void emptyTrash();
};
+1 -1
View File
@@ -21,8 +21,8 @@
#include <lvgl/lvgl.h>
#include "menutoolbar.h"
#include "opentx.h"
#include "table.h"
#include "theme.h"
#include "themes/etx_lv_theme.h"
#include <memory>
+1 -1
View File
@@ -18,7 +18,7 @@
#include "slider.h"
#include "theme.h"
#include "form.h"
#include "themes/etx_lv_theme.h"
// Slider
-1
View File
@@ -18,7 +18,6 @@
#include "toggleswitch.h"
#include "theme.h"
#include "themes/etx_lv_theme.h"
// Animation
+2 -2
View File
@@ -509,7 +509,7 @@ SetupLine::SetupLine(Window* parent, coord_t y, coord_t col2, PaddingSize paddin
Window(parent, {0, y, LCD_W - padding * 2, 0})
{
padAll(PAD_ZERO);
coord_t titleY = PAD_MEDIUM + 1 + lblYOffset;
coord_t titleY = PAD_LARGE + lblYOffset;
coord_t titleH = EdgeTxStyles::PAGE_LINE_HEIGHT;
coord_t h = EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_TINY * 2 + lblYOffset * 2;
if (createEdit) {
@@ -519,7 +519,7 @@ SetupLine::SetupLine(Window* parent, coord_t y, coord_t col2, PaddingSize paddin
if (getTextWidth(title) >= lblWidth) {
h += PAD_MEDIUM;
titleY = 0;
titleH = EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_TINY + 1;
titleH = EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_TINY + PAD_LARGE;
editY = PAD_SMALL + 1;
}
new StaticText(this, {PAD_TINY, titleY, lblWidth, titleH}, title);