2 small, powerful Glamour hacks

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

2 small, powerful Glamour hacks

Sam Adams-2

I've hacked Glamour in two places recently to great effect, and I wonder what the community thinks about these new features.
Both involve allowing arbitrary morphs in place of assumed images or text.

1) I found myself wanting to have act: icons that changed state, acting like a toggle.  In my case I wanted to use a PluggableThreePhaseButtonMorph.
A one line mode to GLMMorphicRender>>renderAction: did the trick

renderAction: anAction
^(UITheme current
newButtonIn: nil
for: anAction
getState: nil
action: #morphicActOn:
arguments: {}
getEnabled: nil
>>>>> label: (anAction icon isMorph ifFalse:[AlphaImageMorph new image: anAction icon]ifTrue:[anAction icon])    <<<<<<<<
help: (anAction title, Character tab asString, anAction shortcutAsString) trimBoth)
valueOfProperty: #noBorder ifAbsentPut: [true]; "this is a hack to tell the GLMUITheme to not draw the border and the fill"
valueOfProperty: #noFill ifAbsentPut: [true];
setProperty: #wantsKeyboardFocusNavigation toValue: false; "to disable the focus"
yourself

2) I also needed to embed morphs in table presentations to allow editing of the cell text.
Again, a single change to GLMTreeMorphNodeModel>>rowMorphForColumn:

rowMorphForColumn: aGlamourColumn

| content |
content :=  self containerTree glamourPresentation column: aGlamourColumn valueFor: self item.
>>>>> ^content isString ifTrue:[StringMorph contents: content] ifFalse:[content] <<<<<<<<

This lead me to customize a subclass of PluggableTextMorph to use blocks instead of the model>>selector approach for pluggable behavior, especially so it would work nicely in a Glamour script and all the context to be referenced on the getText/setText etc operations.

These are obviously hacks but since both cases are wanting a morph and seemingly don't really need a morph of the original type (Image or String) they should be generalized to allow arbitrary morphs.
This also led me to imagine embedding full presentations or visualizations into table cells, but that's beyond my understanding of the framework at this point.

Reminds me of the old XEROX Analyst spreadsheet.

Regards,
Sam


Sam S. Adams, CTO - Contextual Computing
IBM Distinguished Engineer, IBM Research
Mobile: 919-696-6064, email: [hidden email]
Assistant: Linda R. Morrison. (720) 395-0460 Fax: (845) 491-4318, Tie: 676-0460, [hidden email]
<<Hebrews 11:6, Proverbs 3:5-6, Romans 1:16-17, 1 Corinthians 1:10>>
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev

Reply | Threaded
Open this post in threaded view
|

Re: 2 small, powerful Glamour hacks

Tudor Girba-2
Hi Sam,



On Fri, Jan 10, 2014 at 5:58 PM, Sam Adams <[hidden email]> wrote:

I've hacked Glamour in two places recently to great effect, and I wonder what the community thinks about these new features.
Both involve allowing arbitrary morphs in place of assumed images or text.

1) I found myself wanting to have act: icons that changed state, acting like a toggle.  In my case I wanted to use a PluggableThreePhaseButtonMorph.
A one line mode to GLMMorphicRender>>renderAction: did the trick

renderAction: anAction
^(UITheme current
newButtonIn: nil
for: anAction
getState: nil
action: #morphicActOn:
arguments: {}
getEnabled: nil
>>>>> label: (anAction icon isMorph ifFalse:[AlphaImageMorph new image: anAction icon]ifTrue:[anAction icon])    <<<<<<<<
help: (anAction title, Character tab asString, anAction shortcutAsString) trimBoth)
valueOfProperty: #noBorder ifAbsentPut: [true]; "this is a hack to tell the GLMUITheme to not draw the border and the fill"
valueOfProperty: #noFill ifAbsentPut: [true];
setProperty: #wantsKeyboardFocusNavigation toValue: false; "to disable the focus"
yourself


Interesting. We certainly do need to extend Glamour to support preferences not just actions, and a toggle is one kind of preferences. With your approach, you would not have access from the browser to the value of the toggle, and this would make it less valuable. A better approach would be to subclass Action with a ToggleAction and model it explicitly. Would you like to give this a try?
 


