Re: [Factor-talk] Model activation sequence

2015-01-03 Thread Jon Harper
Hi Mark,
I'm basing my remarks on
https://github.com/hyphz/fr8x-editor/tree/257e244c3a20175a5c88d8c2f776999897025776

Like you said, for the arrow to work, it needs to be activated. In your
program the activation of the arrow is done by the open-window which
calls the graft method of the checkbox holding your partmodel. So I
guess you should move your code around to not depend on the data of the
arrow until all the models have been activated. Maybe you can just remove
the call to partmodel-fetch in new-partmodel, are they really needed ? The
ui starts fines without them.

Hope that helps,
Jon



Jon

On Fri, Jan 2, 2015 at 1:08 AM, Mark Green m...@antelope.nildram.co.uk
wrote:

 Hi folks,

 After my previous post about a model which could extract a part of a
 complex structure inside another model, I had a go at it myself as follows:

 TUPLE: partmodel  model master extractor updater ;

 : partmodel-fetch ( partmodel -- )
 dup [ master value ] [ extractor ] bi call( master -- part )
 swap set-model ;

 : new-partmodel ( master extractor updater class -- partmodel )
 f swap new-model swap updater swap extractor [ add-dependency ] [
 swap master ] 2bi dup partmodel-fetch ;

 M: partmodel model-changed
 nip partmodel-fetch ;

 M: partmodel update-model
 dup master locked? [ Warning: partmodel failing to update master
 . drop ] [
 dup [ master value ] [ value ] [ updater ] tri call(
 mastervalue newslavevalue -- )
 master [ [ update-model ] [ notify-connections ] bi ]
 with-locked-model
 ] if ;

 : partmodel ( master extractor updater -- partmodel ) partmodel
 new-partmodel ;

 : nthmodel ( master index -- partmodel )
 [ '[ _ swap nth ] ] [ '[ _ rot set-nth ] ] bi partmodel ;


 Notice that I ended up having to roll my own notification inside
 update-model because using set-model doesn't seem appropriate given that
 the reference to the higher level structure will not change and most of the
 functions for updating parts of complex structures act in place and pop the
 old reference form the stack.

 The problem however occurs when I create a partmodel whose master is an
 arrow. In this case, even when I add it to a UI element, the arrow does
 not seem to be activated and does not fetch its value. This seems odd as
 the partmodel should have the arrow added to its dependency list in
 new-partmodel before being activated itself. Am I doing something terribly
 wrong?

 Mark



 --
 Dive into the World of Parallel Programming! The Go Parallel Website,
 sponsored by Intel and developed in partnership with Slashdot Media, is
 your
 hub for all things parallel software development, from weekly thought
 leadership blogs to news, videos, case studies, tutorials and more. Take a
 look and join the conversation now. http://goparallel.sourceforge.net
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk


--
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Model activation sequence

2015-01-03 Thread Jon Harper
Actually, the call to activate-model is just before the call to the
gadget's graft* method, but the point remains the same

Jon

On Sat, Jan 3, 2015 at 8:02 PM, Jon Harper jon.harpe...@gmail.com wrote:

 Hi Mark,
 I'm basing my remarks on
 https://github.com/hyphz/fr8x-editor/tree/257e244c3a20175a5c88d8c2f776999897025776

 Like you said, for the arrow to work, it needs to be activated. In your
 program the activation of the arrow is done by the open-window which
 calls the graft method of the checkbox holding your partmodel. So I
 guess you should move your code around to not depend on the data of the
 arrow until all the models have been activated. Maybe you can just remove
 the call to partmodel-fetch in new-partmodel, are they really needed ? The
 ui starts fines without them.

 Hope that helps,
 Jon



 Jon

 On Fri, Jan 2, 2015 at 1:08 AM, Mark Green m...@antelope.nildram.co.uk
 wrote:

 Hi folks,

 After my previous post about a model which could extract a part of a
 complex structure inside another model, I had a go at it myself as follows:

 TUPLE: partmodel  model master extractor updater ;

 : partmodel-fetch ( partmodel -- )
 dup [ master value ] [ extractor ] bi call( master -- part )
 swap set-model ;

 : new-partmodel ( master extractor updater class -- partmodel )
 f swap new-model swap updater swap extractor [ add-dependency ] [
 swap master ] 2bi dup partmodel-fetch ;

 M: partmodel model-changed
 nip partmodel-fetch ;

 M: partmodel update-model
 dup master locked? [ Warning: partmodel failing to update
 master . drop ] [
 dup [ master value ] [ value ] [ updater ] tri call(
 mastervalue newslavevalue -- )
 master [ [ update-model ] [ notify-connections ] bi ]
 with-locked-model
 ] if ;

 : partmodel ( master extractor updater -- partmodel ) partmodel
 new-partmodel ;

 : nthmodel ( master index -- partmodel )
 [ '[ _ swap nth ] ] [ '[ _ rot set-nth ] ] bi partmodel ;


 Notice that I ended up having to roll my own notification inside
 update-model because using set-model doesn't seem appropriate given that
 the reference to the higher level structure will not change and most of the
 functions for updating parts of complex structures act in place and pop the
 old reference form the stack.

 The problem however occurs when I create a partmodel whose master is an
 arrow. In this case, even when I add it to a UI element, the arrow does
 not seem to be activated and does not fetch its value. This seems odd as
 the partmodel should have the arrow added to its dependency list in
 new-partmodel before being activated itself. Am I doing something terribly
 wrong?

 Mark



 --
 Dive into the World of Parallel Programming! The Go Parallel Website,
 sponsored by Intel and developed in partnership with Slashdot Media, is
 your
 hub for all things parallel software development, from weekly thought
 leadership blogs to news, videos, case studies, tutorials and more. Take a
 look and join the conversation now. http://goparallel.sourceforge.net
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



--
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Dealing with parts of a model

2015-01-03 Thread Jon Harper
Hi Mark,
model-field can't work with arrows. Among other reasons, in your case the
arrow is not activated when it's data is used to intialize the editor
string (that's why you see them empty).

The model given to model-field isn't meant to be updated by the caller
anyway: it's value is used as an initialization of the editor-string, but
after that only the editor-gadget should update the input model when the
field is edited.

Maybe you should think of your problem the other way around: instead of
having data in your structure and creating arrows from pieces of it, wrap
all the data in your structure in models and pass those models to the UI ?
The UI will then update your structure when the user edits fields.

Regards,
Jon


Jon

On Tue, Dec 30, 2014 at 9:16 PM, Mark Green m...@antelope.nildram.co.uk
wrote:

 Hi,

 I hope everyone had a good Christmas. I'm still struggling a bit with how
 to create a UI that alters parts of a structure.

 So far I can store the structure as a whole in the model slot of the
 containing pane, and I can create arrow models for the individual controls
 to refer to. The problem is writing changes back again, since the arrow
 model does not propagate changes back across itself. I see there is a
 double-ended arrow model in extra called illusion, but it seems to depend
 on the arrow operation being invertible which extraction of part of a
 sequence (for example) is not. It is however mergable in that the data from
 the lower level model could be re-incorporated into the higher level model
 given knowledge of them both. Does anything support this?

 Also, does model-field work correctly? When I try to create one, it
 seems to come up blank and editable, even if the arrow model contains data
 and is not writable.

 Mark



 --
 Dive into the World of Parallel Programming! The Go Parallel Website,
 sponsored by Intel and developed in partnership with Slashdot Media, is
 your
 hub for all things parallel software development, from weekly thought
 leadership blogs to news, videos, case studies, tutorials and more. Take a
 look and join the conversation now. http://goparallel.sourceforge.net
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk


--
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk