[Cuis-dev] Preference behavior and Parameters

Hilaire Fernandes hilaire at drgeo.eu
Mon May 2 13:09:48 PDT 2022


Hi,

Obviously the Preferences carries a lot of things (see code abstract 
below). I am contemplating the situation on the possibility to normalize 
(like a norm) the Preference behavior so it can also be edited with a 
third party GUI, pref save/load/merge to/from files and easier to 
understand.

Observe how hugeFonts is selected for the system: message #hugeFonts is 
sent to Preferences (now it is not a preference flag as some other 
messages sent to Preferences, a source of confusion), then huge font 
applied, then the Preferences set itself the preference #guiElementSize 
to #hudgeFont.

I fell it should be the other way: the user set the #guiElementSize to 
#hugeFont, then the Preference system applies the font change. So we 
have two things happening: changing the value of property, then a system 
reacting to this property change.

An implementation following the logic we discussed with the newer 
Preference system looks like:

  * #guiElementsSize preference of type Array of symbol, when its value
    changes, it triggers an event
  * a third party object listen event from #guiElementSize preference,
    at event catch it defaultFontSize: accordingly.

The third party object could be the Preference system (PreferenceNG 
class) itself. #standardCodeFont, etc will be preferences in their own 
#font category. That way we don't need the Parameter. There will be a 
bit more work to load preference set, though.

Juan, does it sound acceptable implementation?

If so I can resume my work with PreferenceNG on that direction.

Hilaire



Preferences>>hugeFonts
     "Sets not only fonts but other GUI elements
     to fit regular resolution and size screens
     Preferences hugeFonts
     "

     self defaultFontSize: 32.
     self setPreference: #guiElementsSize toValue:  #hugeFonts.

Preferences>>defaultFontSize: pointSize
     "
     Adjust sizes for GUI elements.

     Preferences defaultFontSize: 5
     Preferences defaultFontSize: 6

     Preferences defaultFontSize: 7
     Preferences defaultFontSize: 9
     Preferences defaultFontSize: 11
     Preferences defaultFontSize: 14
     Preferences defaultFontSize: 18
     Preferences defaultFontSize: 24
     Preferences defaultFontSize: 32
     "
     | font titleFont |
     font _ FontFamily familyName: FontFamily defaultFamilyName 
pointSize: pointSize..
     self
         setListFontTo: font;
         setMenuFontTo: font;
         setCodeFontTo: font;
         setButtonFontTo: font;
         setSystemFontTo: font.
     titleFont _ FontFamily familyName: FontFamily defaultFamilyName 
pointSize: pointSize * 12//10.
     self setWindowTitleFontTo: titleFont.
     MorphicCanvas allSubclassesDo: [ :c| c guiSizePreferenceChanged ].
     UISupervisor ui ifNotNil: [ :w | w fontPreferenceChanged ].
     pointSize > 14
         ifTrue: [ Preferences enable: #biggerCursors ]
         ifFalse: [ Preferences disable: #biggerCursors ].
     Cursor defaultCursor activateCursor.
     ^font

-- 
GNU Dr. Geo
http://drgeo.eu
http://blog.drgeo.eu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20220502/cad62533/attachment.htm>


More information about the Cuis-dev mailing list