[Cuis-dev] Tweaks to GUI elements size windows
Mariano Montone
marianomontone at gmail.com
Thu Feb 24 03:49:23 PST 2022
Update: This is a more refined version that selects the appropriate menu
item when the user changes sizes with the buttons.
https://drive.google.com/file/d/1enY-lBozObrOe2HRDubNCvHTdfFuk1f9/view?usp=sharing
---------------------------------
options _ #(tinyFonts verySmallFonts smallFonts standardFonts largeFonts
veryLargeFonts hugeFonts).
currentSize _ #standardFonts.
wm _ (MenuMorph new defaultTarget: Preferences)
addTitle: 'Make GUI elements';
addStayUpIcons;
add: 'Huge' action: #hugeFonts;
add: 'Very Large' action: #veryLargeFonts;
add: 'Large' action: #largeFonts;
add: 'Regular Size' action: #standardFonts;
add: 'Small' action: #smallFonts;
add: 'Very Small'action: #verySmallFonts;
add: 'Tiny'action: #tinyFonts;
yourself.
incSize _ [|item idx |
idx _ (((options indexOf: currentSize) + 1) min: options size).
currentSize _ options at: idx.
item _ wm items at: options size - idx + 1.
wm selectItem: item.
Preferences perform: currentSize].
decSize _ [|item idx|
idx _ (((options indexOf: currentSize) - 1) max: 1).
currentSize _ options at: idx.
item _ wm items at: options size - idx + 1.
wm selectItem: item.
Preferences perform: currentSize].
m _ LayoutMorph newRow
color: wm color;
borderWidth: 0;
axisEdgeWeight: #center;
separation: (20 at 0);
morphHeight: 20;
yourself.
m addMorph:
((PluggableButtonMorph model: decSize action: #value)
icon: Theme current collapseIcon;
setBalloonText: 'Decrease sizes';
yourself)
layoutSpec: LayoutSpec keepMorphExtent.
El 24/2/22 a las 01:49, Mariano Montone escribió:
> Hello,
>
> Ok. Let me try one more time.
>
> Demo:
> https://drive.google.com/file/d/1Py22nSJs7ja16-RzjtNWyj39K4l5uMWM/view?usp=sharing
>
>
> No problem at all if you don't want this included in Cuis, I can put in
> some "goodies" package in one of my repos ...
>
> I attach code at the end (that's not the important part, should be
> improved..)
>
> Cheers,
>
> Mariano
>
> -----------------------------
>
> options _ #(tinyFonts verySmallFonts smallFonts standardFonts largeFonts
> veryLargeFonts hugeFonts veryHugeFonts).
> currentSize _ #standardFonts.
>
> wm _ (MenuMorph new defaultTarget: Preferences)
> addTitle: 'Make GUI elements';
> addStayUpIcons;
> add: 'Huge' action: #hugeFonts;
> add: 'Very Large' action: #veryLargeFonts;
> add: 'Large' action: #largeFonts;
> add: 'Regular Size' action: #standardFonts;
> add: 'Small' action: #smallFonts;
> add: 'Very Small'action: #verySmallFonts;
> add: 'Tiny'action: #tinyFonts;
> yourself.
>
> incSize _ [currentSize _ options at: (((options indexOf: currentSize) +
> 1) min: options size).
> Preferences perform: currentSize].
>
> decSize _ [currentSize _ options at: (((options indexOf: currentSize) -
> 1) max: 1).
> Preferences perform: currentSize].
>
> m _ LayoutMorph newRow
> color: wm color;
> borderWidth: 0;
> axisEdgeWeight: #center;
> separation: (20 at 0);
> morphHeight: 20;
> yourself.
>
> m addMorph:
> ((PluggableButtonMorph model: decSize action: #value)
> icon: Theme current collapseIcon;
> instVarNamed: #magnifiedIcon put: Theme current collapseIcon;
> yourself)
> layoutSpec: LayoutSpec keepMorphExtent.
>
> m addMorph:
> ((PluggableButtonMorph model: incSize action: #value)
> icon: Theme current expandIcon;
> instVarNamed: #magnifiedIcon put: Theme current expandIcon;
> yourself)
> layoutSpec: LayoutSpec keepMorphExtent.
>
> wm addMorphBack: m.
>
> wm popUpInWorld.
>
> El 22/2/22 a las 17:32, Juan Vuletich escribió:
>> Nice idea. Still, I'd prefer to use this gesture for scaling the Word
>> (or any other morph) with Vector Graphics.
>>
>> Cheers,
>>
>> On 2/22/2022 11:44 AM, Mariano Montone via Cuis-dev wrote:
>>> This version uses mouse scroll to set GUI sizes:
>>>
>>> options _ #(tinyFonts verySmallFonts smallFonts standardFonts
>>> largeFonts hugeFonts).
>>> currentSize _ #standardFonts.
>>>
>>> UISupervisor whenUIinSafeState: [ |morph|
>>> morph _ (MVCMenuMorph from: (PopUpMenu labels: 'Done') title:
>>> 'Use mouse scroll to set GUI size').
>>> morph setProperty: #'handlesMouseScroll:' toValue: true.
>>> morph setProperty: #mouseScroll:localPosition: toValue: [:ev
>>> :lpos |
>>> currentSize _ options at: (ev direction == #up ifTrue:
>>> [((options indexOf: currentSize) + 1) min: options size]
>>> ifFalse: [((options indexOf: currentSize) - 1) max: 1]).
>>> Transcript show: currentSize.
>>> Preferences perform: currentSize].
>>> morph
>>> invokeAt: self runningWorld activeHand morphPosition
>>> allowKeyboard: true]
>>>
>>> I think I like it, as an alternative option for setting sizes at least.
>>>
>>> Thoughts?
>>>
>>> Cheers,
>>>
>>> Mariano
>>>
>>> El 22/2/22 a las 10:57, Mariano Montone escribió:
>>>> El 22/2/22 a las 09:37, Juan Vuletich via Cuis-dev escribió:
>>>>> Hi Folks,
>>>>>
>>>>> I just pushed a change to tweak a bit the behavior of the "Size of
>>>>> GUI elements" menu. I felt that the difference between sizes was
>>>>> too large, so I made "tiny" larger, "huge" smaller, and adjusted
>>>>> the rest. I hope you find it pleasant and not annoying. In any
>>>>> case, now you can call #defaultFontSize: with any number,
>>>>> especially if using TrueType.
>>>>
>>>> It is fine for me.
>>>>
>>>> I think it could be cool to provide some widget for selecting the
>>>> size instead of a menu.
>>>>
>>>> Like a refined version of this:
>>>>
>>>> options _ #(tinyFonts verySmallFonts smallFonts standardFonts
>>>> largeFonts hugeFonts).
>>>> sb := ScrollBar new.
>>>> sb morphExtent: 100@(sb buttonExtent).
>>>> sb scrollDelta: 1/(options size) pageDelta: 1/(options size).
>>>> sb model: [:val | |sizeSelector|
>>>> Transcript show: val.
>>>> Transcript show: (val * options size - 1) rounded.
>>>>
>>>> sizeSelector _ options at: (val * (options size - 1)) rounded +
>>>> 1 .
>>>> Transcript show: sizeSelector.
>>>> Preferences perform: sizeSelector] setValueSelector: #value:.
>>>> sb openInWorld
>>>>
>>>> I'll see if I can come up with something better, or better idea...
>>>>
>>>> Cheers,
>>>>
>>>> Mariano
>>>
>>
>>
>
More information about the Cuis-dev
mailing list