mirror of
https://github.com/SatDump/SatDump
synced 2026-08-13 17:47:30 -04:00
Some theming improvements
This commit is contained in:
parent
3d29b24670
commit
8eae0916af
7 changed files with 41 additions and 9 deletions
|
|
@ -74,8 +74,9 @@ First time here? See the reference documents below to get started using SatDump.
|
|||
|
||||
### Fonts
|
||||
- [Roboto](https://fonts.google.com/specimen/Roboto), for text
|
||||
- [3270 Nerd Font](https://www.nerdfonts.com/font-downloads), for icons and symbols
|
||||
*Both fonts were merged into a single font.ttf*
|
||||
- [3270 Nerd Font](https://www.nerdfonts.com/font-downloads), for icons and symbols
|
||||
- [Perfect DOS VGA 437](https://www.dafont.com/perfect-dos-vga-437.font), for Phosphor theme
|
||||
*3270 Nerd Font and Roboto have been merged into a single font.ttf*
|
||||
|
||||
# Developers
|
||||
**Lead Developer:** Aang23 (F4LAU)
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 92 KiB |
BIN
resources/fonts/Perfect-DOS-VGA-437-Win.ttf
Normal file
BIN
resources/fonts/Perfect-DOS-VGA-437-Win.ttf
Normal file
Binary file not shown.
|
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"light": false,
|
||||
"font": "Perfect-DOS-VGA-437-Win",
|
||||
"font_size": 14,
|
||||
"ImGuiStyle": {
|
||||
"ScrollbarRounding": 0.0,
|
||||
"TabRounding": 0.0,
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ namespace image
|
|||
// Others
|
||||
|
||||
// Font creation
|
||||
std::vector<Image<uint8_t>> make_font(int size, bool text_mode = true); // Generate a font to be used by draw_text. Uses the bundled GNU FreeMono
|
||||
std::vector<Image<uint8_t>> make_font(int size, bool text_mode = true); // Generate a font to be used by draw_text. Uses the bundled Roboto font
|
||||
|
||||
template <typename T>
|
||||
Image<T> generate_text_image(std::string text, T color[], int size, int padX, int padY); // return text on a transparent background
|
||||
|
|
|
|||
|
|
@ -51,13 +51,23 @@ namespace style
|
|||
try
|
||||
{
|
||||
std::string selected_theme = satdump::config::main_cfg["user_interface"]["theme"]["value"];
|
||||
std::string theme_path;
|
||||
if(resources::resourceExists("themes/" + selected_theme + ".json"))
|
||||
theme_path = "themes/" + selected_theme + ".json";
|
||||
else
|
||||
{
|
||||
logger->warn("Failed to load theme \"%s\". Will fall back to Dark", selected_theme.c_str());
|
||||
satdump::config::main_cfg["user_interface"]["theme"]["value"] = selected_theme = "Dark";
|
||||
satdump::config::saveUserConfig();
|
||||
}
|
||||
|
||||
std::ifstream file(resources::getResourcePath("themes/" + selected_theme + ".json"));
|
||||
file >> data;
|
||||
file.close();
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
logger->error("Failed to load theme! There will be visual issues.");
|
||||
logger->error("Failed to load any theme! Your SatDump installation may be missing critical files.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -68,6 +78,20 @@ namespace style
|
|||
else
|
||||
ImGui::StyleColorsDark();
|
||||
|
||||
// Set font
|
||||
if (data.contains("font") && data["font"].is_string())
|
||||
{
|
||||
std::string font = data["font"];
|
||||
if (resources::resourceExists("fonts/" + font + ".ttf"))
|
||||
theme.font = font;
|
||||
else
|
||||
logger->debug("Specified font \"%s\" not found. Falling back to default", font.c_str());
|
||||
}
|
||||
|
||||
// Set font size
|
||||
if (data.contains("font_size") && data["font_size"].is_number() && data["font_size"].get<float>() > 0)
|
||||
theme.font_size = data["font_size"];
|
||||
|
||||
// ImGui sizes
|
||||
if (data.contains("ImGuiStyle") && data["ImGuiStyle"].is_object())
|
||||
{
|
||||
|
|
@ -83,13 +107,16 @@ namespace style
|
|||
{"FrameRounding", &ImGuiStyle::FrameRounding},
|
||||
{"FrameBorderSize", &ImGuiStyle::FrameBorderSize},
|
||||
{"IndentSpacing", &ImGuiStyle::IndentSpacing},
|
||||
{"LogSliderDeadzone", &ImGuiStyle::LogSliderDeadzone},
|
||||
{"ColumnsMinSpacing", &ImGuiStyle::ColumnsMinSpacing},
|
||||
{"ScrollbarSize", &ImGuiStyle::ScrollbarSize},
|
||||
{"ScrollbarRounding", &ImGuiStyle::ScrollbarRounding},
|
||||
{"GrabMinSize", &ImGuiStyle::GrabMinSize},
|
||||
{"GrabRounding", &ImGuiStyle::GrabRounding},
|
||||
{"TabRounding", &ImGuiStyle::TabRounding},
|
||||
{"TabBorderSize", &ImGuiStyle::TabBorderSize},
|
||||
{"TabBarBorderSize", &ImGuiStyle::TabBarBorderSize}
|
||||
{"TabBarBorderSize", &ImGuiStyle::TabBarBorderSize},
|
||||
{"SeparatorTextBorderSize", &ImGuiStyle::SeparatorTextBorderSize}
|
||||
};
|
||||
|
||||
for (auto& style_item : data["ImGuiStyle"].items())
|
||||
|
|
@ -254,15 +281,15 @@ namespace style
|
|||
float macos_fbs = macos_framebuffer_scale();
|
||||
float font_scaling = dpi_scaling * macos_fbs;
|
||||
|
||||
baseFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/Roboto-Medium.ttf").c_str(), 16.0f * font_scaling, &config, def);
|
||||
baseFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/" + theme.font + ".ttf").c_str(), theme.font_size * font_scaling, &config, def);
|
||||
config.MergeMode = true;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
baseFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/font.ttf").c_str(), 16.0f * font_scaling, &config, list[i]);
|
||||
baseFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/font.ttf").c_str(), theme.font_size * font_scaling, &config, list[i]);
|
||||
config.MergeMode = false;
|
||||
|
||||
bigFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/Roboto-Medium.ttf").c_str(), 45.0f * font_scaling); //, &config, ranges);
|
||||
//hugeFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/Roboto-Medium.ttf").c_str(), 128.0f * font_scaling); //, &config, ranges);
|
||||
bigFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/" + theme.font + ".ttf").c_str(), 45.0f * font_scaling); //, &config, ranges);
|
||||
//hugeFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/" + theme.font + ".ttf").c_str(), 128.0f * font_scaling); //, &config, ranges);
|
||||
io.Fonts->Build();
|
||||
io.FontGlobalScale = 1 / macos_fbs;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ namespace style
|
|||
struct Theme
|
||||
{
|
||||
bool light_mode = false;
|
||||
std::string font = "Roboto-Medium";
|
||||
float font_size = 16.0f;
|
||||
|
||||
ImColor red;
|
||||
ImColor green;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue