New Theme API
NumPad
UI7 Color Selector
Color 2 Hex
UI7 New Draw API (DrawCmd)
UI7 New Debug API (DrawCmd)
Add ThemeEditor Base
This commit is contained in:
2024-06-05 12:32:51 +02:00
parent cbfb0b128c
commit 0626231b45
17 changed files with 756 additions and 349 deletions

View File

@ -28,7 +28,7 @@
#define UNPACK_BGRA(col) (uint8_t)(col >> 8), (col >> 16), (col >> 24), (col)
inline uint32_t RGBA8(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) {
#define ISIMPLEPAK(x, y) (((x)&0xff) << y)
#define ISIMPLEPAK(x, y) (((x) & 0xff) << y)
return (ISIMPLEPAK(r, 0) | ISIMPLEPAK(g, 8) | ISIMPLEPAK(b, 16) |
ISIMPLEPAK(a, 24));
}
@ -86,13 +86,17 @@ class Theme {
void Load(const std::string &path);
void Default();
void Save(const std::string &path);
unsigned int Get(RD7Color clr);
void Set(RD7Color clr, unsigned int v);
void Swap(RD7Color a, RD7Color b);
bool Undo();
void UndoAll();
void TextBy(RD7Color bg);
RD7Color AutoText(RD7Color bg);
std::vector<unsigned int> &GetTableRef() { return clr_tab; }
// For Smart Pointer
using Ref = std::shared_ptr<Theme>;
static Ref New() { return std::make_shared<Theme>(); }
@ -113,20 +117,9 @@ class Theme {
std::vector<change> changes;
};
unsigned int StyleColor(RD7Color color);
void RedirectColor(RD7Color to, RD7Color from);
void TextColorByBg(RD7Color background);
/// @brief Customices a color until undone
/// For example with RebderD7::Color::Hex
void CustomizeColor(RD7Color color, unsigned int custom);
/// @brief Completly changes a theme color
void ColorNew(RD7Color color, unsigned int new_color);
void UndoColorEdit(RD7Color color);
void UndoAllColorEdits();
void ThemeLoad(const std::string &path);
void ThemeSave(const std::string &path);
void ThemeDefault();
Theme::Ref ThemeActive();
/// @brief Change Theme Adress
/// @param theme your adress
void ThemeSet(Theme::Ref theme);
namespace Color {
/// @brief RGBA Class
@ -154,7 +147,8 @@ class RGBA {
m_a = ISIMPLEUNPAK(in, 24);
}
RGBA(RD7Color in) {
unsigned int col = RenderD7::StyleColor(in);
if (!RenderD7::ThemeActive()) return;
unsigned int col = RenderD7::ThemeActive()->Get(in);
m_r = ISIMPLEUNPAK(col, 0);
m_g = ISIMPLEUNPAK(col, 8);
m_b = ISIMPLEUNPAK(col, 16);
@ -207,6 +201,7 @@ class RGBA {
uint8_t m_r, m_g, m_b, m_a;
};
std::string RGBA2Hex(unsigned int c32);
/// @brief Convert RGB to Hex
/// @param r
/// @param g

View File

@ -68,6 +68,8 @@ void TriangleSolid(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color);
void TriangleLined(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color,
int t = 1);
void Text(R7Vec2 pos, const std::string& text, RD7TextFlags flags = 0);
void TextClr(R7Vec2 pos, const std::string& text, unsigned int color,
RD7TextFlags flags = 0);
void Image(RenderD7::Image* img, const R7Vec2& pos = R7Vec2(0, 0),
const R7Vec2& scale = R7Vec2(1, 1));
} // namespace Draw2

View File

@ -50,6 +50,7 @@ void RegKeyEvent(const std::string &event, uint32_t key);
bool IsEvent(const std::string &event, Actions action);
R7Vec2 GetTouchPosition();
R7Vec2 GetLastTouchPosition();
R7Vec2 GetTouchDownPosition();
void Update();
// Lock/Unlock Input api for example for Keyboard
void Lock();

View File

@ -95,6 +95,7 @@ class Ovl_Keyboard : public RenderD7::Ovl {
std::string* typed_text = nullptr;
std::string str_bak;
RD7KeyboardState* state;
RD7Keyboard type;
int mode = 0;
int ft3 = 0;
};

View File

@ -1,3 +1,21 @@
/**
* This file is part of RenderD7
* Copyright (C) 2021-2024 NPI-D7, tobid7
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <renderd7/renderd7.hpp>
@ -5,12 +23,20 @@
namespace RenderD7 {
class ThemeEditor : public RenderD7::Scene {
public:
ThemeEditor() = default;
~ThemeEditor() = default;
ThemeEditor();
~ThemeEditor();
void Draw() const override;
void Draw(void) const override;
void Logic() override;
private:
Theme::Ref edit_theme;
// Placeholder to save active one to
Theme::Ref temp_theme;
// temp vars for samples
mutable bool cm;
mutable std::string inpt;
mutable int menu = 0;
};
} // namespace RenderD7

View File

@ -65,6 +65,7 @@ void EndMenu();
void Grid(const std::string &name, const R7Vec2 &size, const R7Vec2 &entry_size,
void (*display_func)(void *, R7Vec2), void **data_array,
size_t num_entrys);
void ColorSelector(const std::string &label, unsigned int &color);
bool BeginTree(const std::string &text);
void EndTree();
R7Vec2 GetCursorPos();

View File

@ -76,6 +76,7 @@ extern bool rd7i_graphics_on;
extern bool rd7i_amdt;
extern void* rd7i_soc_buf;
extern bool rd7i_is_am_init;
extern RenderD7::Theme::Ref rd7i_active_theme;
RenderD7::Net::Error rd7i_soc_init();
void rd7i_soc_deinit();

View File

@ -138,6 +138,8 @@ class RSettings : public RenderD7::Scene {
/// @brief Show Up the RenderD7-Settings Menu
void LoadSettings();
/// @brief Show Up The Theme Editor
void LoadThemeEditor();
/// @brief Get's The Programs Time running
/// @return Time Running
float GetTime();