2014-11-16 10:02 GMT+01:00 kilon alios <kilon.alios@gmail.com>:
Hello guys I am trying to add a morph to spec gui before a spec button and the experience has been a nightmare so far.
https://github.com/kilon/Nireas/blob/master/Nireas.package/Nireas.class/clas...
What do you mean "add a morph to spec gui". The common way is to define your own model and instead of composing your GUI with different morphs, you compose your GUI with different (ready-made) models. If you need a new kind of 1 model-GUI-Widget you'll have to define your own spec (morphic)adapter and add a spec binding. If you just want to add an existing morph into your layout, you can use Morphic>>#asSpecAdapter. This example looks a bit ugly, just because it uses a DynamicComposableModel. In your own applicatoin you would define your own model for defining and composing the parts: class:=AthensFlakeDemo. method:=AthensFlakeDemo>>#initialize. composed:= DynamicComposableModel new. composed instantiateModels: #(code TextModel method TextInputFieldModel). "this is a hack, as #instantiateModels: does not work for non-spec-models" composed widgets at:#demo put:(AthensFlakeDemo new asSpecAdapter). "with your own model (instead of using DynamicComposableModel) you would" "define a method that returns the morph asSpecadapter " composed code text:method sourceCode. composed method text: method selector asString. composed code aboutToStyle:true. composed code behavior:class. composed title:(class asString). composed openWithSpecLayout:( SpecLayout composed newColumn:[:r | r add: #demo height:80; add: #method height:25; add: #code]; yourself).
I understand how columns and rows work but I cant figure out how Spec works with Morphs.
I took a look at CheckBoxExample but it completely jammed my brain how complex it looks.
First of all defaultSpec2 is what ? and whats the diffirence with defaultSpec ?
Dont know about you but I don't like neither name defaultSpec and defaultSpec2 , I would have chosen a name like layout or something that makes sense.
also why we need to initializeWidgets when we already define their order in defaultSpec ? Why cant Spec initialise those widgets by itself ?
Is it really necessary for each element of the gui to be defined as a getter method ? Why not just put everything to a dictionary and make a getter for that dictionary ? It would make a complex Spec gui a nightmare to browser and leads to braking it up to more classes which will still make it a mess to browse.
I see also a container defined in there , I assume it has something to do with the morphs.
I took also a look at documentation at Pharo for the Enterprise and it has a section for building widgets but it looks too much work to add just a few morph to a Spec gui.
I wanted to make the gui for Nireas with Spec and I like some of its design but overall it has been way more struggle than working with Morphic.
I know I have complained about Spec before and sorry if I sound like a broken tape but making guis in heavily gui based environment like Pharo should not be so hard.
I dont have a problem failing back to Morphic but since I see so many people praise Spec I keep wondering if I approach this the wrong way and things are much more elegant and easy than they look.