1
0
mirror of synced 2024-11-28 01:20:51 +01:00

impr: Move custom font setting behind a enable checkbox

This commit is contained in:
WerWolv 2023-11-23 23:15:42 +01:00
parent 71df45a347
commit 59b363d9b2
2 changed files with 15 additions and 6 deletions

View File

@ -184,8 +184,8 @@ namespace hex::init {
static bool loadFontsImpl(bool loadUnicode) {
const float defaultFontSize = ImHexApi::System::DefaultFontSize * std::round(ImHexApi::System::getGlobalScale());
// Load font related settings
{
// Load custom font related settings
if (ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font_enable", false)) {
std::fs::path fontFile = ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.font_path", "").get<std::string>();
if (!fontFile.empty()) {
if (!wolv::io::fs::exists(fontFile) || !wolv::io::fs::isRegularFile(fontFile)) {

View File

@ -386,13 +386,22 @@ namespace hex::plugin::builtin {
/* Fonts */
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.glyphs", "hex.builtin.setting.font.load_all_unicode_chars", false);
auto fontPathSetting = ContentRegistry::Settings::add<Widgets::FilePicker>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_path").requiresRestart();
auto customFontEnabledSetting = ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.custom_font_enable", false).requiresRestart();
ContentRegistry::Settings::add<Widgets::FilePicker>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_path")
.requiresRestart()
.setEnabledCallback([customFontEnabledSetting]{
auto &checkBox = static_cast<Widgets::Checkbox &>(customFontEnabledSetting.getWidget());
return checkBox.isChecked();
});
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_size", 13, 0, 100)
.requiresRestart()
.setEnabledCallback([fontPathSetting]{
auto &filePicker = static_cast<Widgets::FilePicker &>(fontPathSetting.getWidget());
.setEnabledCallback([customFontEnabledSetting]{
auto &checkBox = static_cast<Widgets::Checkbox &>(customFontEnabledSetting.getWidget());
return !filePicker.getPath().empty();
return checkBox.isChecked();
});