@@ -33,11 +33,20 @@ struct UIFontSelection {
3333 bool strikeThrough{ false };
3434 bool antialiasing{ true };
3535 Color color{ Color::White };
36+
37+ bool operator ==( const UIFontSelection& other ) const {
38+ return font == other.font && size == other.size && underline == other.underline &&
39+ strikeThrough == other.strikeThrough && antialiasing == other.antialiasing &&
40+ color == other.color ;
41+ }
42+
43+ bool operator !=( const UIFontSelection& other ) const { return !( *this == other ); }
3644};
3745
3846class EE_API UIFontPickerDialog : public UIWindow {
3947 public:
4048 using FontPickedCb = std::function<void ( const UIFontSelection& )>;
49+ using FontSelectionChangedCb = std::function<void ( const UIFontSelection& )>;
4150
4251 enum Flags {
4352 MonospaceOnly = 1 << 0 ,
@@ -73,6 +82,8 @@ class EE_API UIFontPickerDialog : public UIWindow {
7382
7483 void setOnFontPicked ( FontPickedCb cb );
7584
85+ void setOnFontSelectionChanged ( FontSelectionChangedCb cb );
86+
7687 UIPushButton* getButtonOK () const ;
7788
7889 UIPushButton* getButtonCancel () const ;
@@ -100,10 +111,13 @@ class EE_API UIFontPickerDialog : public UIWindow {
100111 KeyBindings::Shortcut mCloseShortcut { KEY_UNKNOWN };
101112 UIFontSelection mSelection ;
102113 FontPickedCb mFontPickedCb ;
114+ FontSelectionChangedCb mFontSelectionChangedCb ;
103115 std::vector<FontDesc> mFonts ;
104116 std::vector<std::string> mFamilies ;
105117 std::vector<FontStyleEntry> mStyles ;
106118 std::vector<Uint32> mSizes ;
119+ UnorderedSet<std::string> mLoadedFontKeys ;
120+ UnorderedMap<std::string, std::string> mFontTags ;
107121 std::shared_ptr<Models::Model> mFamilyModel ;
108122 std::shared_ptr<Models::Model> mStyleModel ;
109123 std::shared_ptr<Models::Model> mSizeModel ;
@@ -125,13 +139,14 @@ class EE_API UIFontPickerDialog : public UIWindow {
125139 UICheckBox* mAntialiasing { nullptr };
126140 UICheckBox* mUnderline { nullptr };
127141 UICheckBox* mStrikeThrough { nullptr };
128- UIPushButton * mColorButton { nullptr };
142+ UIWidget * mColorButton { nullptr };
129143 UIPushButton* mButtonOK { nullptr };
130144 UIPushButton* mButtonCancel { nullptr };
131145 UIPushButton* mButtonApply { nullptr };
132146 UIPushButton* mButtonBrowse { nullptr };
133147 bool mUpdating { false };
134148 bool mLoadingFonts { false };
149+ bool mSelectionColorExplicit { false };
135150 Uint64 mLoadFontsTaskId { 0 };
136151
137152 struct LoadFontsRequest {
@@ -156,20 +171,30 @@ class EE_API UIFontPickerDialog : public UIWindow {
156171
157172 void sortFonts ();
158173
174+ void mergeFontManagerFonts ( std::vector<FontDesc>& fonts );
175+
176+ void updateFontTags ();
177+
159178 void setFontsLoading ( bool loading );
160179
180+ void updateDefaultSelectionColor ();
181+
161182 void updateFamilies ();
162183
163184 void updateStyles ();
164185
165- void updateSelectionFromLists ();
186+ void updateSelectionFromLists ( bool notify = true );
187+
188+ void emitSelectionChanged ();
166189
167190 void updatePreview ();
168191
169192 void selectInitialRows ();
170193
171194 void selectFamily ( const std::string& family );
172195
196+ void selectRegularStyle ();
197+
173198 void selectStyle ( const FontDesc& desc );
174199
175200 void selectSize ( Uint32 size );
0 commit comments