2) I also needed to embed morphs in table presentations to allow editing of the cell text.
Again, a single change to GLMTreeMorphNodeModel>>rowMorphForColumn:

rowMorphForColumn: aGlamourColumn

| content |
content :=  self containerTree glamourPresentation column: aGlamourColumn valueFor: self item.
>>>>> ^content isString ifTrue:[StringMorph contents: content] ifFalse:[content] <<<<<<<<

This lead me to customize a subclass of PluggableTextMorph to use blocks instead of the model>>selector approach for pluggable behavior, especially so it would work nicely in a Glamour script and all the context to be referenced on the getText/setText etc operations.


Nice. I integrated this one simply by calling asMorph to content.

Cheers,
Doru


These are obviously hacks but since both cases are wanting a morph and seemingly don't really need a morph of the original type (Image or String) they should be generalized to allow arbitrary morphs.
This also led me to imagine embedding full presentations or visualizations into table cells, but that's beyond my understanding of the framework at this point.

Reminds me of the old XEROX Analyst spreadsheet.

Regards,
Sam


Sam S. Adams, CTO - Contextual Computing
IBM Distinguished Engineer, IBM Research
Mobile: <a href="tel:919-696-6064" value="+19196966064" target="_blank">919-696-6064, email: [hidden email]
Assistant: Linda R. Morrison. <a href="tel:%28720%29%20395-0460" value="+17203950460" target="_blank">(720) 395-0460 Fax: <a href="tel:%28845%29%20491-4318" value="+18454914318" target="_blank">(845) 491-4318, Tie: 676-0460, [hidden email]
<<Hebrews 11:6, Proverbs 3:5-6, Romans 1:16-17, 1 Corinthians 1:10>>


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev




--

"Every thing has its own flow"

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: 2 small, powerful Glamour hacks

Stéphane Ducasse
In reply to this post by Sam Adams-2
Hi sam

renderAction: anAction

^(UITheme current
newButtonIn: nil
for: anAction
getState: nil
action: #morphicActOn:
arguments: {}
getEnabled: nil
>>>>> label: (anAction icon isMorph ifFalse:[AlphaImageMorph new image: anAction icon]ifTrue:[anAction icon])    <<<<<<<<

I was reading the following and I do not like the isMorph usage (because it looks like a case statements) and I’m fighting with morphic to remove them. 

Why not making the icon always Morph or something polymorphic? 


help: (anAction title, Character tab asString, anAction shortcutAsString) trimBoth)
valueOfProperty: #noBorder ifAbsentPut: [true]; "this is a hack to tell the GLMUITheme to not draw the border and the fill"
valueOfProperty: #noFill ifAbsentPut: [true];
setProperty: #wantsKeyboardFocusNavigation toValue: false; "to disable the focus"
yourself

2) I also needed to embed morphs in table presentations to allow editing of the cell text.
Again, a single change to GLMTreeMorphNodeModel>>rowMorphForColumn:

rowMorphForColumn: aGlamourColumn

| content |
content :=  self containerTree glamourPresentation column: aGlamourColumn valueFor: self item.
>>>>> ^content isString ifTrue:[StringMorph contents: content] ifFalse:[content] <<<<<<<<

This lead me to customize a subclass of PluggableTextMorph to use blocks instead of the model>>selector approach for pluggable behavior, especially so it would work nicely in a Glamour script and all the context to be referenced on the getText/setText etc operations.

These are obviously hacks but since both cases are wanting a morph and seemingly don't really need a morph of the original type (Image or String) they should be generalized to allow arbitrary morphs.
This also led me to imagine embedding full presentations or visualizations into table cells, but that's beyond my understanding of the framework at this point.

Reminds me of the old XEROX Analyst spreadsheet.

Regards,
Sam


Sam S. Adams, CTO - Contextual Computing
IBM Distinguished Engineer, IBM Research
Mobile: 919-696-6064, email: [hidden email]
Assistant: Linda R. Morrison. (720) 395-0460 Fax: (845) 491-4318, Tie: 676-0460, [hidden email]
<<Hebrews 11:6, Proverbs 3:5-6, Romans 1:16-17, 1 Corinthians 1:10>>

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev