Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glamour-Roassal should be able to work with raw ROView not just ROMondrianBuilder #900

Closed
seandenigris opened this issue Aug 3, 2015 · 12 comments

Comments

@seandenigris
Copy link
Contributor

Originally reported on Google Code with ID 900

Hopefully, I've cracked this.  In response to my own query: "Could something like a
GLMMorphicRoassalRawRenderer be added to the Glamour-Roassal interface?  - which would
pass an unencumbered ROView to the paintingBlock.  It is not really a Glamour-Roassal
interface at the moment, more of a Glamour-Mondrian interface."

With the attached slice you can now go...
    browser transmit to: #graphic andShow: 
    [   :a |
        a roassal
            newView: [ ROView new @ RODraggable ] ;
            painting: [:view :input |  view add: ROElement new]
    ].

After loading you can first try the new & old tests in 'Glamour-Tests-Roassal' 
then try 'GLMRawRoassalExamplesBrowser open'

I surprised myself that I got this far.  A few times I hit a brick wall and was going
to submit a half done proof-of-concept, but then just kept digging. Apart from hopefully
getting integrated, some critical feedback would appreciated.  A few points for review...

1. I had considered using #viewPrototype: with an instance to copy, but then I wasn't
sure how deep I should copy it to produce a new view. So using a block with newView:
seemed the safer path (and it also feels like it opens up some interesting possibilities,
even if I can't think what they are at the moment)

2. I noticed that GLMRoassalPresentation>>renderOn: had a flag 'This should be the
responsibility of the view'.
This method was one that I previously copied and modified for GLMRoassalRawPresentation
in my "Interactive Roassal" experiment.  There I removed the calls to #applyLayout
and #populateMenuOn since these were MNU for ROView (which had replaced ROMondrianViewBuilder).
This time I pushed these two calls into ROMondrianViewBuilder>>preOpen, where ROView>>preOpen
is left empty. I'm note sure I'm happy with #preOpen as a name but it was the best
I could come up with, since I also refactored ROMondrianViewBuilder>>open to use it.

3. GLMMorphicRoassalRenderer>>render:  had hardcoded reference to #stack with "ROMorph
on: view stack" so I pushed the required difference into ROMondrianBuilder>>newMorph
and ROView>>newMorph.

4. GLMMorphicRoassalRenderer>>actOnPresentationUpdate had hardcoded use of #stack in
"setView: aView stack" so I pushed that into ROMondrianViewBuilder>>onMorph: and ROView>>onMorph:


5. GLMMorphicRoassalRenderer>>actOnPresentationUpdate had hardcoded ROMondrianViewBuilder
so I modified this to use the block passed to GLMRoassalPresentation>>newView: .

6. I copied GLMRoassalMorphicTest to GLMRawRoassalMorphicTest with required modifications.


7. I copied GLMRoassalExamplesBrowser to GLMRawRoassalExamplesBrowser with required
modifications.  


Reported by benjamin.t.coman on 2013-01-03 15:13:38

@seandenigris
Copy link
Contributor Author

The slice and dependent files are in the attached SLICE-Issue-900.zip.

Reported by benjamin.t.coman on 2013-01-03 16:17:55


- _Attachment: [SLICE-Issue-900.zip](https://storage.googleapis.com/google-code-attachments/moose-technology/issue-900/comment-1/SLICE-Issue-900.zip)_

@seandenigris
Copy link
Contributor Author

btw, that slice is against a fresh Moose-4.7-beta image downloaded yesterday.

Reported by benjamin.t.coman on 2013-01-04 06:37:48

@seandenigris
Copy link
Contributor Author

I look at your slice, but you broke Glamour with it because newMorph is not present
in Roassal

Reported by tudor@tudorgirba.com on 2013-01-07 20:45:32

@seandenigris
Copy link
Contributor Author

Thanks for taking the time to have a look at it.  #newMorph is in Roassal-BenComan.405.mcz
in the SLICE-Issue-900.zip file you downloaded.  

Sorry the hiccup. I haven't working with slices very much.  It seems strange though.
I thought I'd tested loading the SLICE-Issue-900-xxxxxxx.1.mcz file onto a freshly
unpacked Moose image - except now I am having trouble loading that slice myself. 

I just re-tested loading the individual mcz files in the following order.  
Roassal-BenComan.405.mcz
Glamour-Morphic-Renderer-BenComan.180.mcz
Glamour-Roassal-Presentation-BenComan.9.mcz
Glamour-Tests-Roassal-BenComan.5.mcz
Glamour-Examples-BenComan.253.mcz

Then...
* the eight Glamour-Tests-Roassal are all green.
* GLMRawRoassalExamplesBrowser open   brings up the Glamour browser on ROExample
* GLMRoassalExamplesBrowser open   brings up the Glamour browser on ROMondrianExample

Could you give it another go.

Reported by benjamin.t.coman on 2013-01-08 12:12:24

@seandenigris
Copy link
Contributor Author

Or perhaps I misunderstood you, and you mean it needs Alexandre to approve and integrate
my Roassal changes.

Reported by benjamin.t.coman on 2013-01-08 14:43:16

@seandenigris
Copy link
Contributor Author

I have had some discussion with Alexandre, and since the methods I was adding to Roassal
are 'morph' focused and Roassal is more cross-platform, he suggested these methods
be Glamour extensions to Roassal.  I'll do up another with regard for that.

Reported by benjamin.t.coman on 2013-01-10 17:38:45

@seandenigris
Copy link
Contributor Author

Sorry I never got around to following this up. It is surprisingly long ago.  I have
been distracted away from Moose for a while, but since there are now a number of builders
for Roassal - ROMondrianViewBuilder, ROTreeMapBuilder, ROPunchcardBuilder, ROFranceMapBuilder
- now might be a good time to revisit the architecture of the Glamour-Roassal interface.


Currently Glamour is tied tightly with ROMondrianViewBuilder, and I guess the new builders
would not work with Glamour. In other words, it is currently a Glamour-ROMondrianViewBuilder
interface rather than a Glamour-Roassal interface.  It would be really great if future
new third-party Roassal builders could be easily plugged into Glamour.  This should
also include direct use of ROView such as by my LEKtrek application (when I finally
release it).

Also, please consider the case where the Roassal view is not completely regenerated
each time, but is persistent across invocations of #paint:.  This is for where the
Glamour-Roassal interface is used mostly for passing selections from Glamour lists
to highlight Roassal features.  Just off the top of my head, one way of implementing
both these behaviours might be to consider whether a class or an instance is passed
to #newView:.  For example, where..
        a roassal
            newView: [ :oldView | MyRoassalBuilder newViewFrom: oldView ] ; 

* regenerate each time
    MyRoassalBuilder class>>newViewFrom: oldView
         ^ self new

* persistent
    MyRoassalBuilder class>>newViewFrom: oldView
         ^ oldView

Reported by benjamin.t.coman on 2013-11-17 12:42:00

@seandenigris
Copy link
Contributor Author

I have updated this to work on Moose 5 build #166 [1] per attached files:
* Glamour-Roassal-Presentations-BenComan.16
* Glamour-Morphic-Renderer-BenComan.216

The Roassal parts have been made extensions from package Glamour-Roassal-Presentations.

After loading evaluate...
    GLMOtherExamples new roassalDirect openOn: (1 to: 20).

[1] https://ci.inria.fr/moose/job/moose-5.0/166/

cheers -ben

Reported by benjamin.t.coman on 2013-11-17 16:30:20

@seandenigris
Copy link
Contributor Author

Reported by benjamin.t.coman on 2013-11-17 16:31:57


- _Attachment: [Glamour-Roassal-Presentations-BenComan.16.mcz](https://storage.googleapis.com/google-code-attachments/moose-technology/issue-900/comment-9/Glamour-Roassal-Presentations-BenComan.16.mcz)_ - _Attachment: [Glamour-Morphic-Renderer-BenComan.216.mcz](https://storage.googleapis.com/google-code-attachments/moose-technology/issue-900/comment-9/Glamour-Morphic-Renderer-BenComan.216.mcz)_

@seandenigris
Copy link
Contributor Author

Here is an overview of the changes...

Package Glamour-Roassal-Presentations extensions to Roassal

* ROMondrianViewBuilder
  >>newMorph(new) - factored out GLMMorphicRoassalRenderer>>render: - returns new ROMorph
on its #stack.

  >>onMorph:(new) - sets view of existing ROMorph on its #stack

* ROView
  >>newMorph(new) - returns new ROMorph on itself
  >>onMorph:(new) - sets view of existing ROMorph on itself
  >>applyLayout(new) - does nothing, just be polymorphic with ROMondrianBuilder

Package Glamour-Roassal-Presentations 

* GLMRoassalPresentation - added ivar 'newViewBlock'
  >>newViewBlock/newViewBlock:(new) - getter/setter for added ivar
  >>renderOn:(mod) 
    - changed #raw to #view, since this is polymorphic between ROView & ROMondrianViewBuilder
  >>view(mod) - removed hardcoded ROMondrianViewBuilder. Instead evaluate 'newViewBlock'.

Package Glamour-Morphic-Renderer

* GLMMorphicRoassalRenderer
  >>actOnPresentationUpdate:(mod) - removed hardcoded ROMondrianViewBuilder. Instead
evaluate 'newViewBlock'
  >>render:(mod) - removed hardcoded ROMorph on #stack.  Factored out to ROMondrianViewBuilder>>newMorph.

Reported by benjamin.t.coman on 2013-11-17 16:32:50

@seandenigris
Copy link
Contributor Author

A usage example can be defining the following method, then evaluating the comment.

GLMOtherExample>>roassalCountries
    "self new roassalCountries openOn: ROSVGPath countries"

    | browser |
    ROPlatform setCurrent: 'morphic'.
    browser := GLMTabulator withStatusbar.
    browser column: #list; column: #roassalRaw.
    browser transmit to: #list; andShow: 
    [   :a |
        a list 
            title: 'Select country' 
    ].
    browser transmit from: #list; to: #roassalRaw; andShow: 
    [   :a |
        a roassal 
            title: 'Country Shape';
            newViewBlock: [ ROView new @ RODraggable ] ;  "<----------"
            painting: 
            [   :view :country |  |path element|
                path := ROSVGPath path: (ROSVGPath perform: country).
                element := path elementOn: country.
                view add: element.
                view translateTo: path topLeftFromSVG negated.
            ].
    ].
    ^browser

Reported by benjamin.t.coman on 2013-11-19 16:11:19


- _Attachment: Issue-900-use-case.png
![Issue-900-use-case.png](https://storage.googleapis.com/google-code-attachments/moose-technology/issue-900/comment-11/Issue-900-use-case.png)_

@seandenigris
Copy link
Contributor Author

Thanks Ben.

I integrated your solution for now with one modification: we have initializeView: instead
of newViewBlock:.

We can iterate from this point on: we need to make all builders polymorphic. 

Now, this works:

GLMWrapper new with: [ :browser |
        browser show: [ :a |
            a roassal 
                initializeView: [ ROView new @ RODraggable ] ;
                painting: [ :view :numbers | 
                    numbers do: [ :number | 
                        view add: (ROElement spriteOn: number) + ROLabel ].
                    ROTreeLayout on: view elements
                ] ] ];
    openOn: (1 to: 10)

Reported by tudor@tudorgirba.com on 2013-12-17 20:32:56

  • Status changed: Fixed
  • Labels added: Type-Enhancement, Component-Glamour, Milestone-5.0
  • Labels removed: Type-Defect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant