Add font size selection to ecode font picker:

Allow UIFontPickerDialog sections to be hidden and make ecode's UI, editor, and terminal font dialogs select both the font and its size.
Keep external fonts selectable across asynchronous font enumeration, including when they share a family name with a system font, and label them as external. Also normalize UILinearLayout weights across visible children so hidden picker columns release their space correctly.
Update font picker previews, size units, menu labels, translations, and lifetime handling.

Addresses SpartanJ/ecode#944.
This commit is contained in:
Martín Lucas Golini
2026-08-11 12:38:34 -03:00
parent 10a5d7effc
commit 6df0c0738f
17 changed files with 397 additions and 115 deletions
+12 -3
View File
@@ -28,6 +28,7 @@ class UIColorPicker;
struct UIFontSelection {
FontDesc font;
/** Font size in density-independent pixels. */
Uint32 size{ 12 };
bool underline{ false };
bool strikeThrough{ false };
@@ -54,7 +55,8 @@ class EE_API UIFontPickerDialog : public UIWindow {
ShowEffects = 1 << 2,
ShowColor = 1 << 3,
ShowApplyButton = 1 << 4,
DefaultFlags = ShowSize | ShowEffects | ShowColor,
ShowStyle = 1 << 5,
DefaultFlags = ShowSize | ShowEffects | ShowColor | ShowStyle,
};
struct FontStyleEntry {
@@ -62,6 +64,12 @@ class EE_API UIFontPickerDialog : public UIWindow {
FontDesc desc;
};
struct FontFamilyEntry {
std::string label;
std::string family;
std::string externalFontKey;
};
static UIFontPickerDialog* New( Uint32 flags = DefaultFlags );
virtual ~UIFontPickerDialog();
@@ -113,10 +121,11 @@ class EE_API UIFontPickerDialog : public UIWindow {
FontPickedCb mFontPickedCb;
FontSelectionChangedCb mFontSelectionChangedCb;
std::vector<FontDesc> mFonts;
std::vector<std::string> mFamilies;
std::vector<FontFamilyEntry> mFamilies;
std::vector<FontStyleEntry> mStyles;
std::vector<Uint32> mSizes;
UnorderedSet<std::string> mLoadedFontKeys;
UnorderedSet<std::string> mExternalFontKeys;
UnorderedMap<std::string, std::string> mFontTags;
Graphics::FontTrueTypePtr mPreviewFont;
Graphics::Font* mPreviewTextDefaultFont{ nullptr };
@@ -196,7 +205,7 @@ class EE_API UIFontPickerDialog : public UIWindow {
void selectInitialRows();
void selectFamily( const std::string& family );
void selectFamily( const FontDesc& font );
void selectRegularStyle();
+6 -1
View File
@@ -2,6 +2,7 @@
#define UI_UILINEARLAYOUT_HPP
#include <eepp/ui/uilayout.hpp>
#include <utility>
namespace EE { namespace UI {
@@ -52,7 +53,11 @@ class EE_API UILinearLayout : public UILayout {
void packHorizontal();
Sizei getTotalUsedSize();
/**
* @return A pair containing the space used by visible fixed-size children and margins, followed
* by the sum of the visible children's positive layout weights.
*/
std::pair<Sizei, Float> getTotalUsedSize();
void applyWidthPolicyOnChildren();