Creating a System Window containing a Morph and some buttons

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

Creating a System Window containing a Morph and some buttons

Jeff Gonis
Hi Everyone,

So I am working on porting over a small simulation I wrote for fun in java to squeak, and I am actually stuck at a point before I can get any real work done.  The basics of the user interface I would like to offer consist of a SystemWindow containing a custom morph that will handle all of the drawing and updating of the simulation, and some buttons for altering the parameters of the simulation.  The morph would take up the largest portion of the screen, say 3/4.

I have been wrestling with SystemWindow and Toolbuilder for the last little while and I feel like I must be overlooking something easy to get started with.  If I create a system window and add a placeholder morph to it, with a frame of (0@0 corner: 0.5@1) the window becomes blue as it takes on the color of the morph I added and the morph itself becomes white.  I would like the morph to retain its color when I add it to the window, and not have the window alter its own color either.

Second, if I were to add to morphs side by side, one with a frame of (0@0 corner: 0.5@1) and the other with (0.5@0 corner: 1@1), then I will have a splitter in between the morphs and any attempt to drag this splitter results in a debugger popping up.

I have been attempting to learn Toolbuilder, but it seems very focused on just that, tools, and I didn't see an appropriate spec for adding just a custom subclass of morph.  I may have overlooked something easy here to do so, and so my spec would consist of a pluggableWindow, with its children being a pluggablePanelSpec with pluggableButtons as its children, and some other spec representing the custom morph as the second child of the windowSpec.

Any help or pointers towards creating a basic system window with a morph, or a couple of morphs in it, respecting colors and layouts, and being resized with the splitters would be greatly appreciated.

Thank you very much for your time,
Jeff G!

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Creating a System Window containing a Morph and some buttons

laurent laffont


On Thu, Jun 17, 2010 at 8:37 AM, Jeff G <[hidden email]> wrote:
Hi Everyone,

So I am working on porting over a small simulation I wrote for fun in java to squeak, and I am actually stuck at a point before I can get any real work done.  The basics of the user interface I would like to offer consist of a SystemWindow containing a custom morph that will handle all of the drawing and updating of the simulation, and some buttons for altering the parameters of the simulation.  The morph would take up the largest portion of the screen, say 3/4.

I have been wrestling with SystemWindow and Toolbuilder for the last little while and I feel like I must be overlooking something easy to get started with.  If I create a system window and add a placeholder morph to it, with a frame of (0@0 corner: 0.5@1) the window becomes blue as it takes on the color of the morph I added and the morph itself becomes white.  I would like the morph to retain its color when I add it to the window, and not have the window alter its own color either.

Second, if I were to add to morphs side by side, one with a frame of (0@0 corner: 0.5@1) and the other with (0.5@0 corner: 1@1), then I will have a splitter in between the morphs and any attempt to drag this splitter results in a debugger popping up.

I have been attempting to learn Toolbuilder, but it seems very focused on just that, tools, and I didn't see an appropriate spec for adding just a custom subclass of morph.  I may have overlooked something easy here to do so, and so my spec would consist of a pluggableWindow, with its children being a pluggablePanelSpec with pluggableButtons as its children, and some other spec representing the custom morph as the second child of the windowSpec.

Any help or pointers towards creating a basic system window with a morph, or a couple of morphs in it, respecting colors and layouts, and being resized with the splitters would be greatly appreciated.

Thank you very much for your time,

Hi,

Take a look at:

Cheers,
 
Jeff G!

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Creating a System Window containing a Morph and some buttons

Bert Freudenberg
In reply to this post by Jeff Gonis
On 17.06.2010, at 08:37, Jeff G wrote:

> Hi Everyone,
>
> So I am working on porting over a small simulation I wrote for fun in java to squeak, and I am actually stuck at a point before I can get any real work done.  The basics of the user interface I would like to offer consist of a SystemWindow containing a custom morph that will handle all of the drawing and updating of the simulation, and some buttons for altering the parameters of the simulation.  The morph would take up the largest portion of the screen, say 3/4.

Well, one difference between Squeak and Java is that while we (i.e. our Smalltalk ancestor) indeed invented windows, we feel they are rarely needed for something else than tools :)

Normally you just build your morphs directly, *not* putting them into a window frame. That's how you should start, and worry about windows later, if at all. It actually makes it easier to debug your morphs, a window would just get into the way. You have discovered halos and how to interact directly with morphs, right?

> I have been wrestling with SystemWindow and Toolbuilder for the last little while and I feel like I must be overlooking something easy to get started with.  If I create a system window and add a placeholder morph to it, with a frame of (0@0 corner: 0.5@1) the window becomes blue as it takes on the color of the morph I added and the morph itself becomes white.  I would like the morph to retain its color when I add it to the window, and not have the window alter its own color either.

Well, as you correctly inferred, system windows are made for tools, and they try to maintain a color scheme. SystemWindows nowadays set the color of added morphs to white. But when you alter the color after adding it, it stays.

> Second, if I were to add to morphs side by side, one with a frame of (0@0 corner: 0.5@1) and the other with (0.5@0 corner: 1@1), then I will have a splitter in between the morphs and any attempt to drag this splitter results in a debugger popping up.

A SystemWindow needs a model. If you don't provide one, you get that error.

> I have been attempting to learn Toolbuilder, but it seems very focused on just that, tools, and I didn't see an appropriate spec for adding just a custom subclass of morph.  I may have overlooked something easy here to do so, and so my spec would consist of a pluggableWindow, with its children being a pluggablePanelSpec with pluggableButtons as its children, and some other spec representing the custom morph as the second child of the windowSpec.

Ignore tool builder for anything but tools. It's meant as a facade to allow building text-centric tools in different UI frameworks, not just Morphic.

> Any help or pointers towards creating a basic system window with a morph, or a couple of morphs in it, respecting colors and layouts, and being resized with the splitters would be greatly appreciated.

        model := Model new.
        w := SystemWindow new.
        w model: model.

        red := Morph new.
        w addMorph: red frame: (0@0 corner: 0.5@1).
        red color: Color red.

        blue := Morph new.
        w addMorph: blue frame: (0.5@0 corner: 1@1).
        blue color: Color blue.

        w openInWorld.

- Bert -

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners