Changes:
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:
parent
cbfb0b128c
commit
0626231b45
@ -28,7 +28,7 @@
|
|||||||
#define UNPACK_BGRA(col) (uint8_t)(col >> 8), (col >> 16), (col >> 24), (col)
|
#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) {
|
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) |
|
return (ISIMPLEPAK(r, 0) | ISIMPLEPAK(g, 8) | ISIMPLEPAK(b, 16) |
|
||||||
ISIMPLEPAK(a, 24));
|
ISIMPLEPAK(a, 24));
|
||||||
}
|
}
|
||||||
@ -86,13 +86,17 @@ class Theme {
|
|||||||
|
|
||||||
void Load(const std::string &path);
|
void Load(const std::string &path);
|
||||||
void Default();
|
void Default();
|
||||||
|
void Save(const std::string &path);
|
||||||
|
|
||||||
unsigned int Get(RD7Color clr);
|
unsigned int Get(RD7Color clr);
|
||||||
void Set(RD7Color clr, unsigned int v);
|
void Set(RD7Color clr, unsigned int v);
|
||||||
void Swap(RD7Color a, RD7Color b);
|
void Swap(RD7Color a, RD7Color b);
|
||||||
bool Undo();
|
bool Undo();
|
||||||
void UndoAll();
|
void UndoAll();
|
||||||
|
void TextBy(RD7Color bg);
|
||||||
|
RD7Color AutoText(RD7Color bg);
|
||||||
|
|
||||||
|
std::vector<unsigned int> &GetTableRef() { return clr_tab; }
|
||||||
// For Smart Pointer
|
// For Smart Pointer
|
||||||
using Ref = std::shared_ptr<Theme>;
|
using Ref = std::shared_ptr<Theme>;
|
||||||
static Ref New() { return std::make_shared<Theme>(); }
|
static Ref New() { return std::make_shared<Theme>(); }
|
||||||
@ -113,20 +117,9 @@ class Theme {
|
|||||||
std::vector<change> changes;
|
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();
|
Theme::Ref ThemeActive();
|
||||||
|
/// @brief Change Theme Adress
|
||||||
|
/// @param theme your adress
|
||||||
void ThemeSet(Theme::Ref theme);
|
void ThemeSet(Theme::Ref theme);
|
||||||
namespace Color {
|
namespace Color {
|
||||||
/// @brief RGBA Class
|
/// @brief RGBA Class
|
||||||
@ -154,7 +147,8 @@ class RGBA {
|
|||||||
m_a = ISIMPLEUNPAK(in, 24);
|
m_a = ISIMPLEUNPAK(in, 24);
|
||||||
}
|
}
|
||||||
RGBA(RD7Color in) {
|
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_r = ISIMPLEUNPAK(col, 0);
|
||||||
m_g = ISIMPLEUNPAK(col, 8);
|
m_g = ISIMPLEUNPAK(col, 8);
|
||||||
m_b = ISIMPLEUNPAK(col, 16);
|
m_b = ISIMPLEUNPAK(col, 16);
|
||||||
@ -207,6 +201,7 @@ class RGBA {
|
|||||||
|
|
||||||
uint8_t m_r, m_g, m_b, m_a;
|
uint8_t m_r, m_g, m_b, m_a;
|
||||||
};
|
};
|
||||||
|
std::string RGBA2Hex(unsigned int c32);
|
||||||
/// @brief Convert RGB to Hex
|
/// @brief Convert RGB to Hex
|
||||||
/// @param r
|
/// @param r
|
||||||
/// @param g
|
/// @param g
|
||||||
|
@ -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,
|
void TriangleLined(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color,
|
||||||
int t = 1);
|
int t = 1);
|
||||||
void Text(R7Vec2 pos, const std::string& text, RD7TextFlags flags = 0);
|
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),
|
void Image(RenderD7::Image* img, const R7Vec2& pos = R7Vec2(0, 0),
|
||||||
const R7Vec2& scale = R7Vec2(1, 1));
|
const R7Vec2& scale = R7Vec2(1, 1));
|
||||||
} // namespace Draw2
|
} // namespace Draw2
|
||||||
|
@ -50,6 +50,7 @@ void RegKeyEvent(const std::string &event, uint32_t key);
|
|||||||
bool IsEvent(const std::string &event, Actions action);
|
bool IsEvent(const std::string &event, Actions action);
|
||||||
R7Vec2 GetTouchPosition();
|
R7Vec2 GetTouchPosition();
|
||||||
R7Vec2 GetLastTouchPosition();
|
R7Vec2 GetLastTouchPosition();
|
||||||
|
R7Vec2 GetTouchDownPosition();
|
||||||
void Update();
|
void Update();
|
||||||
// Lock/Unlock Input api for example for Keyboard
|
// Lock/Unlock Input api for example for Keyboard
|
||||||
void Lock();
|
void Lock();
|
||||||
|
@ -95,6 +95,7 @@ class Ovl_Keyboard : public RenderD7::Ovl {
|
|||||||
std::string* typed_text = nullptr;
|
std::string* typed_text = nullptr;
|
||||||
std::string str_bak;
|
std::string str_bak;
|
||||||
RD7KeyboardState* state;
|
RD7KeyboardState* state;
|
||||||
|
RD7Keyboard type;
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
int ft3 = 0;
|
int ft3 = 0;
|
||||||
};
|
};
|
||||||
|
@ -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
|
#pragma once
|
||||||
|
|
||||||
#include <renderd7/renderd7.hpp>
|
#include <renderd7/renderd7.hpp>
|
||||||
@ -5,12 +23,20 @@
|
|||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
class ThemeEditor : public RenderD7::Scene {
|
class ThemeEditor : public RenderD7::Scene {
|
||||||
public:
|
public:
|
||||||
ThemeEditor() = default;
|
ThemeEditor();
|
||||||
~ThemeEditor() = default;
|
~ThemeEditor();
|
||||||
|
|
||||||
void Draw() const override;
|
void Draw(void) const override;
|
||||||
void Logic() override;
|
void Logic() override;
|
||||||
|
|
||||||
private:
|
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
|
} // namespace RenderD7
|
@ -65,6 +65,7 @@ void EndMenu();
|
|||||||
void Grid(const std::string &name, const R7Vec2 &size, const R7Vec2 &entry_size,
|
void Grid(const std::string &name, const R7Vec2 &size, const R7Vec2 &entry_size,
|
||||||
void (*display_func)(void *, R7Vec2), void **data_array,
|
void (*display_func)(void *, R7Vec2), void **data_array,
|
||||||
size_t num_entrys);
|
size_t num_entrys);
|
||||||
|
void ColorSelector(const std::string &label, unsigned int &color);
|
||||||
bool BeginTree(const std::string &text);
|
bool BeginTree(const std::string &text);
|
||||||
void EndTree();
|
void EndTree();
|
||||||
R7Vec2 GetCursorPos();
|
R7Vec2 GetCursorPos();
|
||||||
|
@ -76,6 +76,7 @@ extern bool rd7i_graphics_on;
|
|||||||
extern bool rd7i_amdt;
|
extern bool rd7i_amdt;
|
||||||
extern void* rd7i_soc_buf;
|
extern void* rd7i_soc_buf;
|
||||||
extern bool rd7i_is_am_init;
|
extern bool rd7i_is_am_init;
|
||||||
|
extern RenderD7::Theme::Ref rd7i_active_theme;
|
||||||
|
|
||||||
RenderD7::Net::Error rd7i_soc_init();
|
RenderD7::Net::Error rd7i_soc_init();
|
||||||
void rd7i_soc_deinit();
|
void rd7i_soc_deinit();
|
@ -138,6 +138,8 @@ class RSettings : public RenderD7::Scene {
|
|||||||
|
|
||||||
/// @brief Show Up the RenderD7-Settings Menu
|
/// @brief Show Up the RenderD7-Settings Menu
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
|
/// @brief Show Up The Theme Editor
|
||||||
|
void LoadThemeEditor();
|
||||||
/// @brief Get's The Programs Time running
|
/// @brief Get's The Programs Time running
|
||||||
/// @return Time Running
|
/// @return Time Running
|
||||||
float GetTime();
|
float GetTime();
|
||||||
|
137
source/Color.cpp
137
source/Color.cpp
@ -28,7 +28,7 @@ void rd7i_swap32(unsigned int& c) {
|
|||||||
((c & 0xFF000000) >> 24);
|
((c & 0xFF000000) >> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string rd7i_mk2hex(unsigned int c32) {
|
std::string RenderD7::Color::RGBA2Hex(unsigned int c32) {
|
||||||
rd7i_swap32(c32);
|
rd7i_swap32(c32);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "#";
|
ss << "#";
|
||||||
@ -128,6 +128,7 @@ unsigned int RenderD7::Theme::Get(RD7Color clr) {
|
|||||||
if (clr < 0 || clr >= RD7Color_Len) return 0;
|
if (clr < 0 || clr >= RD7Color_Len) return 0;
|
||||||
return this->clr_tab[clr];
|
return this->clr_tab[clr];
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderD7::Theme::Set(RD7Color clr, unsigned int v) {
|
void RenderD7::Theme::Set(RD7Color clr, unsigned int v) {
|
||||||
if (clr < 0 || clr >= RD7Color_Len) return;
|
if (clr < 0 || clr >= RD7Color_Len) return;
|
||||||
this->changes.push_back(change(clr, this->clr_tab[clr], v));
|
this->changes.push_back(change(clr, this->clr_tab[clr], v));
|
||||||
@ -141,6 +142,14 @@ void RenderD7::Theme::Swap(RD7Color a, RD7Color b) {
|
|||||||
this->changes.push_back(change(a, b, c, this->clr_tab[a]));
|
this->changes.push_back(change(a, b, c, this->clr_tab[a]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderD7::Theme::TextBy(RD7Color bg) {
|
||||||
|
if (!Color::RGBA(bg).is_light()) Swap(RD7Color_Text, RD7Color_Text2);
|
||||||
|
}
|
||||||
|
|
||||||
|
RD7Color RenderD7::Theme::AutoText(RD7Color bg) {
|
||||||
|
return Color::RGBA(bg).is_light() ? RD7Color_Text : RD7Color_Text2;
|
||||||
|
}
|
||||||
|
|
||||||
bool RenderD7::Theme::Undo() {
|
bool RenderD7::Theme::Undo() {
|
||||||
if (!this->changes.size()) return false;
|
if (!this->changes.size()) return false;
|
||||||
auto ch = this->changes[this->changes.size() - 1];
|
auto ch = this->changes[this->changes.size() - 1];
|
||||||
@ -160,86 +169,7 @@ void RenderD7::Theme::UndoAll() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RenderD7 StyleColor Api
|
void RenderD7::Theme::Save(const std::string& path) {
|
||||||
// not const cause const = error lol
|
|
||||||
std::map<RD7Color, unsigned int> rd7i_color_map = rd7i_default_theme;
|
|
||||||
|
|
||||||
std::map<RD7Color, unsigned int> rd7i_color_swap_map;
|
|
||||||
|
|
||||||
unsigned int RenderD7::StyleColor(RD7Color color) {
|
|
||||||
if (rd7i_color_swap_map.find(color) != rd7i_color_swap_map.end())
|
|
||||||
return rd7i_color_swap_map[color];
|
|
||||||
else if (rd7i_color_map.find(color) != rd7i_color_map.end())
|
|
||||||
return rd7i_color_map[color];
|
|
||||||
return RGBA8(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::ColorNew(RD7Color color, unsigned int new_color) {
|
|
||||||
// Dont edit before Init
|
|
||||||
if (!rd7i_running) return;
|
|
||||||
rd7i_color_map[color] = new_color;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::RedirectColor(RD7Color to, RD7Color from) {
|
|
||||||
// As you see at the code Redirect doesnt redirect xd
|
|
||||||
// Just named cause it feels like redirecting
|
|
||||||
// Oh and if the color is edit you redirect to it is
|
|
||||||
// grabs that redirected lol
|
|
||||||
rd7i_color_swap_map[to] = StyleColor(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::CustomizeColor(RD7Color color, unsigned int custom) {
|
|
||||||
rd7i_color_swap_map[color] = custom;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::TextColorByBg(RD7Color background) {
|
|
||||||
UndoColorEdit(RD7Color_Text); // To be sure
|
|
||||||
rd7i_color_swap_map[RD7Color_Text] = StyleColor(
|
|
||||||
Color::RGBA(background).is_light() ? RD7Color_Text : RD7Color_Text2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::UndoColorEdit(RD7Color color) {
|
|
||||||
if (rd7i_color_swap_map.find(color) == rd7i_color_swap_map.end()) return;
|
|
||||||
rd7i_color_swap_map.erase(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::UndoAllColorEdits() { rd7i_color_swap_map.clear(); }
|
|
||||||
|
|
||||||
void RenderD7::ThemeLoad(const std::string& path) {
|
|
||||||
std::ifstream file(path);
|
|
||||||
if (!file.is_open()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
nlohmann::json js;
|
|
||||||
file >> js;
|
|
||||||
// clang-format off
|
|
||||||
if(THEMEVER != js["version"]) {
|
|
||||||
file.close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
rd7i_color_map[RD7Color_Text] =rd7i_special_color_hex(js["RD7Color_Text"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_Text2] =rd7i_special_color_hex(js["RD7Color_Text2"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_TextDisabled] =rd7i_special_color_hex(js["RD7Color_TextDisabled"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_Background] =rd7i_special_color_hex(js["RD7Color_Background"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_Header] =rd7i_special_color_hex(js["RD7Color_Header"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_Selector] =rd7i_special_color_hex(js["RD7Color_Selector"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_SelectorFade] =rd7i_special_color_hex(js["RD7Color_SelectorFade"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_List0] =rd7i_special_color_hex(js["RD7Color_List0"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_List1] =rd7i_special_color_hex(js["RD7Color_List1"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_MessageBackground] = rd7i_special_color_hex(js["RD7Color_MessageBackground"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_Button] =rd7i_special_color_hex(js["RD7Color_Button"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_ButtonHovered] =rd7i_special_color_hex(js["RD7Color_ButtonHovered"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_ButtonDisabled] =rd7i_special_color_hex(js["RD7Color_ButtonDisabled"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_ButtonActive] =rd7i_special_color_hex(js["RD7Color_ButtonActive"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_Checkmark] =rd7i_special_color_hex(js["RD7Color_Checkmark"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_FrameBg] =rd7i_special_color_hex(js["RD7Color_FrameBg"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_FrameBgHovered] =rd7i_special_color_hex(js["RD7Color_FrameBgHovered"].get<std::string>());
|
|
||||||
rd7i_color_map[RD7Color_Progressbar] =rd7i_special_color_hex(js["RD7Color_Progressbar"].get<std::string>());
|
|
||||||
// clang-format on
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::ThemeSave(const std::string& path) {
|
|
||||||
if (std::filesystem::path(path).filename().string() == "renderd7.theme") {
|
if (std::filesystem::path(path).filename().string() == "renderd7.theme") {
|
||||||
if (!rd7i_amdt) {
|
if (!rd7i_amdt) {
|
||||||
return;
|
return;
|
||||||
@ -252,30 +182,37 @@ void RenderD7::ThemeSave(const std::string& path) {
|
|||||||
nlohmann::json js;
|
nlohmann::json js;
|
||||||
// clang-format off
|
// clang-format off
|
||||||
js["version"] = THEMEVER;
|
js["version"] = THEMEVER;
|
||||||
js["RD7Color_Text"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Text]);
|
js["RD7Color_Text"] = RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Text]);
|
||||||
js["RD7Color_Text2"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Text2]);
|
js["RD7Color_Text2"] = RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Text2]);
|
||||||
js["RD7Color_TextDisabled"] = rd7i_mk2hex(rd7i_color_map[RD7Color_TextDisabled]);
|
js["RD7Color_TextDisabled"] =
|
||||||
js["RD7Color_Background"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Background]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_TextDisabled]); js["RD7Color_Background"] =
|
||||||
js["RD7Color_Header"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Header]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Background]); js["RD7Color_Header"] =
|
||||||
js["RD7Color_Selector"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Selector]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Header]); js["RD7Color_Selector"] =
|
||||||
js["RD7Color_SelectorFade"] = rd7i_mk2hex(rd7i_color_map[RD7Color_SelectorFade]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Selector]); js["RD7Color_SelectorFade"] =
|
||||||
js["RD7Color_List0"] = rd7i_mk2hex(rd7i_color_map[RD7Color_List0]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_SelectorFade]); js["RD7Color_List0"] =
|
||||||
js["RD7Color_List1"] = rd7i_mk2hex(rd7i_color_map[RD7Color_List1]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_List0]); js["RD7Color_List1"] =
|
||||||
js["RD7Color_MessageBackground"] = rd7i_mk2hex(rd7i_color_map[RD7Color_MessageBackground]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_List1]); js["RD7Color_MessageBackground"] =
|
||||||
js["RD7Color_Button"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Button]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_MessageBackground]); js["RD7Color_Button"] =
|
||||||
js["RD7Color_ButtonHovered"] = rd7i_mk2hex(rd7i_color_map[RD7Color_ButtonHovered]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Button]); js["RD7Color_ButtonHovered"] =
|
||||||
js["RD7Color_ButtonDisabled"] = rd7i_mk2hex(rd7i_color_map[RD7Color_ButtonDisabled]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_ButtonHovered]);
|
||||||
js["RD7Color_ButtonActive"] = rd7i_mk2hex(rd7i_color_map[RD7Color_ButtonActive]);
|
js["RD7Color_ButtonDisabled"] =
|
||||||
js["RD7Color_Checkmark"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Checkmark]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_ButtonDisabled]);
|
||||||
js["RD7Color_FrameBg"] = rd7i_mk2hex(rd7i_color_map[RD7Color_FrameBg]);
|
js["RD7Color_ButtonActive"] =
|
||||||
js["RD7Color_FrameBgHovered"] = rd7i_mk2hex(rd7i_color_map[RD7Color_FrameBgHovered]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_ButtonActive]); js["RD7Color_Checkmark"] =
|
||||||
js["RD7Color_Progressbar"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Progressbar]);
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Checkmark]); js["RD7Color_FrameBg"] =
|
||||||
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_FrameBg]); js["RD7Color_FrameBgHovered"] =
|
||||||
|
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_FrameBgHovered]); js["RD7Color_Progressbar"]
|
||||||
|
= RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Progressbar]);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
file << js.dump(4);
|
file << js.dump(4);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderD7::ThemeDefault() { rd7i_color_map = rd7i_default_theme; }
|
RenderD7::Theme::Ref RenderD7::ThemeActive() { return rd7i_active_theme; }
|
||||||
|
|
||||||
|
void RenderD7::ThemeSet(RenderD7::Theme::Ref theme) {
|
||||||
|
rd7i_active_theme = theme;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t RenderD7::Color::Hex(const std::string& color, uint8_t a) {
|
uint32_t RenderD7::Color::Hex(const std::string& color, uint8_t a) {
|
||||||
if (color.length() < 7 ||
|
if (color.length() < 7 ||
|
||||||
|
@ -198,8 +198,15 @@ void TriangleLined(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Text(R7Vec2 pos, const std::string &text, RD7TextFlags flags) {
|
void Text(R7Vec2 pos, const std::string &text, RD7TextFlags flags) {
|
||||||
|
TextClr(pos, text, RenderD7::ThemeActive()->Get(RD7Color_Text), flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextClr(R7Vec2 pos, const std::string &text, unsigned int color,
|
||||||
|
RD7TextFlags flags) {
|
||||||
// The Start of the C2D Text Hell
|
// The Start of the C2D Text Hell
|
||||||
if (!RD7I_FNT_VALID()) return;
|
if (!RD7I_FNT_VALID()) return;
|
||||||
|
// Check if Theme Loadet
|
||||||
|
if (!ThemeActive()) return;
|
||||||
// little patch for a freeze
|
// little patch for a freeze
|
||||||
if (text.length() < 1) return;
|
if (text.length() < 1) return;
|
||||||
// Variables
|
// Variables
|
||||||
@ -262,17 +269,17 @@ void Text(R7Vec2 pos, const std::string &text, RD7TextFlags flags) {
|
|||||||
if (flags & RD7TextFlags_Shaddow) // performance Killer xd
|
if (flags & RD7TextFlags_Shaddow) // performance Killer xd
|
||||||
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x + 1 + (dim.y * line),
|
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x + 1 + (dim.y * line),
|
||||||
newpos.y + 1, 0.5, rd7i_d2_txt_size, rd7i_d2_txt_size,
|
newpos.y + 1, 0.5, rd7i_d2_txt_size, rd7i_d2_txt_size,
|
||||||
RenderD7::StyleColor(RD7Color_TextDisabled));
|
RenderD7::ThemeActive()->Get(RD7Color_TextDisabled));
|
||||||
|
|
||||||
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x, newpos.y + (dim.y * line),
|
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x, newpos.y + (dim.y * line),
|
||||||
0.5, rd7i_d2_txt_size, rd7i_d2_txt_size,
|
0.5, rd7i_d2_txt_size, rd7i_d2_txt_size, color);
|
||||||
RenderD7::StyleColor(RD7Color_Text));
|
|
||||||
edit_text = edit_text.substr(edit_text.find('\n') + 1);
|
edit_text = edit_text.substr(edit_text.find('\n') + 1);
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updated_mwh) rd7i_d7_mwh = R7Vec2(0, 0);
|
if (updated_mwh) rd7i_d7_mwh = R7Vec2(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image(RenderD7::Image *img, const R7Vec2 &pos, const R7Vec2 &scale) {
|
void Image(RenderD7::Image *img, const R7Vec2 &pos, const R7Vec2 &scale) {
|
||||||
if (img->loaded())
|
if (img->loaded())
|
||||||
C2D_DrawImageAt(img->get(), pos.x, pos.y, 0.5f, nullptr, scale.x, scale.y);
|
C2D_DrawImageAt(img->get(), pos.x, pos.y, 0.5f, nullptr, scale.x, scale.y);
|
||||||
|
@ -41,6 +41,7 @@ class HidApi {
|
|||||||
// Clears Functionality for 1 Frame
|
// Clears Functionality for 1 Frame
|
||||||
last_touch_pos = R7Vec2();
|
last_touch_pos = R7Vec2();
|
||||||
touch_pos[0] = R7Vec2();
|
touch_pos[0] = R7Vec2();
|
||||||
|
dtp = R7Vec2();
|
||||||
backups[Hid::Down] = 0;
|
backups[Hid::Down] = 0;
|
||||||
backups[Hid::Held] = 0;
|
backups[Hid::Held] = 0;
|
||||||
backups[Hid::Up] = 0;
|
backups[Hid::Up] = 0;
|
||||||
@ -60,9 +61,16 @@ class HidApi {
|
|||||||
|
|
||||||
R7Vec2 getTouchPos() { return touch_pos[0]; }
|
R7Vec2 getTouchPos() { return touch_pos[0]; }
|
||||||
R7Vec2 getLastTouchPos() { return last_touch_pos; }
|
R7Vec2 getLastTouchPos() { return last_touch_pos; }
|
||||||
|
R7Vec2 getTouchDownPos() { return dtp; }
|
||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
last_touch_pos = touch_pos[0];
|
last_touch_pos = touch_pos[0];
|
||||||
|
if (isEvent("touch", Hid::Down)) {
|
||||||
|
dtp = touch_pos[0];
|
||||||
|
}
|
||||||
|
if (isEvent("touch", Hid::Up)) {
|
||||||
|
dtp = R7Vec2();
|
||||||
|
}
|
||||||
for (const auto &it : actions) {
|
for (const auto &it : actions) {
|
||||||
backups[it.first] = it.second[0];
|
backups[it.first] = it.second[0];
|
||||||
}
|
}
|
||||||
@ -82,6 +90,7 @@ class HidApi {
|
|||||||
R7Vec2 *js2_mv = nullptr;
|
R7Vec2 *js2_mv = nullptr;
|
||||||
|
|
||||||
R7Vec2 last_touch_pos;
|
R7Vec2 last_touch_pos;
|
||||||
|
R7Vec2 dtp;
|
||||||
|
|
||||||
std::map<std::string, uint32_t> key_bindings;
|
std::map<std::string, uint32_t> key_bindings;
|
||||||
bool locked = false;
|
bool locked = false;
|
||||||
@ -120,6 +129,7 @@ bool IsEvent(const std::string &event, Actions action) {
|
|||||||
}
|
}
|
||||||
R7Vec2 GetTouchPosition() { return hid_handler.getTouchPos(); }
|
R7Vec2 GetTouchPosition() { return hid_handler.getTouchPos(); }
|
||||||
R7Vec2 GetLastTouchPosition() { return hid_handler.getLastTouchPos(); }
|
R7Vec2 GetLastTouchPosition() { return hid_handler.getLastTouchPos(); }
|
||||||
|
R7Vec2 GetTouchDownPosition() { return hid_handler.getTouchDownPos(); }
|
||||||
void Update() { hid_handler.update(); }
|
void Update() { hid_handler.update(); }
|
||||||
void Lock() { hid_handler.lock(true); }
|
void Lock() { hid_handler.lock(true); }
|
||||||
void Unlock() { hid_handler.lock(false); }
|
void Unlock() { hid_handler.lock(false); }
|
||||||
|
@ -65,22 +65,23 @@ void ProcessMessages() {
|
|||||||
200 - (float(msg_lst[i]->animationframe - fade_outs) / fol) * 200;
|
200 - (float(msg_lst[i]->animationframe - fade_outs) / fol) * 200;
|
||||||
}
|
}
|
||||||
// Wtf is this function lol
|
// Wtf is this function lol
|
||||||
RenderD7::CustomizeColor(RD7Color_MessageBackground,
|
RenderD7::ThemeActive()->Set(
|
||||||
RenderD7::Color::RGBA(RD7Color_MessageBackground)
|
RD7Color_MessageBackground,
|
||||||
.changeA(new_alpha)
|
RenderD7::Color::RGBA(RD7Color_MessageBackground)
|
||||||
.toRGBA());
|
.changeA(new_alpha)
|
||||||
RenderD7::CustomizeColor(
|
.toRGBA());
|
||||||
|
RenderD7::ThemeActive()->Set(
|
||||||
RD7Color_Text,
|
RD7Color_Text,
|
||||||
RenderD7::Color::RGBA(RD7Color_Text2).changeA(new_alpha).toRGBA());
|
RenderD7::Color::RGBA(RD7Color_Text2).changeA(new_alpha).toRGBA());
|
||||||
RenderD7::Draw2::RFS(pos, R7Vec2(150, 50),
|
RenderD7::Draw2::RFS(
|
||||||
RenderD7::StyleColor(RD7Color_MessageBackground));
|
pos, R7Vec2(150, 50),
|
||||||
|
RenderD7::ThemeActive()->Get(RD7Color_MessageBackground));
|
||||||
RenderD7::Draw2::Text(pos + R7Vec2(5, 1), msg_lst[i]->title);
|
RenderD7::Draw2::Text(pos + R7Vec2(5, 1), msg_lst[i]->title);
|
||||||
RenderD7::Draw2::Text(pos + R7Vec2(5, 17), msg_lst[i]->message);
|
RenderD7::Draw2::Text(pos + R7Vec2(5, 17), msg_lst[i]->message);
|
||||||
if (rd7_debugging)
|
if (rd7_debugging)
|
||||||
RenderD7::Draw2::Text(pos + R7Vec2(155, 1),
|
RenderD7::Draw2::Text(pos + R7Vec2(155, 1),
|
||||||
std::to_string(msg_lst[i]->animationframe));
|
std::to_string(msg_lst[i]->animationframe));
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
RenderD7::ThemeActive()->UndoAll();
|
||||||
RenderD7::UndoColorEdit(RD7Color_MessageBackground);
|
|
||||||
// Why Frameadd? because Message uses int as frame and
|
// Why Frameadd? because Message uses int as frame and
|
||||||
// It seems that lower 0.5 will be rounded to 0
|
// It seems that lower 0.5 will be rounded to 0
|
||||||
// Why not replace int with float ?
|
// Why not replace int with float ?
|
||||||
|
@ -40,6 +40,30 @@ struct Key {
|
|||||||
int action = 0;
|
int action = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::vector<Key> keyboard_layout_num{
|
||||||
|
// 1st row
|
||||||
|
{"7", R7Vec2(5, 135), R7Vec2(36, 24), 0},
|
||||||
|
{"8", R7Vec2(43, 135), R7Vec2(36, 24), 0},
|
||||||
|
{"9", R7Vec2(81, 135), R7Vec2(36, 24), 0},
|
||||||
|
// 2nd row
|
||||||
|
{"4", R7Vec2(5, 161), R7Vec2(36, 24), 0},
|
||||||
|
{"5", R7Vec2(43, 161), R7Vec2(36, 24), 0},
|
||||||
|
{"6", R7Vec2(81, 161), R7Vec2(36, 24), 0},
|
||||||
|
// 3rd row
|
||||||
|
{"1", R7Vec2(5, 187), R7Vec2(36, 24), 0},
|
||||||
|
{"2", R7Vec2(43, 187), R7Vec2(36, 24), 0},
|
||||||
|
{"3", R7Vec2(81, 187), R7Vec2(36, 24), 0},
|
||||||
|
|
||||||
|
// 4th row
|
||||||
|
{"0", R7Vec2(5, 213), R7Vec2(74, 24), 0},
|
||||||
|
{".", R7Vec2(81, 213), R7Vec2(36, 24), 0},
|
||||||
|
// additional actions
|
||||||
|
{"bksp", R7Vec2(119, 135), R7Vec2(74, 24), 2},
|
||||||
|
//{"", R7Vec2(119, 161), R7Vec2(74, 24), 0},
|
||||||
|
{"Confirm", R7Vec2(119, 187), R7Vec2(74, 24), 5},
|
||||||
|
{"Cancel", R7Vec2(119, 213), R7Vec2(74, 24), 4},
|
||||||
|
};
|
||||||
|
|
||||||
std::vector<Key> keyboard_layout = {
|
std::vector<Key> keyboard_layout = {
|
||||||
// 1st row
|
// 1st row
|
||||||
{"`", R7Vec2(5, 137), R7Vec2(18, 18), 0},
|
{"`", R7Vec2(5, 137), R7Vec2(18, 18), 0},
|
||||||
@ -336,7 +360,7 @@ void Ovl_Metrik::Draw(void) const {
|
|||||||
RenderD7::GetTextDimensions(mt_tbs), i_mt_color[0]);
|
RenderD7::GetTextDimensions(mt_tbs), i_mt_color[0]);
|
||||||
RenderD7::Draw2::RFS(R7Vec2(0, infoy), RenderD7::GetTextDimensions(info),
|
RenderD7::Draw2::RFS(R7Vec2(0, infoy), RenderD7::GetTextDimensions(info),
|
||||||
i_mt_color[0]);
|
i_mt_color[0]);
|
||||||
RenderD7::CustomizeColor(RD7Color_Text, i_txt_color[0]);
|
RenderD7::ThemeActive()->Set(RD7Color_Text, i_txt_color[0]);
|
||||||
RenderD7::Draw2::Text(R7Vec2(0, 0), mt_fps);
|
RenderD7::Draw2::Text(R7Vec2(0, 0), mt_fps);
|
||||||
RenderD7::Draw2::Text(R7Vec2(0, 50), mt_cpu);
|
RenderD7::Draw2::Text(R7Vec2(0, 50), mt_cpu);
|
||||||
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 1), mt_gpu);
|
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 1), mt_gpu);
|
||||||
@ -344,7 +368,7 @@ void Ovl_Metrik::Draw(void) const {
|
|||||||
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 3), mt_lfr);
|
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 3), mt_lfr);
|
||||||
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 4), mt_tbs);
|
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 4), mt_tbs);
|
||||||
RenderD7::Draw2::Text(R7Vec2(0, infoy), info);
|
RenderD7::Draw2::Text(R7Vec2(0, infoy), info);
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
RenderD7::ThemeActive()->Undo();
|
||||||
|
|
||||||
// Force Bottom (Debug Touchpos)
|
// Force Bottom (Debug Touchpos)
|
||||||
RenderD7::OnScreen(Bottom);
|
RenderD7::OnScreen(Bottom);
|
||||||
@ -370,6 +394,7 @@ Ovl_Keyboard::Ovl_Keyboard(std::string& ref, RD7KeyboardState& state,
|
|||||||
RenderD7::Hid::Lock();
|
RenderD7::Hid::Lock();
|
||||||
typed_text = &ref;
|
typed_text = &ref;
|
||||||
this->state = &state;
|
this->state = &state;
|
||||||
|
this->type = type;
|
||||||
*this->state = RD7KeyboardState_None;
|
*this->state = RD7KeyboardState_None;
|
||||||
str_bak = ref;
|
str_bak = ref;
|
||||||
ft3 = 0;
|
ft3 = 0;
|
||||||
@ -384,7 +409,8 @@ void Ovl_Keyboard::Draw(void) const {
|
|||||||
float tmp_txt = RenderD7::TextGetSize();
|
float tmp_txt = RenderD7::TextGetSize();
|
||||||
RenderD7::TextDefaultSize();
|
RenderD7::TextDefaultSize();
|
||||||
if (ft3 > 5) RenderD7::Hid::Unlock();
|
if (ft3 > 5) RenderD7::Hid::Unlock();
|
||||||
auto key_table = keyboard_layout;
|
auto key_table =
|
||||||
|
(type == RD7Keyboard_Numpad) ? keyboard_layout_num : keyboard_layout;
|
||||||
if (mode == 1)
|
if (mode == 1)
|
||||||
key_table = keyboard_layout_caps;
|
key_table = keyboard_layout_caps;
|
||||||
else if (mode == 2)
|
else if (mode == 2)
|
||||||
@ -398,17 +424,21 @@ void Ovl_Keyboard::Draw(void) const {
|
|||||||
R7Vec2(0, 0), R7Vec2(320, 112),
|
R7Vec2(0, 0), R7Vec2(320, 112),
|
||||||
RenderD7::Color::RGBA(RD7Color_FrameBg).changeA(150).toRGBA());
|
RenderD7::Color::RGBA(RD7Color_FrameBg).changeA(150).toRGBA());
|
||||||
RenderD7::Draw2::RFS(R7Vec2(0, 112), R7Vec2(320, 128),
|
RenderD7::Draw2::RFS(R7Vec2(0, 112), R7Vec2(320, 128),
|
||||||
RenderD7::StyleColor(RD7Color_FrameBg));
|
RenderD7::ThemeActive()->Get(RD7Color_FrameBg));
|
||||||
RenderD7::Draw2::RFS(R7Vec2(0, 112), R7Vec2(320, 20),
|
RenderD7::Draw2::RFS(R7Vec2(0, 112), R7Vec2(320, 20),
|
||||||
RenderD7::StyleColor(RD7Color_Header));
|
RenderD7::ThemeActive()->Get(RD7Color_Header));
|
||||||
RenderD7::TextColorByBg(RD7Color_Header);
|
RenderD7::ThemeActive()->TextBy(RD7Color_Header);
|
||||||
RenderD7::Draw2::Text(R7Vec2(5, 114), "> " + *typed_text);
|
RenderD7::Draw2::Text(R7Vec2(5, 114), "> " + *typed_text);
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
RenderD7::ThemeActive()->Undo();
|
||||||
for (auto const& it : key_table) {
|
for (auto const& it : key_table) {
|
||||||
R7Vec2 txtdim = RenderD7::GetTextDimensions(it.disp);
|
R7Vec2 txtdim = RenderD7::GetTextDimensions(it.disp);
|
||||||
R7Vec2 txtpos = R7Vec2(it.pos.x + it.size.x * 0.5 - txtdim.x * 0.5,
|
R7Vec2 txtpos = R7Vec2(it.pos.x + it.size.x * 0.5 - txtdim.x * 0.5,
|
||||||
it.pos.y + it.size.y * 0.5 - txtdim.y * 0.5);
|
it.pos.y + it.size.y * 0.5 - txtdim.y * 0.5);
|
||||||
RD7Color btn = RD7Color_Button;
|
RD7Color btn = RD7Color_Button;
|
||||||
|
if (RenderD7::Hid::IsEvent("cancel", RenderD7::Hid::Up)) {
|
||||||
|
RenderD7::Hid::Clear();
|
||||||
|
shared_data[0x05] = 1;
|
||||||
|
}
|
||||||
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
||||||
UI7_InBox(RenderD7::Hid::GetLastTouchPosition(), it.pos, it.size)) {
|
UI7_InBox(RenderD7::Hid::GetLastTouchPosition(), it.pos, it.size)) {
|
||||||
if (mode == 2) // Request Disable Shift
|
if (mode == 2) // Request Disable Shift
|
||||||
@ -436,10 +466,10 @@ void Ovl_Keyboard::Draw(void) const {
|
|||||||
UI7_InBox(RenderD7::Hid::GetTouchPosition(), it.pos, it.size)) {
|
UI7_InBox(RenderD7::Hid::GetTouchPosition(), it.pos, it.size)) {
|
||||||
btn = RD7Color_ButtonHovered;
|
btn = RD7Color_ButtonHovered;
|
||||||
}
|
}
|
||||||
RenderD7::Draw2::RFS(it.pos, it.size, RenderD7::StyleColor(btn));
|
RenderD7::Draw2::RFS(it.pos, it.size, RenderD7::ThemeActive()->Get(btn));
|
||||||
RenderD7::TextColorByBg(btn);
|
RenderD7::ThemeActive()->TextBy(btn);
|
||||||
RenderD7::Draw2::Text(txtpos, it.disp);
|
RenderD7::Draw2::Text(txtpos, it.disp);
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
RenderD7::ThemeActive()->Undo();
|
||||||
}
|
}
|
||||||
if (ft3 > 5) RenderD7::Hid::Lock();
|
if (ft3 > 5) RenderD7::Hid::Lock();
|
||||||
RenderD7::CustomTextSize(tmp_txt);
|
RenderD7::CustomTextSize(tmp_txt);
|
||||||
|
85
source/ThemeEditor.cpp
Normal file
85
source/ThemeEditor.cpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/**
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <renderd7/Hid.hpp>
|
||||||
|
#include <renderd7/ThemeEditor.hpp>
|
||||||
|
#include <renderd7/UI7.hpp>
|
||||||
|
|
||||||
|
std::map<RD7Color, std::string> color_names = {
|
||||||
|
{RD7Color_Background, "Background"},
|
||||||
|
{RD7Color_Button, "Button"},
|
||||||
|
{RD7Color_ButtonActive, "ButtonActive"},
|
||||||
|
{RD7Color_ButtonDisabled, "ButtonDisabled"},
|
||||||
|
{RD7Color_ButtonHovered, "ButtonHovered"},
|
||||||
|
{RD7Color_Checkmark, "Checkmark"},
|
||||||
|
{RD7Color_FrameBg, "FrameBg"},
|
||||||
|
{RD7Color_FrameBgHovered, "FrameBgHovered"},
|
||||||
|
{RD7Color_Header, "Header"},
|
||||||
|
{RD7Color_List0, "List0"},
|
||||||
|
{RD7Color_List1, "List1"},
|
||||||
|
{RD7Color_MessageBackground, "Message Background"},
|
||||||
|
{RD7Color_Progressbar, "Progressbar"},
|
||||||
|
{RD7Color_Selector, "Selector"},
|
||||||
|
{RD7Color_SelectorFade, "SelectorFade"},
|
||||||
|
{RD7Color_Text2, "Text2"},
|
||||||
|
{RD7Color_Text, "Text"},
|
||||||
|
{RD7Color_TextDisabled, "Text Disabled"},
|
||||||
|
};
|
||||||
|
|
||||||
|
RenderD7::ThemeEditor::ThemeEditor() {
|
||||||
|
// Backup active Theme and create New one to edit
|
||||||
|
temp_theme = RenderD7::ThemeActive();
|
||||||
|
edit_theme = RenderD7::Theme::New();
|
||||||
|
edit_theme->Default();
|
||||||
|
RenderD7::ThemeSet(edit_theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderD7::ThemeEditor::~ThemeEditor() {
|
||||||
|
// Set Back to Acrive Theme
|
||||||
|
RenderD7::ThemeSet(temp_theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::ThemeEditor::Draw() const {
|
||||||
|
RenderD7::OnScreen(Top);
|
||||||
|
if (UI7::BeginMenu("Theme Editor")) {
|
||||||
|
UI7::Label("Sample Text");
|
||||||
|
UI7::Checkbox("Checkbox", cm);
|
||||||
|
UI7::InputText("Input Text", inpt, "Input Text");
|
||||||
|
UI7::Button("Button");
|
||||||
|
UI7::Progressbar(0.5f);
|
||||||
|
UI7::ColorSelector("Color Selector",
|
||||||
|
edit_theme->GetTableRef()[RD7Color_Progressbar]);
|
||||||
|
UI7::EndMenu();
|
||||||
|
}
|
||||||
|
RenderD7::OnScreen(Bottom);
|
||||||
|
if (UI7::BeginMenu("Theme", R7Vec2(), UI7MenuFlags_Scrolling)) {
|
||||||
|
if (menu == 0) {
|
||||||
|
for (auto& it : color_names) {
|
||||||
|
UI7::ColorSelector(it.second, edit_theme->GetTableRef()[it.first]);
|
||||||
|
}
|
||||||
|
} else if (menu == 1) {
|
||||||
|
}
|
||||||
|
UI7::EndMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::ThemeEditor::Logic() {
|
||||||
|
if (Hid::IsEvent("cancel", Hid::Down)) {
|
||||||
|
RenderD7::Scene::Back();
|
||||||
|
}
|
||||||
|
}
|
668
source/UI7.cpp
668
source/UI7.cpp
@ -20,6 +20,7 @@
|
|||||||
#include <renderd7/Color.hpp>
|
#include <renderd7/Color.hpp>
|
||||||
#include <renderd7/DrawV2.hpp>
|
#include <renderd7/DrawV2.hpp>
|
||||||
#include <renderd7/Hid.hpp>
|
#include <renderd7/Hid.hpp>
|
||||||
|
#include <renderd7/Message.hpp>
|
||||||
#include <renderd7/Overlays.hpp>
|
#include <renderd7/Overlays.hpp>
|
||||||
#include <renderd7/UI7.hpp>
|
#include <renderd7/UI7.hpp>
|
||||||
#include <renderd7/internal_db.hpp>
|
#include <renderd7/internal_db.hpp>
|
||||||
@ -84,40 +85,129 @@ struct UI7ID {
|
|||||||
bool has_title;
|
bool has_title;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<unsigned int> ui7i_debug_colors{
|
using DrawCmdType = int;
|
||||||
0xff0000ff, // lvl 0
|
enum DrawCmdType_ {
|
||||||
0xff3344ff, // lvl 1
|
DrawCmdType_Skip,
|
||||||
0xffff44ff, // lvl 2
|
DrawCmdType_Rect,
|
||||||
0xffff4422, // lvl 3
|
DrawCmdType_Triangle,
|
||||||
|
DrawCmdType_Text,
|
||||||
|
DrawCmdType_Debug,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int UI7CtxDebugCol(int lvl) {
|
struct DrawCmd;
|
||||||
if (lvl < 0) return 0;
|
void UI7CtxPushDebugCmd(std::shared_ptr<DrawCmd> ref);
|
||||||
if (lvl >= (int)ui7i_debug_colors.size()) return 0;
|
|
||||||
return ui7i_debug_colors[lvl];
|
|
||||||
}
|
|
||||||
|
|
||||||
struct UI7OBJ {
|
struct DrawCmd {
|
||||||
UI7OBJ() {}
|
DrawCmd(R7Vec4 r, RD7Color c) : rect(r), clr(c), type(DrawCmdType_Rect) {}
|
||||||
UI7OBJ(const R7Vec4 &i0, const int &i1) {
|
DrawCmd(R7Vec4 r, unsigned int c)
|
||||||
box = i0;
|
: rect(r), ovr_clr(c), type(DrawCmdType_Rect) {
|
||||||
type = i1;
|
clr = -1;
|
||||||
s = rd7i_current_screen;
|
}
|
||||||
|
DrawCmd(R7Vec4 r, R7Vec2 a, RD7Color c)
|
||||||
|
: rect(r), add_coords(a), clr(c), type(DrawCmdType_Triangle) {}
|
||||||
|
DrawCmd(R7Vec4 r, R7Vec2 a, unsigned int c)
|
||||||
|
: rect(r), add_coords(a), ovr_clr(c), type(DrawCmdType_Triangle) {
|
||||||
|
clr = -1;
|
||||||
|
}
|
||||||
|
DrawCmd(R7Vec2 p, const std::string &t, RD7Color c, RD7TextFlags f = 0)
|
||||||
|
: rect(p, R7Vec2()),
|
||||||
|
text(t),
|
||||||
|
clr(c),
|
||||||
|
text_flags(f),
|
||||||
|
type(DrawCmdType_Text) {}
|
||||||
|
DrawCmd(R7Vec2 p, const std::string &t, unsigned int c, RD7TextFlags f = 0)
|
||||||
|
: rect(p, R7Vec2()),
|
||||||
|
text(t),
|
||||||
|
ovr_clr(c),
|
||||||
|
text_flags(f),
|
||||||
|
type(DrawCmdType_Text) {
|
||||||
|
clr = -1;
|
||||||
|
}
|
||||||
|
// Empty Command
|
||||||
|
DrawCmd() {}
|
||||||
|
// For Debug API
|
||||||
|
DrawCmd(DrawCmd &thiz) {
|
||||||
|
auto cmd = DrawCmd::New();
|
||||||
|
cmd->add_coords = thiz.add_coords;
|
||||||
|
cmd->clr = thiz.clr;
|
||||||
|
cmd->ovr_clr = thiz.ovr_clr;
|
||||||
|
cmd->rect = thiz.rect;
|
||||||
|
cmd->stype = thiz.type;
|
||||||
|
cmd->text = thiz.text;
|
||||||
|
cmd->text_box = thiz.text_box;
|
||||||
|
cmd->text_flags = thiz.text_flags;
|
||||||
|
cmd->type = DrawCmdType_Debug;
|
||||||
|
cmd->screen = rd7i_current_screen;
|
||||||
|
UI7CtxPushDebugCmd(cmd);
|
||||||
|
}
|
||||||
|
R7Vec4 rect; // Position / Size
|
||||||
|
R7Vec2 add_coords; // Additional Coords
|
||||||
|
RD7Color clr; // Color
|
||||||
|
std::string text; // Text
|
||||||
|
DrawCmdType type; // DrawCmd Type
|
||||||
|
DrawCmdType stype; // Second Type
|
||||||
|
unsigned int ovr_clr; // Override Color (if not clr)
|
||||||
|
RD7TextFlags text_flags; // Flags for Text Rendering
|
||||||
|
R7Vec2 text_box; // Maximum text Box
|
||||||
|
bool screen;
|
||||||
|
|
||||||
|
// Process the Command
|
||||||
|
void Process() {
|
||||||
|
DrawCmd(*this);
|
||||||
|
if (type == DrawCmdType_Skip) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto color = (clr == -1 ? ovr_clr : RenderD7::ThemeActive()->Get(clr));
|
||||||
|
if (type == DrawCmdType_Rect) {
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(rect.x, rect.y), R7Vec2(rect.z, rect.w),
|
||||||
|
color);
|
||||||
|
} else if (type == DrawCmdType_Triangle) {
|
||||||
|
RenderD7::Draw2::TriangleSolid(R7Vec2(rect.x, rect.y),
|
||||||
|
R7Vec2(rect.z, rect.w), add_coords, color);
|
||||||
|
} else if (type == DrawCmdType_Text) {
|
||||||
|
if (text_box.x || text_box.y) {
|
||||||
|
RenderD7::TextMaxBox(text_box);
|
||||||
|
}
|
||||||
|
RenderD7::Draw2::TextClr(R7Vec2(rect.x, rect.y), text, color, text_flags);
|
||||||
|
if (text_box.x || text_box.y) {
|
||||||
|
RenderD7::TextDefaultBox();
|
||||||
|
}
|
||||||
|
} else if (type == DrawCmdType_Debug) {
|
||||||
|
Debug();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Killer Function
|
|
||||||
void Debug() {
|
void Debug() {
|
||||||
RenderD7::OnScreen(s ? Top : Bottom);
|
RenderD7::OnScreen(screen ? Top : Bottom);
|
||||||
auto clr = UI7CtxDebugCol(type);
|
if (stype == DrawCmdType_Skip && type != DrawCmdType_Debug) return;
|
||||||
RenderD7::Draw2::TriangleLined(R7Vec2(box.x, box.y),
|
// auto color = (clr == -1 ? ovr_clr : RenderD7::ThemeActive()->Get(clr));
|
||||||
R7Vec2(box.x + box.z, box.y),
|
if (stype == DrawCmdType_Rect) {
|
||||||
R7Vec2(box.x, box.y + box.w), clr);
|
RenderD7::Draw2::TriangleLined(
|
||||||
RenderD7::Draw2::TriangleLined(R7Vec2(box.x, box.y + box.w),
|
R7Vec2(rect.x, rect.y), R7Vec2(rect.x + rect.z, rect.y),
|
||||||
R7Vec2(box.x + box.z, box.y),
|
R7Vec2(rect.x, rect.y + rect.w), 0xff0000ff);
|
||||||
R7Vec2(box.x + box.z, box.y + box.w), clr);
|
RenderD7::Draw2::TriangleLined(R7Vec2(rect.x + rect.z, rect.y + rect.w),
|
||||||
|
R7Vec2(rect.x + rect.z, rect.y),
|
||||||
|
R7Vec2(rect.x, rect.y + rect.w),
|
||||||
|
0xff0000ff);
|
||||||
|
} else if (stype == DrawCmdType_Text) {
|
||||||
|
auto szs = RenderD7::GetTextDimensions(text);
|
||||||
|
if (text_flags & RD7TextFlags_AlignRight) {
|
||||||
|
rect.x -= szs.x;
|
||||||
|
}
|
||||||
|
RenderD7::Draw2::TriangleLined(
|
||||||
|
R7Vec2(rect.x, rect.y), R7Vec2(rect.x + szs.x, rect.y),
|
||||||
|
R7Vec2(rect.x, rect.y + szs.y), 0xff00ffff);
|
||||||
|
RenderD7::Draw2::TriangleLined(R7Vec2(rect.x + szs.x, rect.y + szs.y),
|
||||||
|
R7Vec2(rect.x + szs.x, rect.y),
|
||||||
|
R7Vec2(rect.x, rect.y + szs.y),
|
||||||
|
0xff00ffff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// For Smart Pointer
|
||||||
|
using Ref = std::shared_ptr<DrawCmd>;
|
||||||
|
template <typename... args>
|
||||||
|
static Ref New(args &&...cargs) {
|
||||||
|
return std::make_shared<DrawCmd>(std::forward<args>(cargs)...);
|
||||||
}
|
}
|
||||||
R7Vec4 box;
|
|
||||||
int type;
|
|
||||||
bool s = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UI7Menu {
|
struct UI7Menu {
|
||||||
@ -131,6 +221,15 @@ struct UI7Menu {
|
|||||||
float scrolling_mod = 0.f; // For Menu Scrolling effect
|
float scrolling_mod = 0.f; // For Menu Scrolling effect
|
||||||
float tbh; // TabBar Height
|
float tbh; // TabBar Height
|
||||||
bool show_scroolbar = true; // Show Scrollbar
|
bool show_scroolbar = true; // Show Scrollbar
|
||||||
|
bool has_touch = false; // To Disable touch on Top Screen
|
||||||
|
|
||||||
|
// SubMenu
|
||||||
|
std::string submenu;
|
||||||
|
|
||||||
|
// DrawLists
|
||||||
|
std::vector<DrawCmd::Ref> background;
|
||||||
|
std::vector<DrawCmd::Ref> main;
|
||||||
|
std::vector<DrawCmd::Ref> front;
|
||||||
|
|
||||||
R7Vec2 ms; // Max Size
|
R7Vec2 ms; // Max Size
|
||||||
R7Vec2 msr; // Max Size Real (Slider)
|
R7Vec2 msr; // Max Size Real (Slider)
|
||||||
@ -156,12 +255,16 @@ struct UI7_Ctx {
|
|||||||
bool in_menu;
|
bool in_menu;
|
||||||
bool debugging;
|
bool debugging;
|
||||||
std::map<std::string, UI7Menu::Ref> menus;
|
std::map<std::string, UI7Menu::Ref> menus;
|
||||||
|
std::vector<DrawCmd::Ref> debug_calls;
|
||||||
UI7Menu::Ref cm;
|
UI7Menu::Ref cm;
|
||||||
std::vector<UI7OBJ> objects;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
UI7_Ctx *ui7_ctx;
|
UI7_Ctx *ui7_ctx;
|
||||||
|
|
||||||
|
void UI7CtxPushDebugCmd(DrawCmd::Ref ref) {
|
||||||
|
ui7_ctx->debug_calls.push_back(ref);
|
||||||
|
}
|
||||||
|
|
||||||
bool UI7CtxValidate() {
|
bool UI7CtxValidate() {
|
||||||
if (ui7_ctx == nullptr) return false;
|
if (ui7_ctx == nullptr) return false;
|
||||||
if (!ui7_ctx->is_activated) return false;
|
if (!ui7_ctx->is_activated) return false;
|
||||||
@ -181,6 +284,7 @@ bool UI7CtxBeginMenu(const std::string &lb) {
|
|||||||
ui7_ctx->cm = ui7_ctx->menus[id.ID()];
|
ui7_ctx->cm = ui7_ctx->menus[id.ID()];
|
||||||
ui7_ctx->cm->menuid = id;
|
ui7_ctx->cm->menuid = id;
|
||||||
ui7_ctx->cm->cursor = R7Vec2(0, 0);
|
ui7_ctx->cm->cursor = R7Vec2(0, 0);
|
||||||
|
ui7_ctx->cm->has_touch = !rd7i_current_screen;
|
||||||
ui7_ctx->in_menu = true;
|
ui7_ctx->in_menu = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -207,12 +311,20 @@ void UI7CtxEndMenu() {
|
|||||||
(szs) * (static_cast<float>(ui7_ctx->cm->scrolling_offset) /
|
(szs) * (static_cast<float>(ui7_ctx->cm->scrolling_offset) /
|
||||||
static_cast<float>(ui7_ctx->cm->msr.y)))));
|
static_cast<float>(ui7_ctx->cm->msr.y)))));
|
||||||
int slider_w = 4;
|
int slider_w = 4;
|
||||||
RenderD7::Draw2::RFS(R7Vec2(sw - 12, tsp), R7Vec2(slider_w * 2, szs),
|
ui7_ctx->cm->front.push_back(
|
||||||
RenderD7::StyleColor(RD7Color_List0));
|
DrawCmd::New(R7Vec4(R7Vec2(sw - 12, tsp), R7Vec2(slider_w * 2, szs)),
|
||||||
RenderD7::Draw2::RFS(R7Vec2(sw - 10, slider_pos + 2),
|
RD7Color_List0));
|
||||||
R7Vec2(slider_w, slider_rh),
|
ui7_ctx->cm->front.push_back(DrawCmd::New(
|
||||||
RenderD7::StyleColor(RD7Color_Selector));
|
R7Vec4(R7Vec2(sw - 10, slider_pos + 2), R7Vec2(slider_w, slider_rh)),
|
||||||
|
RD7Color_Selector));
|
||||||
}
|
}
|
||||||
|
// Proccess DrawLists
|
||||||
|
for (auto &it : ui7_ctx->cm->background) it->Process();
|
||||||
|
for (auto &it : ui7_ctx->cm->main) it->Process();
|
||||||
|
for (auto &it : ui7_ctx->cm->front) it->Process();
|
||||||
|
ui7_ctx->cm->background.clear();
|
||||||
|
ui7_ctx->cm->main.clear();
|
||||||
|
ui7_ctx->cm->front.clear();
|
||||||
ui7_ctx->cm = nullptr;
|
ui7_ctx->cm = nullptr;
|
||||||
ui7_ctx->in_menu = false;
|
ui7_ctx->in_menu = false;
|
||||||
}
|
}
|
||||||
@ -228,12 +340,6 @@ void UI7CtxCursorMove(R7Vec2 size) {
|
|||||||
ui7_ctx->cm->msr = R7Vec2(ui7_ctx->cm->slc.x, ui7_ctx->cm->slc.y - 10);
|
ui7_ctx->cm->msr = R7Vec2(ui7_ctx->cm->slc.x, ui7_ctx->cm->slc.y - 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI7CtxRegObj(const UI7OBJ &obj) {
|
|
||||||
if (!UI7CtxValidate()) return;
|
|
||||||
if (!ui7_ctx->debugging) return;
|
|
||||||
ui7_ctx->objects.push_back(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
bool InBox(R7Vec2 inpos, R7Vec2 boxpos, R7Vec2 boxsize) {
|
bool InBox(R7Vec2 inpos, R7Vec2 boxpos, R7Vec2 boxsize) {
|
||||||
if ((inpos.x > boxpos.x) && (inpos.y > boxpos.y) &&
|
if ((inpos.x > boxpos.x) && (inpos.y > boxpos.y) &&
|
||||||
@ -265,11 +371,11 @@ void Deinit() {
|
|||||||
void Update() {
|
void Update() {
|
||||||
// Dont do anithing without ctx;
|
// Dont do anithing without ctx;
|
||||||
if (!UI7CtxValidate()) return;
|
if (!UI7CtxValidate()) return;
|
||||||
|
ui7_ctx->debug_calls.clear();
|
||||||
float current = __get_time();
|
float current = __get_time();
|
||||||
ui7_ctx->delta = (current - ui7_ctx->_last) / 1000.f;
|
ui7_ctx->delta = (current - ui7_ctx->_last) / 1000.f;
|
||||||
ui7_ctx->_last = current;
|
ui7_ctx->_last = current;
|
||||||
ui7_ctx->time += ui7_ctx->delta;
|
ui7_ctx->time += ui7_ctx->delta;
|
||||||
if (ui7_ctx->debugging) ui7_ctx->objects.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float GetTime() {
|
float GetTime() {
|
||||||
@ -303,28 +409,24 @@ bool Button(const std::string &label, R7Vec2 size) {
|
|||||||
if (pos.y > 240 ||
|
if (pos.y > 240 ||
|
||||||
(pos.y + size.y < ui7_ctx->cm->tbh - 5 && pb.y > ui7_ctx->cm->tbh))
|
(pos.y + size.y < ui7_ctx->cm->tbh - 5 && pb.y > ui7_ctx->cm->tbh))
|
||||||
return false;
|
return false;
|
||||||
RenderD7::Draw2::Scissor(R7Vec2(0, ui7_ctx->cm->tbh),
|
|
||||||
R7Vec2(rd7i_current_screen ? 400 : 320, 240));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, size), 1));
|
if (ui7_ctx->cm->has_touch) {
|
||||||
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
||||||
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
InBox(RenderD7::Hid::GetLastTouchPosition(), pos, size)) {
|
||||||
InBox(RenderD7::Hid::GetLastTouchPosition(), pos, size)) {
|
btn = RD7Color_ButtonActive;
|
||||||
btn = RD7Color_ButtonActive;
|
ret = true;
|
||||||
ret = true;
|
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held) &&
|
||||||
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held) &&
|
InBox(RenderD7::Hid::GetTouchPosition(), pos, size)) {
|
||||||
InBox(RenderD7::Hid::GetTouchPosition(), pos, size)) {
|
btn = RD7Color_ButtonHovered;
|
||||||
btn = RD7Color_ButtonHovered;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderD7::Draw2::RFS(pos, size, RenderD7::StyleColor(btn));
|
ui7_ctx->cm->main.push_back(DrawCmd::New(R7Vec4(pos, size), btn));
|
||||||
pos = R7Vec2(pos.x + size.x * 0.5f - textdim.x * 0.5,
|
pos = R7Vec2(pos.x + size.x * 0.5f - textdim.x * 0.5,
|
||||||
pos.y + size.y * 0.5f - textdim.y * 0.5);
|
pos.y + size.y * 0.5f - textdim.y * 0.5);
|
||||||
RenderD7::TextColorByBg(btn);
|
ui7_ctx->cm->main.push_back(
|
||||||
RenderD7::Draw2::Text(pos, label);
|
DrawCmd::New(pos, label, RenderD7::ThemeActive()->AutoText(btn)));
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
|
||||||
RenderD7::Draw2::ScissorReset();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,35 +448,34 @@ void Checkbox(const std::string &label, bool &c) {
|
|||||||
if (pos.y > 240 ||
|
if (pos.y > 240 ||
|
||||||
(pos.y + cbs.y < ui7_ctx->cm->tbh - 5 && pb.y > ui7_ctx->cm->tbh))
|
(pos.y + cbs.y < ui7_ctx->cm->tbh - 5 && pb.y > ui7_ctx->cm->tbh))
|
||||||
return;
|
return;
|
||||||
RenderD7::Draw2::Scissor(R7Vec2(0, ui7_ctx->cm->tbh),
|
|
||||||
R7Vec2(rd7i_current_screen ? 400 : 320, 240));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
if (ui7_ctx->cm->has_touch) {
|
||||||
InBox(RenderD7::Hid::GetLastTouchPosition(), pos, inp)) {
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
||||||
bg = RD7Color_FrameBgHovered;
|
InBox(RenderD7::Hid::GetLastTouchPosition(), pos, inp)) {
|
||||||
c = !c;
|
bg = RD7Color_FrameBgHovered;
|
||||||
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held) &&
|
c = !c;
|
||||||
InBox(RenderD7::Hid::GetTouchPosition(), pos, inp)) {
|
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held) &&
|
||||||
bg = RD7Color_FrameBgHovered;
|
InBox(RenderD7::Hid::GetTouchPosition(), pos, inp)) {
|
||||||
|
bg = RD7Color_FrameBgHovered;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderD7::Draw2::RFS(pos, cbs, RenderD7::StyleColor(bg));
|
ui7_ctx->cm->main.push_back(DrawCmd::New(R7Vec4(pos, cbs), bg));
|
||||||
if (c == true) {
|
if (c == true) {
|
||||||
RenderD7::Draw2::RFS(pos + R7Vec2(2, 2), cbs - R7Vec2(4, 4),
|
ui7_ctx->cm->main.push_back(DrawCmd::New(
|
||||||
RenderD7::StyleColor(RD7Color_Checkmark));
|
R7Vec4(pos + R7Vec2(2, 2), cbs - R7Vec2(4, 4)), RD7Color_Checkmark));
|
||||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos + R7Vec2(2, 2), cbs - R7Vec2(4, 4)), 3));
|
|
||||||
}
|
}
|
||||||
RenderD7::Draw2::Text(pos + R7Vec2(cbs.x + 5, 1), label);
|
ui7_ctx->cm->main.push_back(
|
||||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, cbs + R7Vec2(txtdim.x + 5, 0)), 1));
|
DrawCmd::New(pos + R7Vec2(cbs.x + 5, 1), label,
|
||||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, cbs), 2));
|
RenderD7::ThemeActive()->AutoText(RD7Color_Background)));
|
||||||
RenderD7::Draw2::ScissorReset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label(const std::string &label, RD7TextFlags flags) {
|
void Label(const std::string &label, RD7TextFlags flags) {
|
||||||
if (!UI7CtxValidate()) return;
|
if (!UI7CtxValidate()) return;
|
||||||
R7Vec2 textdim = RenderD7::GetTextDimensions(label);
|
R7Vec2 textdim = RenderD7::GetTextDimensions(label);
|
||||||
R7Vec2 pos = GetCursorPos();
|
R7Vec2 pos = GetCursorPos();
|
||||||
|
auto upos = pos;
|
||||||
// Remove some y offset cause texts have some offset
|
// Remove some y offset cause texts have some offset
|
||||||
UI7CtxCursorMove(textdim - R7Vec2(0, 4));
|
UI7CtxCursorMove(textdim - R7Vec2(0, 4));
|
||||||
|
|
||||||
@ -384,28 +485,25 @@ void Label(const std::string &label, RD7TextFlags flags) {
|
|||||||
if (pos.y > 240 ||
|
if (pos.y > 240 ||
|
||||||
(pos.y + textdim.y < ui7_ctx->cm->tbh - 5 && pb.y > ui7_ctx->cm->tbh))
|
(pos.y + textdim.y < ui7_ctx->cm->tbh - 5 && pb.y > ui7_ctx->cm->tbh))
|
||||||
return;
|
return;
|
||||||
RenderD7::Draw2::Scissor(R7Vec2(0, ui7_ctx->cm->tbh),
|
|
||||||
R7Vec2(rd7i_current_screen ? 400 : 320, 240));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float tbh = RenderD7::TextGetSize() * 40;
|
float tbh = RenderD7::TextGetSize() * 40;
|
||||||
if (flags & RD7TextFlags_AlignRight) {
|
auto &list =
|
||||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos - R7Vec2(textdim.x, 0), textdim), 1));
|
(upos.y + textdim.y < tbh) ? ui7_ctx->cm->front : ui7_ctx->cm->main;
|
||||||
} else {
|
|
||||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, textdim), 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderD7::TextColorByBg(
|
list.push_back(DrawCmd::New(
|
||||||
(pos.y + textdim.y < tbh ? RD7Color_Header : RD7Color_Background));
|
pos, label,
|
||||||
RenderD7::Draw2::Text(pos, label, flags);
|
RenderD7::ThemeActive()->AutoText(
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
(upos.y + textdim.y < tbh ? RD7Color_Header : RD7Color_Background)),
|
||||||
RenderD7::Draw2::ScissorReset();
|
flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Progressbar(float value) {
|
void Progressbar(float value) {
|
||||||
if (!UI7CtxValidate()) return;
|
if (!UI7CtxValidate()) return;
|
||||||
R7Vec2 pos = GetCursorPos();
|
R7Vec2 pos = GetCursorPos();
|
||||||
R7Vec2 size = R7Vec2((rd7i_current_screen ? 400 : 320) - (pos.x * 2), 20);
|
R7Vec2 size = R7Vec2((rd7i_current_screen ? 400 : 320) - (pos.x * 2), 20);
|
||||||
|
if (ui7_ctx->cm->show_scroolbar && ui7_ctx->cm->enable_scrolling)
|
||||||
|
size.x -= 16;
|
||||||
UI7CtxCursorMove(size);
|
UI7CtxCursorMove(size);
|
||||||
|
|
||||||
if (ui7_ctx->cm->enable_scrolling) {
|
if (ui7_ctx->cm->enable_scrolling) {
|
||||||
@ -414,18 +512,18 @@ void Progressbar(float value) {
|
|||||||
if (pos.y > 240 ||
|
if (pos.y > 240 ||
|
||||||
(pos.y + size.y < ui7_ctx->cm->tbh - 5 && pb.y > ui7_ctx->cm->tbh))
|
(pos.y + size.y < ui7_ctx->cm->tbh - 5 && pb.y > ui7_ctx->cm->tbh))
|
||||||
return;
|
return;
|
||||||
RenderD7::Draw2::Scissor(R7Vec2(0, ui7_ctx->cm->tbh),
|
|
||||||
R7Vec2(rd7i_current_screen ? 400 : 320, 240));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderD7::Draw2::RFS(pos, size, RenderD7::StyleColor(RD7Color_FrameBg));
|
ui7_ctx->cm->main.push_back(
|
||||||
RenderD7::Draw2::RFS(pos + R7Vec2(2, 2), size - R7Vec2(4, 4),
|
DrawCmd::New(R7Vec4(pos, size), RD7Color_FrameBg));
|
||||||
RenderD7::StyleColor(RD7Color_FrameBgHovered));
|
ui7_ctx->cm->main.push_back(
|
||||||
if (!(value != value) && !(value < 0.0) && !(value > 1.0))
|
DrawCmd::New(R7Vec4(pos + R7Vec2(2, 2), size - R7Vec2(4, 4)),
|
||||||
RenderD7::Draw2::RFS(pos + R7Vec2(2, 2),
|
RD7Color_FrameBgHovered));
|
||||||
R7Vec2((size.x - 4) * value, size.y - 4),
|
if (!(value != value) && !(value < 0.0) && !(value > 1.0)) {
|
||||||
RenderD7::StyleColor(RD7Color_Progressbar));
|
ui7_ctx->cm->main.push_back(DrawCmd::New(
|
||||||
RenderD7::Draw2::ScissorReset();
|
R7Vec4(pos + R7Vec2(2, 2), R7Vec2((size.x - 4) * value, size.y - 4)),
|
||||||
|
RD7Color_Progressbar));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image(RenderD7::Image *img) {
|
void Image(RenderD7::Image *img) {
|
||||||
@ -439,14 +537,9 @@ void Image(RenderD7::Image *img) {
|
|||||||
if (pos.y > 240 || (pos.y + img->get_size().y < ui7_ctx->cm->tbh - 5 &&
|
if (pos.y > 240 || (pos.y + img->get_size().y < ui7_ctx->cm->tbh - 5 &&
|
||||||
pb.y > ui7_ctx->cm->tbh))
|
pb.y > ui7_ctx->cm->tbh))
|
||||||
return;
|
return;
|
||||||
RenderD7::Draw2::Scissor(R7Vec2(0, ui7_ctx->cm->tbh),
|
|
||||||
R7Vec2(rd7i_current_screen ? 400 : 320, 240));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, img->get_size()), 1));
|
|
||||||
|
|
||||||
RenderD7::Draw2::Image(img, pos);
|
RenderD7::Draw2::Image(img, pos);
|
||||||
RenderD7::Draw2::ScissorReset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserList(const std::vector<std::string> &entrys, int &selection,
|
void BrowserList(const std::vector<std::string> &entrys, int &selection,
|
||||||
@ -461,9 +554,9 @@ void BrowserList(const std::vector<std::string> &entrys, int &selection,
|
|||||||
if (size.y == 0) size.y = (max_entrys * 15);
|
if (size.y == 0) size.y = (max_entrys * 15);
|
||||||
UI7CtxCursorMove(size);
|
UI7CtxCursorMove(size);
|
||||||
for (int i = 0; i < max_entrys; i++) {
|
for (int i = 0; i < max_entrys; i++) {
|
||||||
RenderD7::Draw2::RFS(
|
ui7_ctx->cm->main.push_back(
|
||||||
pos + R7Vec2(0, 15 * i), R7Vec2(size.x, 15),
|
DrawCmd::New(R7Vec4(pos + R7Vec2(0, 15 * i), R7Vec2(size.x, 15)),
|
||||||
RenderD7::StyleColor((i % 2) == 0 ? RD7Color_List0 : RD7Color_List1));
|
(i % 2 == 0 ? RD7Color_List0 : RD7Color_List1)));
|
||||||
}
|
}
|
||||||
for (size_t i = 0;
|
for (size_t i = 0;
|
||||||
i < ((entrys.size() < (size_t)max_entrys) ? entrys.size()
|
i < ((entrys.size() < (size_t)max_entrys) ? entrys.size()
|
||||||
@ -473,32 +566,21 @@ void BrowserList(const std::vector<std::string> &entrys, int &selection,
|
|||||||
int list_index =
|
int list_index =
|
||||||
(selection < max_entrys ? i : (i + selection - (max_entrys - 1)));
|
(selection < max_entrys ? i : (i + selection - (max_entrys - 1)));
|
||||||
if (i == (size_t)selindex) {
|
if (i == (size_t)selindex) {
|
||||||
RenderD7::Draw2::RectFilled(
|
ui7_ctx->cm->main.push_back(DrawCmd::New(
|
||||||
pos + R7Vec2(0, 15 * i), R7Vec2(size.x, 15),
|
R7Vec4(pos + R7Vec2(0, 15 * i), R7Vec2(size.x, 15)),
|
||||||
{RenderD7::StyleColor(RD7Color_Selector),
|
(unsigned int)RenderD7::Color::RGBA(RD7Color_Selector)
|
||||||
RenderD7::Color::RGBA(RD7Color_Selector)
|
.fade_to(RD7Color_SelectorFade, std::sin(RenderD7::GetTime()))
|
||||||
.fade_to(RD7Color_SelectorFade, std::sin(RenderD7::GetTime()))
|
.toRGBA()));
|
||||||
.toRGBA(),
|
|
||||||
RenderD7::StyleColor(RD7Color_Selector),
|
|
||||||
RenderD7::Color::RGBA(RD7Color_Selector)
|
|
||||||
.fade_to(RD7Color_SelectorFade, std::sin(RenderD7::GetTime()))
|
|
||||||
.toRGBA()});
|
|
||||||
RenderD7::TextColorByBg(RD7Color_Selector);
|
|
||||||
RenderD7::TextMaxBox(R7Vec2(size.x, 0));
|
|
||||||
RenderD7::Draw2::Text(pos + R7Vec2(5, 15 * i), entrys[list_index],
|
|
||||||
txtflags | RD7TextFlags_Short);
|
|
||||||
RenderD7::TextDefaultBox();
|
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
|
||||||
} else {
|
|
||||||
RenderD7::Ftrace::Beg("app", "short_algo");
|
|
||||||
RenderD7::TextColorByBg(RD7Color_List0);
|
|
||||||
RenderD7::TextMaxBox(R7Vec2(size.x, 0));
|
|
||||||
RenderD7::Draw2::Text(pos + R7Vec2(5, 15 * i), entrys[list_index],
|
|
||||||
txtflags | RD7TextFlags_Short);
|
|
||||||
RenderD7::TextDefaultBox();
|
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
|
||||||
RenderD7::Ftrace::End("app", "short_algo");
|
|
||||||
}
|
}
|
||||||
|
auto cmd =
|
||||||
|
DrawCmd::New(pos + R7Vec2(5, 15 * i), entrys[list_index],
|
||||||
|
RenderD7::ThemeActive()->AutoText(
|
||||||
|
selindex == (int)i
|
||||||
|
? RD7Color_Selector
|
||||||
|
: (i % 2 == 0 ? RD7Color_List0 : RD7Color_List1)),
|
||||||
|
txtflags | RD7TextFlags_Short);
|
||||||
|
cmd->text_box = R7Vec2(size.x, 15);
|
||||||
|
ui7_ctx->cm->main.push_back(cmd);
|
||||||
}
|
}
|
||||||
RenderD7::CustomTextSize(tmp_txt);
|
RenderD7::CustomTextSize(tmp_txt);
|
||||||
}
|
}
|
||||||
@ -523,32 +605,32 @@ void InputText(const std::string &label, std::string &text,
|
|||||||
if (pos.y > 240 ||
|
if (pos.y > 240 ||
|
||||||
(pos.y + cbs.y < ui7_ctx->cm->tbh - 5 && pb.y > ui7_ctx->cm->tbh))
|
(pos.y + cbs.y < ui7_ctx->cm->tbh - 5 && pb.y > ui7_ctx->cm->tbh))
|
||||||
return;
|
return;
|
||||||
RenderD7::Draw2::Scissor(R7Vec2(0, ui7_ctx->cm->tbh),
|
|
||||||
R7Vec2(rd7i_current_screen ? 400 : 320, 240));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
if (ui7_ctx->cm->has_touch) {
|
||||||
InBox(RenderD7::Hid::GetLastTouchPosition(), pos, inp)) {
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
||||||
bg = RD7Color_FrameBgHovered;
|
InBox(RenderD7::Hid::GetLastTouchPosition(), pos, inp)) {
|
||||||
RenderD7::AddOvl(
|
bg = RD7Color_FrameBgHovered;
|
||||||
std::make_unique<RenderD7::Ovl_Keyboard>(text, kbd_state, hint));
|
RenderD7::AddOvl(
|
||||||
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held) &&
|
std::make_unique<RenderD7::Ovl_Keyboard>(text, kbd_state, hint));
|
||||||
InBox(RenderD7::Hid::GetTouchPosition(), pos, inp)) {
|
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held) &&
|
||||||
bg = RD7Color_FrameBgHovered;
|
InBox(RenderD7::Hid::GetTouchPosition(), pos, inp)) {
|
||||||
|
bg = RD7Color_FrameBgHovered;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderD7::Draw2::RFS(pos, cbs, RenderD7::StyleColor(bg));
|
ui7_ctx->cm->main.push_back(DrawCmd::New(R7Vec4(pos, cbs), bg));
|
||||||
RenderD7::TextColorByBg(bg);
|
ui7_ctx->cm->main.push_back(
|
||||||
RenderD7::Draw2::Text(pos + R7Vec2(5, 1), (text != "" ? text : hint));
|
DrawCmd::New(pos + R7Vec2(5, 1), (text != "" ? text : hint),
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
RenderD7::ThemeActive()->AutoText(bg)));
|
||||||
RenderD7::Draw2::Text(pos + R7Vec2(cbs.x + 5, 1), id.Title());
|
ui7_ctx->cm->main.push_back(
|
||||||
RenderD7::Draw2::ScissorReset();
|
DrawCmd::New(pos + R7Vec2(cbs.x + 5, 1), id.Title(),
|
||||||
|
RenderD7::ThemeActive()->AutoText(RD7Color_Background)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BeginMenu(const std::string &title, R7Vec2 size, UI7MenuFlags flags) {
|
bool BeginMenu(const std::string &title, R7Vec2 size, UI7MenuFlags flags) {
|
||||||
if (!UI7CtxValidate()) return false;
|
if (!UI7CtxValidate()) return false;
|
||||||
if (UI7CtxInMenu()) return false;
|
if (UI7CtxInMenu()) return false;
|
||||||
RenderD7::Draw2::ScissorReset();
|
|
||||||
auto id = UI7ID(title);
|
auto id = UI7ID(title);
|
||||||
auto ret = UI7CtxBeginMenu(title);
|
auto ret = UI7CtxBeginMenu(title);
|
||||||
if (!ret) return ret;
|
if (!ret) return ret;
|
||||||
@ -563,7 +645,10 @@ bool BeginMenu(const std::string &title, R7Vec2 size, UI7MenuFlags flags) {
|
|||||||
float tbh = RenderD7::TextGetSize() * 40;
|
float tbh = RenderD7::TextGetSize() * 40;
|
||||||
ui7_ctx->cm->tbh = tbh;
|
ui7_ctx->cm->tbh = tbh;
|
||||||
|
|
||||||
if (flags & UI7MenuFlags_NoTitlebar) titlebar = false;
|
if (flags & UI7MenuFlags_NoTitlebar) {
|
||||||
|
titlebar = false;
|
||||||
|
ui7_ctx->cm->tbh = 0.f;
|
||||||
|
}
|
||||||
if (flags & UI7MenuFlags_TitleMid) txtflags = RD7TextFlags_AlignMid;
|
if (flags & UI7MenuFlags_TitleMid) txtflags = RD7TextFlags_AlignMid;
|
||||||
ui7_ctx->cm->enable_scrolling = (flags & UI7MenuFlags_Scrolling);
|
ui7_ctx->cm->enable_scrolling = (flags & UI7MenuFlags_Scrolling);
|
||||||
if (ui7_ctx->cm->enable_scrolling && !rd7i_current_screen) {
|
if (ui7_ctx->cm->enable_scrolling && !rd7i_current_screen) {
|
||||||
@ -592,32 +677,33 @@ bool BeginMenu(const std::string &title, R7Vec2 size, UI7MenuFlags flags) {
|
|||||||
ui7_ctx->cm->scrolling_offset > ui7_ctx->cm->ms.y - 200) {
|
ui7_ctx->cm->scrolling_offset > ui7_ctx->cm->ms.y - 200) {
|
||||||
ui7_ctx->cm->scrolling_mod = 0.f;
|
ui7_ctx->cm->scrolling_mod = 0.f;
|
||||||
}
|
}
|
||||||
|
if (ui7_ctx->cm->has_touch) {
|
||||||
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Down)) {
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Down)) {
|
||||||
// Set the mdp Value as Start Pos
|
// Set the mdp Value as Start Pos
|
||||||
ui7_ctx->cm->mdp = RenderD7::Hid::GetTouchPosition();
|
ui7_ctx->cm->mdp = RenderD7::Hid::GetTouchPosition();
|
||||||
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up)) {
|
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up)) {
|
||||||
// 0 out the start pos
|
// 0 out the start pos
|
||||||
ui7_ctx->cm->mdp = R7Vec2();
|
ui7_ctx->cm->mdp = R7Vec2();
|
||||||
}
|
}
|
||||||
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held)) {
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held)) {
|
||||||
// Set modifier
|
// Set modifier
|
||||||
auto np = RenderD7::Hid::GetTouchPosition();
|
auto np = RenderD7::Hid::GetTouchPosition();
|
||||||
// Check if and do nothing if the scrolling ofset goes out of screen
|
// Check if and do nothing if the scrolling ofset goes out of screen
|
||||||
if (ui7_ctx->cm->scrolling_offset < ui7_ctx->cm->ms.y - 200 &&
|
if (ui7_ctx->cm->scrolling_offset < ui7_ctx->cm->ms.y - 200 &&
|
||||||
ui7_ctx->cm->scrolling_offset > -40) {
|
ui7_ctx->cm->scrolling_offset > -40) {
|
||||||
float cursor_mod = (ui7_ctx->cm->mdp.y - np.y);
|
float cursor_mod = (ui7_ctx->cm->mdp.y - np.y);
|
||||||
if (ui7_ctx->cm->scrolling_mod <= 4.f &&
|
if (ui7_ctx->cm->scrolling_mod <= 4.f &&
|
||||||
ui7_ctx->cm->scrolling_mod >= -4 && cursor_mod != 0.0f) {
|
ui7_ctx->cm->scrolling_mod >= -4 && cursor_mod != 0.0f) {
|
||||||
if (cursor_mod > 0) {
|
if (cursor_mod > 0) {
|
||||||
ui7_ctx->cm->scrolling_mod = cursor_mod;
|
ui7_ctx->cm->scrolling_mod = cursor_mod;
|
||||||
} else {
|
} else {
|
||||||
ui7_ctx->cm->scrolling_mod = cursor_mod;
|
ui7_ctx->cm->scrolling_mod = cursor_mod;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Update Start pos
|
||||||
|
ui7_ctx->cm->mdp = np;
|
||||||
}
|
}
|
||||||
// Update Start pos
|
|
||||||
ui7_ctx->cm->mdp = np;
|
|
||||||
}
|
}
|
||||||
// New Scrolling efect
|
// New Scrolling efect
|
||||||
if (ui7_ctx->cm->scrolling_mod != 0)
|
if (ui7_ctx->cm->scrolling_mod != 0)
|
||||||
@ -639,28 +725,23 @@ bool BeginMenu(const std::string &title, R7Vec2 size, UI7MenuFlags flags) {
|
|||||||
ui7_ctx->cm->scrolling_offset = 0.f;
|
ui7_ctx->cm->scrolling_offset = 0.f;
|
||||||
ui7_ctx->cm->scrolling_mod = 0.f;
|
ui7_ctx->cm->scrolling_mod = 0.f;
|
||||||
}
|
}
|
||||||
RenderD7::Draw2::RFS(R7Vec2(0, 0), size,
|
|
||||||
RenderD7::StyleColor(RD7Color_Background));
|
ui7_ctx->cm->background.push_back(
|
||||||
|
DrawCmd::New(R7Vec4(R7Vec2(), size), RD7Color_Background));
|
||||||
if (titlebar) {
|
if (titlebar) {
|
||||||
RenderD7::Draw2::ScissorReset();
|
ui7_ctx->cm->front.push_back(
|
||||||
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(size.x, tbh),
|
DrawCmd::New(R7Vec4(R7Vec2(), R7Vec2(size.x, tbh)), RD7Color_Header));
|
||||||
RenderD7::StyleColor(RD7Color_Header));
|
ui7_ctx->cm->front.push_back(DrawCmd::New(
|
||||||
RenderD7::TextColorByBg(RD7Color_Header);
|
R7Vec2(5, 2), id.Title(),
|
||||||
RenderD7::Draw2::Text(R7Vec2(5, 2), id.Title(), txtflags);
|
RenderD7::ThemeActive()->AutoText(RD7Color_Header), txtflags));
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCursorPos(R7Vec2(5, tbh + 5));
|
SetCursorPos(R7Vec2(5, ui7_ctx->cm->tbh + 5));
|
||||||
UI7CtxRegObj(UI7OBJ(R7Vec4(R7Vec2(), size), 0));
|
|
||||||
if (titlebar) UI7CtxRegObj(UI7OBJ(R7Vec4(R7Vec2(), R7Vec2(size.x, tbh)), 1));
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndMenu() {
|
void EndMenu() { UI7CtxEndMenu(); }
|
||||||
RenderD7::Draw2::ScissorReset();
|
|
||||||
UI7CtxEndMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Grid(const std::string &name, const R7Vec2 &size, const R7Vec2 &entry_size,
|
void Grid(const std::string &name, const R7Vec2 &size, const R7Vec2 &entry_size,
|
||||||
void (*display_func)(void *, R7Vec2), void **data_array,
|
void (*display_func)(void *, R7Vec2), void **data_array,
|
||||||
@ -671,7 +752,6 @@ void Grid(const std::string &name, const R7Vec2 &size, const R7Vec2 &entry_size,
|
|||||||
R7Vec2 pos = GetCursorPos();
|
R7Vec2 pos = GetCursorPos();
|
||||||
R7Vec2 cpos(pos);
|
R7Vec2 cpos(pos);
|
||||||
|
|
||||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, size), 1));
|
|
||||||
int neh = std::floor(size.x / (entry_size.x + 4));
|
int neh = std::floor(size.x / (entry_size.x + 4));
|
||||||
int nev = std::floor(size.y / (entry_size.y + 4));
|
int nev = std::floor(size.y / (entry_size.y + 4));
|
||||||
|
|
||||||
@ -688,7 +768,6 @@ void Grid(const std::string &name, const R7Vec2 &size, const R7Vec2 &entry_size,
|
|||||||
pos += igoff;
|
pos += igoff;
|
||||||
for (size_t i = 0; i < num_entrys; i++) {
|
for (size_t i = 0; i < num_entrys; i++) {
|
||||||
display_func(data_array[i], pos);
|
display_func(data_array[i], pos);
|
||||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, entry_size), 2));
|
|
||||||
if (ui7_ctx->debugging)
|
if (ui7_ctx->debugging)
|
||||||
RenderD7::Draw2::Text(pos + R7Vec2(4, 4), std::to_string(i));
|
RenderD7::Draw2::Text(pos + R7Vec2(4, 4), std::to_string(i));
|
||||||
if (pos.x + (entry_size.x * 2) > (cpos.x + size.x) &&
|
if (pos.x + (entry_size.x * 2) > (cpos.x + size.x) &&
|
||||||
@ -705,6 +784,217 @@ void Grid(const std::string &name, const R7Vec2 &size, const R7Vec2 &entry_size,
|
|||||||
UI7CtxCursorMove(size);
|
UI7CtxCursorMove(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColorSelector(const std::string &label, unsigned int &color) {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
float sv = (RenderD7::TextGetSize() * 40) * 0.9;
|
||||||
|
R7Vec2 cbs = R7Vec2(sv, sv);
|
||||||
|
R7Vec2 txtdim = RenderD7::GetTextDimensions(label);
|
||||||
|
R7Vec2 inp = cbs + R7Vec2(txtdim.x + 5, 0);
|
||||||
|
auto outline =
|
||||||
|
RenderD7::Color::RGBA(color).is_light() ? 0xff000000 : 0xffffffff;
|
||||||
|
auto id = UI7ID(label);
|
||||||
|
|
||||||
|
R7Vec2 pos = GetCursorPos();
|
||||||
|
UI7CtxCursorMove(inp);
|
||||||
|
|
||||||
|
if (ui7_ctx->cm->enable_scrolling) {
|
||||||
|
R7Vec2 pb = pos;
|
||||||
|
pos -= R7Vec2(0, ui7_ctx->cm->scrolling_offset);
|
||||||
|
if (pos.y > 240 ||
|
||||||
|
(pos.y + cbs.y < ui7_ctx->cm->tbh - 5 && pb.y > ui7_ctx->cm->tbh))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ui7_ctx->cm->has_touch) {
|
||||||
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
||||||
|
InBox(RenderD7::Hid::GetLastTouchPosition(), pos, inp)) {
|
||||||
|
ui7_ctx->cm->submenu = id.ID();
|
||||||
|
// Nullify scrolling mod to fix freeze
|
||||||
|
ui7_ctx->cm->scrolling_mod = 0.0f;
|
||||||
|
RenderD7::Hid::Lock();
|
||||||
|
RenderD7::Hid::Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ui7_ctx->cm->submenu == id.ID()) {
|
||||||
|
// Base
|
||||||
|
auto clr = RenderD7::Color::RGBA(color);
|
||||||
|
// Keyboard logic
|
||||||
|
static bool inkbd;
|
||||||
|
static std::string kbd_txt;
|
||||||
|
static RD7KeyboardState kbd_state;
|
||||||
|
static int kbd_rgba = 0;
|
||||||
|
if (kbd_state == RD7KeyboardState_Confirm) {
|
||||||
|
int num = std::atoi(kbd_txt.c_str());
|
||||||
|
if (num < 0 || num > 255) {
|
||||||
|
RenderD7::PushMessage("UI7", "Error: Value must\nbe 0 - 255!");
|
||||||
|
} else {
|
||||||
|
if (kbd_rgba == 1) {
|
||||||
|
clr.m_r = num;
|
||||||
|
} else if (kbd_rgba == 2) {
|
||||||
|
clr.m_g = num;
|
||||||
|
} else if (kbd_rgba == 3) {
|
||||||
|
clr.m_b = num;
|
||||||
|
} else if (kbd_rgba == 4) {
|
||||||
|
clr.m_a = num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (kbd_state) {
|
||||||
|
inkbd = false;
|
||||||
|
kbd_state = RD7KeyboardState_None;
|
||||||
|
kbd_txt = "";
|
||||||
|
kbd_rgba = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inkbd) RenderD7::Hid::Unlock();
|
||||||
|
bool isunlock = false;
|
||||||
|
R7Vec2 npos = pos;
|
||||||
|
if (npos.y < ui7_ctx->cm->tbh + 2) npos.y = ui7_ctx->cm->tbh;
|
||||||
|
if (npos.y + 97 > 235) npos.y = 137;
|
||||||
|
// Input
|
||||||
|
if (ui7_ctx->cm->has_touch) {
|
||||||
|
auto ltp = RenderD7::Hid::GetLastTouchPosition();
|
||||||
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
||||||
|
(InBox(ltp, npos + R7Vec2(2, 2), cbs) ||
|
||||||
|
!InBox(ltp, npos, R7Vec2(107, 97)))) {
|
||||||
|
ui7_ctx->cm->submenu = "";
|
||||||
|
isunlock = true;
|
||||||
|
} else if (RenderD7::Hid::IsEvent("cancel", RenderD7::Hid::Down)) {
|
||||||
|
ui7_ctx->cm->submenu = "";
|
||||||
|
isunlock = true;
|
||||||
|
RenderD7::Hid::Clear();
|
||||||
|
}
|
||||||
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up)) {
|
||||||
|
if (InBox(ltp, npos + R7Vec2(2, cbs.y * 3 + 4), R7Vec2(50, cbs.y))) {
|
||||||
|
inkbd = true;
|
||||||
|
kbd_txt = std::to_string(clr.m_r);
|
||||||
|
kbd_rgba = 1;
|
||||||
|
RenderD7::AddOvl(std::make_unique<RenderD7::Ovl_Keyboard>(
|
||||||
|
kbd_txt, kbd_state, "", RD7Keyboard_Numpad));
|
||||||
|
} else if (InBox(ltp, npos + R7Vec2(54, cbs.y * 3 + 4),
|
||||||
|
R7Vec2(50, cbs.y))) {
|
||||||
|
inkbd = true;
|
||||||
|
kbd_txt = std::to_string(clr.m_g);
|
||||||
|
kbd_rgba = 2;
|
||||||
|
RenderD7::AddOvl(std::make_unique<RenderD7::Ovl_Keyboard>(
|
||||||
|
kbd_txt, kbd_state, "", RD7Keyboard_Numpad));
|
||||||
|
} else if (InBox(ltp, npos + R7Vec2(2, cbs.y * 4 + 4),
|
||||||
|
R7Vec2(50, cbs.y))) {
|
||||||
|
inkbd = true;
|
||||||
|
kbd_txt = std::to_string(clr.m_b);
|
||||||
|
kbd_rgba = 3;
|
||||||
|
RenderD7::AddOvl(std::make_unique<RenderD7::Ovl_Keyboard>(
|
||||||
|
kbd_txt, kbd_state, "", RD7Keyboard_Numpad));
|
||||||
|
} else if (InBox(ltp, npos + R7Vec2(54, cbs.y * 4 + 4),
|
||||||
|
R7Vec2(50, cbs.y))) {
|
||||||
|
inkbd = true;
|
||||||
|
kbd_txt = std::to_string(clr.m_a);
|
||||||
|
kbd_rgba = 4;
|
||||||
|
RenderD7::AddOvl(std::make_unique<RenderD7::Ovl_Keyboard>(
|
||||||
|
kbd_txt, kbd_state, "", RD7Keyboard_Numpad));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
color = clr.toRGBA();
|
||||||
|
}
|
||||||
|
if (!isunlock && !inkbd) RenderD7::Hid::Lock();
|
||||||
|
// Draw Frame
|
||||||
|
ui7_ctx->cm->front.push_back(
|
||||||
|
DrawCmd::New(R7Vec4(npos.x, npos.y, 107, 97), RD7Color_FrameBg));
|
||||||
|
// Draw Color Button
|
||||||
|
ui7_ctx->cm->front.push_back(
|
||||||
|
DrawCmd::New(R7Vec4(npos + R7Vec2(2, 2), cbs), outline));
|
||||||
|
ui7_ctx->cm->front.push_back(
|
||||||
|
DrawCmd::New(R7Vec4(npos + R7Vec2(4, 4), cbs - R7Vec2(4, 4)), color));
|
||||||
|
// Setup TextCommand with Short flag
|
||||||
|
auto cmd =
|
||||||
|
DrawCmd::New(npos + R7Vec2(cbs.x + 7, 1), label,
|
||||||
|
RenderD7::ThemeActive()->AutoText(RD7Color_FrameBg));
|
||||||
|
cmd->text_box = R7Vec2(93 - cbs.x - 5, 0);
|
||||||
|
cmd->text_flags |= RD7TextFlags_Short;
|
||||||
|
ui7_ctx->cm->front.push_back(cmd);
|
||||||
|
// Add luminance text
|
||||||
|
ui7_ctx->cm->front.push_back(DrawCmd::New(
|
||||||
|
npos + R7Vec2(2, cbs.y + 4), "lum: " + std::to_string(clr.luminance()),
|
||||||
|
RenderD7::ThemeActive()->AutoText(RD7Color_FrameBg)));
|
||||||
|
// Add Hex value
|
||||||
|
ui7_ctx->cm->front.push_back(
|
||||||
|
DrawCmd::New(npos + R7Vec2(2, cbs.y * 2 + 4),
|
||||||
|
"hex: " + RenderD7::Color::RGBA2Hex(color),
|
||||||
|
RenderD7::ThemeActive()->AutoText(RD7Color_FrameBg)));
|
||||||
|
// Red
|
||||||
|
{
|
||||||
|
ui7_ctx->cm->front.push_back(DrawCmd::New(
|
||||||
|
R7Vec4(npos + R7Vec2(2, cbs.y * 3 + 4), R7Vec2(50, cbs.y)),
|
||||||
|
RD7Color_FrameBgHovered));
|
||||||
|
ui7_ctx->cm->front.push_back(
|
||||||
|
DrawCmd::New(R7Vec4(npos + R7Vec2(2, cbs.y * 3 + 4),
|
||||||
|
R7Vec2(50 * ((float)clr.m_r / 255.f), cbs.y)),
|
||||||
|
0xff0000ff));
|
||||||
|
|
||||||
|
auto ncmd = DrawCmd::New(npos + R7Vec2(2, cbs.y * 3 + 4),
|
||||||
|
std::to_string(clr.m_r), RD7Color_Text);
|
||||||
|
ncmd->text_flags |= RD7TextFlags_AlignMid;
|
||||||
|
ncmd->text_box = R7Vec2(50, 0);
|
||||||
|
ui7_ctx->cm->front.push_back(ncmd);
|
||||||
|
}
|
||||||
|
// Green
|
||||||
|
{
|
||||||
|
ui7_ctx->cm->front.push_back(DrawCmd::New(
|
||||||
|
R7Vec4(npos + R7Vec2(54, cbs.y * 3 + 4), R7Vec2(50, cbs.y)),
|
||||||
|
RD7Color_FrameBgHovered));
|
||||||
|
ui7_ctx->cm->front.push_back(
|
||||||
|
DrawCmd::New(R7Vec4(npos + R7Vec2(54, cbs.y * 3 + 4),
|
||||||
|
R7Vec2(50 * ((float)clr.m_g / 255.f), cbs.y)),
|
||||||
|
0xff00ff00));
|
||||||
|
auto ncmd = DrawCmd::New(npos + R7Vec2(54, cbs.y * 3 + 4),
|
||||||
|
std::to_string(clr.m_g), RD7Color_Text);
|
||||||
|
ncmd->text_flags |= RD7TextFlags_AlignMid;
|
||||||
|
ncmd->text_box = R7Vec2(50, 0);
|
||||||
|
ui7_ctx->cm->front.push_back(ncmd);
|
||||||
|
}
|
||||||
|
// Blue
|
||||||
|
{
|
||||||
|
ui7_ctx->cm->front.push_back(DrawCmd::New(
|
||||||
|
R7Vec4(npos + R7Vec2(2, cbs.y * 4 + 4), R7Vec2(50, cbs.y)),
|
||||||
|
RD7Color_FrameBgHovered));
|
||||||
|
ui7_ctx->cm->front.push_back(
|
||||||
|
DrawCmd::New(R7Vec4(npos + R7Vec2(2, cbs.y * 4 + 4),
|
||||||
|
R7Vec2(50 * ((float)clr.m_b / 255.f), cbs.y)),
|
||||||
|
0xffff0000));
|
||||||
|
|
||||||
|
auto ncmd = DrawCmd::New(npos + R7Vec2(2, cbs.y * 4 + 4),
|
||||||
|
std::to_string(clr.m_b), RD7Color_Text);
|
||||||
|
ncmd->text_flags |= RD7TextFlags_AlignMid;
|
||||||
|
ncmd->text_box = R7Vec2(50, 0);
|
||||||
|
ui7_ctx->cm->front.push_back(ncmd);
|
||||||
|
}
|
||||||
|
// Alpha
|
||||||
|
{
|
||||||
|
ui7_ctx->cm->front.push_back(DrawCmd::New(
|
||||||
|
R7Vec4(npos + R7Vec2(54, cbs.y * 4 + 4), R7Vec2(50, cbs.y)),
|
||||||
|
RD7Color_FrameBgHovered));
|
||||||
|
ui7_ctx->cm->front.push_back(
|
||||||
|
DrawCmd::New(R7Vec4(npos + R7Vec2(54, cbs.y * 4 + 4),
|
||||||
|
R7Vec2(50 * ((float)clr.m_a / 255.f), cbs.y)),
|
||||||
|
0xffffffff));
|
||||||
|
|
||||||
|
auto ncmd = DrawCmd::New(npos + R7Vec2(54, cbs.y * 4 + 4),
|
||||||
|
std::to_string(clr.m_a), RD7Color_Text);
|
||||||
|
ncmd->text_flags |= RD7TextFlags_AlignMid;
|
||||||
|
ncmd->text_box = R7Vec2(50, 0);
|
||||||
|
ui7_ctx->cm->front.push_back(ncmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui7_ctx->cm->main.push_back(DrawCmd::New(R7Vec4(pos, cbs), outline));
|
||||||
|
ui7_ctx->cm->main.push_back(
|
||||||
|
DrawCmd::New(R7Vec4(pos + R7Vec2(2, 2), cbs - R7Vec2(4, 4)), color));
|
||||||
|
ui7_ctx->cm->main.push_back(
|
||||||
|
DrawCmd::New(pos + R7Vec2(cbs.x + 5, 1), label,
|
||||||
|
RenderD7::ThemeActive()->AutoText(RD7Color_Background)));
|
||||||
|
}
|
||||||
|
|
||||||
bool BeginTree(const std::string &text) {
|
bool BeginTree(const std::string &text) {
|
||||||
// TODO
|
// TODO
|
||||||
return false;
|
return false;
|
||||||
@ -742,8 +1032,8 @@ void SameLine() {
|
|||||||
void Debug() {
|
void Debug() {
|
||||||
if (!UI7CtxValidate()) return;
|
if (!UI7CtxValidate()) return;
|
||||||
if (ui7_ctx->debugging) {
|
if (ui7_ctx->debugging) {
|
||||||
for (size_t i = 0; i < ui7_ctx->objects.size(); i++) {
|
for (auto &it : ui7_ctx->debug_calls) {
|
||||||
ui7_ctx->objects[i].Debug();
|
it->Process();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ float rd7_draw2_tsm = 1.2f;
|
|||||||
bool rd7i_amdt = false;
|
bool rd7i_amdt = false;
|
||||||
void *rd7i_soc_buf = nullptr;
|
void *rd7i_soc_buf = nullptr;
|
||||||
bool rd7i_is_am_init = false;
|
bool rd7i_is_am_init = false;
|
||||||
|
RenderD7::Theme::Ref rd7i_active_theme;
|
||||||
|
|
||||||
/// Global ///
|
/// Global ///
|
||||||
// Outdated HidApi (HidV2Patched)
|
// Outdated HidApi (HidV2Patched)
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <renderd7/Hid.hpp> // Integate HidApi
|
#include <renderd7/Hid.hpp> // Integate HidApi
|
||||||
#include <renderd7/Message.hpp>
|
#include <renderd7/Message.hpp>
|
||||||
#include <renderd7/Overlays.hpp>
|
#include <renderd7/Overlays.hpp>
|
||||||
|
#include <renderd7/ThemeEditor.hpp>
|
||||||
#include <renderd7/UI7.hpp>
|
#include <renderd7/UI7.hpp>
|
||||||
#include <renderd7/log.hpp>
|
#include <renderd7/log.hpp>
|
||||||
#include <renderd7/renderd7.hpp>
|
#include <renderd7/renderd7.hpp>
|
||||||
@ -214,7 +215,7 @@ void rd7i_init_theme() {
|
|||||||
|
|
||||||
if (!RenderD7::FS::FileExist(path + "/renderd7.theme") || renew) {
|
if (!RenderD7::FS::FileExist(path + "/renderd7.theme") || renew) {
|
||||||
rd7i_amdt = true;
|
rd7i_amdt = true;
|
||||||
RenderD7::ThemeSave(path + "/renderd7.theme");
|
RenderD7::ThemeActive()->Save(path + "/renderd7.theme");
|
||||||
rd7i_amdt = false;
|
rd7i_amdt = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,6 +348,9 @@ Result RenderD7::Init::Main(std::string app_name) {
|
|||||||
atexit(aptExit);
|
atexit(aptExit);
|
||||||
romfsInit();
|
romfsInit();
|
||||||
|
|
||||||
|
rd7i_active_theme = Theme::New();
|
||||||
|
rd7i_active_theme->Default();
|
||||||
|
|
||||||
auto ret = rd7i_soc_init();
|
auto ret = rd7i_soc_init();
|
||||||
if (ret) {
|
if (ret) {
|
||||||
RenderD7::PushMessage("RenderD7", "Failed to\nInit Soc!");
|
RenderD7::PushMessage("RenderD7", "Failed to\nInit Soc!");
|
||||||
@ -393,6 +397,9 @@ Result RenderD7::Init::Minimal(std::string app_name) {
|
|||||||
atexit(gfxExit);
|
atexit(gfxExit);
|
||||||
romfsInit();
|
romfsInit();
|
||||||
|
|
||||||
|
rd7i_active_theme = Theme::New();
|
||||||
|
rd7i_active_theme->Default();
|
||||||
|
|
||||||
auto ret = rd7i_soc_init();
|
auto ret = rd7i_soc_init();
|
||||||
if (ret) {
|
if (ret) {
|
||||||
RenderD7::PushMessage("RenderD7", "Failed to\nInit Soc!");
|
RenderD7::PushMessage("RenderD7", "Failed to\nInit Soc!");
|
||||||
@ -561,6 +568,9 @@ void RenderD7::RSettings::Draw(void) const {
|
|||||||
if (UI7::Button("IDB")) {
|
if (UI7::Button("IDB")) {
|
||||||
shared_request[0x00000001] = RIDB;
|
shared_request[0x00000001] = RIDB;
|
||||||
}
|
}
|
||||||
|
if (UI7::Button("ThemeEditor")) {
|
||||||
|
RenderD7::LoadThemeEditor();
|
||||||
|
}
|
||||||
if (UI7::Button("Back")) {
|
if (UI7::Button("Back")) {
|
||||||
shared_request[0x00000002] = 1U;
|
shared_request[0x00000002] = 1U;
|
||||||
}
|
}
|
||||||
@ -600,38 +610,38 @@ void RenderD7::RSettings::Draw(void) const {
|
|||||||
} else if (m_state == RFTRACE) {
|
} else if (m_state == RFTRACE) {
|
||||||
RenderD7::OnScreen(Top);
|
RenderD7::OnScreen(Top);
|
||||||
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(400, 240),
|
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(400, 240),
|
||||||
RenderD7::StyleColor(RD7Color_Background));
|
RenderD7::ThemeActive()->Get(RD7Color_Background));
|
||||||
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(400, 20),
|
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(400, 20),
|
||||||
RenderD7::StyleColor(RD7Color_Header));
|
RenderD7::ThemeActive()->Get(RD7Color_Header));
|
||||||
RenderD7::TextColorByBg(RD7Color_Header);
|
RenderD7::ThemeActive()->TextBy(RD7Color_Header);
|
||||||
RenderD7::Draw2::Text(R7Vec2(5, 2), "RenderD7 -> FTrace");
|
RenderD7::Draw2::Text(R7Vec2(5, 2), "RenderD7 -> FTrace");
|
||||||
RenderD7::Draw2::Text(R7Vec2(395, 2), RENDERD7VSTRING,
|
RenderD7::Draw2::Text(R7Vec2(395, 2), RENDERD7VSTRING,
|
||||||
RD7TextFlags_AlignRight);
|
RD7TextFlags_AlignRight);
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
RenderD7::ThemeActive()->Undo();
|
||||||
RenderD7::Draw2::RFS(R7Vec2(0, 220), R7Vec2(400, 20),
|
RenderD7::Draw2::RFS(R7Vec2(0, 220), R7Vec2(400, 20),
|
||||||
RenderD7::StyleColor(RD7Color_Header));
|
RenderD7::ThemeActive()->Get(RD7Color_Header));
|
||||||
RenderD7::TextColorByBg(RD7Color_Header);
|
RenderD7::ThemeActive()->TextBy(RD7Color_Header);
|
||||||
RenderD7::Draw2::Text(
|
RenderD7::Draw2::Text(
|
||||||
R7Vec2(5, 222),
|
R7Vec2(5, 222),
|
||||||
"Traces: " + std::to_string(ftrace_index + 1) + "/" +
|
"Traces: " + std::to_string(ftrace_index + 1) + "/" +
|
||||||
std::to_string(RenderD7::Ftrace::rd7_traces.size()));
|
std::to_string(RenderD7::Ftrace::rd7_traces.size()));
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
RenderD7::ThemeActive()->Undo();
|
||||||
RenderD7::Draw2::RFS(R7Vec2(0, 20), R7Vec2(400, 20),
|
RenderD7::Draw2::RFS(R7Vec2(0, 20), R7Vec2(400, 20),
|
||||||
RenderD7::StyleColor(RD7Color_TextDisabled));
|
RenderD7::ThemeActive()->Get(RD7Color_TextDisabled));
|
||||||
RenderD7::TextColorByBg(RD7Color_TextDisabled);
|
RenderD7::ThemeActive()->TextBy(RD7Color_TextDisabled);
|
||||||
RenderD7::Draw2::Text(R7Vec2(5, 22), "Function:");
|
RenderD7::Draw2::Text(R7Vec2(5, 22), "Function:");
|
||||||
RenderD7::Draw2::Text(R7Vec2(395, 22),
|
RenderD7::Draw2::Text(R7Vec2(395, 22),
|
||||||
"Time (ms):", RD7TextFlags_AlignRight);
|
"Time (ms):", RD7TextFlags_AlignRight);
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
RenderD7::ThemeActive()->Undo();
|
||||||
|
|
||||||
// List Bg
|
// List Bg
|
||||||
for (int i = 0; i < 12; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
if ((i % 2 == 0))
|
if ((i % 2 == 0))
|
||||||
RenderD7::Draw2::RFS(R7Vec2(0, 40 + (i)*15), R7Vec2(400, 15),
|
RenderD7::Draw2::RFS(R7Vec2(0, 40 + (i) * 15), R7Vec2(400, 15),
|
||||||
RenderD7::StyleColor(RD7Color_List0));
|
RenderD7::ThemeActive()->Get(RD7Color_List0));
|
||||||
else
|
else
|
||||||
RenderD7::Draw2::RFS(R7Vec2(0, 40 + (i)*15), R7Vec2(400, 15),
|
RenderD7::Draw2::RFS(R7Vec2(0, 40 + (i) * 15), R7Vec2(400, 15),
|
||||||
RenderD7::StyleColor(RD7Color_List1));
|
RenderD7::ThemeActive()->Get(RD7Color_List1));
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderD7::Ftrace::Beg("rd7ft", "display_traces");
|
RenderD7::Ftrace::Beg("rd7ft", "display_traces");
|
||||||
@ -647,24 +657,24 @@ void RenderD7::RSettings::Draw(void) const {
|
|||||||
_fkey__ = it->first;
|
_fkey__ = it->first;
|
||||||
RenderD7::Draw2::RFS(R7Vec2(0, 40 + (ix - start_index) * 15),
|
RenderD7::Draw2::RFS(R7Vec2(0, 40 + (ix - start_index) * 15),
|
||||||
R7Vec2(400, 15),
|
R7Vec2(400, 15),
|
||||||
RenderD7::StyleColor(RD7Color_Selector));
|
RenderD7::ThemeActive()->Get(RD7Color_Selector));
|
||||||
RenderD7::TextColorByBg(RD7Color_Header);
|
RenderD7::ThemeActive()->TextBy(RD7Color_Header);
|
||||||
RenderD7::Draw2::Text(R7Vec2(5, 40 + (ix - start_index) * 15),
|
RenderD7::Draw2::Text(R7Vec2(5, 40 + (ix - start_index) * 15),
|
||||||
it->second.func_name);
|
it->second.func_name);
|
||||||
RenderD7::Draw2::Text(R7Vec2(395, 40 + (ix - start_index) * 15),
|
RenderD7::Draw2::Text(R7Vec2(395, 40 + (ix - start_index) * 15),
|
||||||
RenderD7::MsTimeFmt(it->second.time_of),
|
RenderD7::MsTimeFmt(it->second.time_of),
|
||||||
RD7TextFlags_AlignRight);
|
RD7TextFlags_AlignRight);
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
RenderD7::ThemeActive()->Undo();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Use List 0 cause no reference for screenpos
|
// Use List 0 cause no reference for screenpos
|
||||||
RenderD7::TextColorByBg(RD7Color_List0);
|
RenderD7::ThemeActive()->TextBy(RD7Color_List0);
|
||||||
RenderD7::Draw2::Text(R7Vec2(5, 40 + (ix - start_index) * 15),
|
RenderD7::Draw2::Text(R7Vec2(5, 40 + (ix - start_index) * 15),
|
||||||
it->second.func_name);
|
it->second.func_name);
|
||||||
RenderD7::Draw2::Text(R7Vec2(395, 40 + (ix - start_index) * 15),
|
RenderD7::Draw2::Text(R7Vec2(395, 40 + (ix - start_index) * 15),
|
||||||
RenderD7::MsTimeFmt(it->second.time_of),
|
RenderD7::MsTimeFmt(it->second.time_of),
|
||||||
RD7TextFlags_AlignRight);
|
RD7TextFlags_AlignRight);
|
||||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
RenderD7::ThemeActive()->Undo();
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
++ix;
|
++ix;
|
||||||
@ -705,6 +715,9 @@ void RenderD7::RSettings::Draw(void) const {
|
|||||||
UI7::Label(
|
UI7::Label(
|
||||||
"Touch Last Pos: " + std::to_string(Hid::GetLastTouchPosition().x) +
|
"Touch Last Pos: " + std::to_string(Hid::GetLastTouchPosition().x) +
|
||||||
", " + std::to_string(Hid::GetLastTouchPosition().y));
|
", " + std::to_string(Hid::GetLastTouchPosition().y));
|
||||||
|
UI7::Label(
|
||||||
|
"Touch Down Pos: " + std::to_string(Hid::GetTouchDownPosition().x) +
|
||||||
|
", " + std::to_string(Hid::GetTouchDownPosition().y));
|
||||||
UI7::EndMenu();
|
UI7::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -834,6 +847,10 @@ void RenderD7::LoadSettings() {
|
|||||||
RenderD7::Scene::Load(std::make_unique<RenderD7::RSettings>());
|
RenderD7::Scene::Load(std::make_unique<RenderD7::RSettings>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderD7::LoadThemeEditor() {
|
||||||
|
RenderD7::Scene::Load(std::make_unique<RenderD7::ThemeEditor>());
|
||||||
|
}
|
||||||
|
|
||||||
void RenderD7::AddOvl(std::unique_ptr<RenderD7::Ovl> overlay) {
|
void RenderD7::AddOvl(std::unique_ptr<RenderD7::Ovl> overlay) {
|
||||||
rd7i_overlays.push_back(std::move(overlay));
|
rd7i_overlays.push_back(std::move(overlay));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user