[Qt-interest] [solved] Is it possible with the State Machine Framework?

Mihail Naydenov mlists at ymail.com
Thu Apr 15 13:42:48 CEST 2010


OK, thank You, your guidelines helped me find the solution.

It is as follows. 

drawer_open
drawer_closed

*both* are parallel states.

Indeed the icon also must have another pair of (open/closed) sates. They will do the work setting all the necessary properties.

Then, upon dragging out/in from the drawer, one simply un/re-parents the icon stats to both open and closed states.
Thats it.

Now varying number of icons can be told to be in open close state simultaneously.


The moral of the story is.
If you want to be able to add/remove  which properties are control by witch state you wrap them in a sub-state of their own and hande the switching trough parenting the sub-state to the desired states. (Instead of binding the props directly to the desired states) 
 
I must note, Im not very happy. It really feels that enabling "un-binding" of properties from a state is much better and simple solution.
MihailNaydenov


 

----- Original Message ----
> From: Sean Harmer <sean.harmer at maps-technology.com>
> To: qt-interest at trolltech.com
> Sent: Thu, April 15, 2010 11:51:59 AM
> Subject: Re: [Qt-interest] Is it possible with the State Machine Framework?
> 
> Hi,

On Thursday 15 April 2010 09:13:13 Mihail Naydenov wrote:
> Hi, 
> thank You, for your interest.
> 
> Right now the (easy) way to do 
> work in states is to make some state
> automatically assign properties of 
> some object (on state change).
> 
> state->assignProperty(object, 
> property, value)
> 
> Now the object has defined meaning what is 
> like to be in that state.
> You don't have to manually mange the object 
> yourself, now it is smart and
> reacts automatically to the events that 
> alter the sate. This is very
> powerful, because in a way a state 
> represents an environment for the
> object: Here is an object, you set 
> this and that directly, and the rest is
> handled behind the scenes, based 
> on some external factors not of interest
> to the user.
> 
> 
> For instance: You have a control (an icon) when clicked it does a work. 
> You
> have a drawer/ tool window. The drawer can be "open" and "closed". 
> Now,
> you can drag the icon in and outside the drawer in a way changing 
> its
> environment. When in the drawer - it also "opens" and "closes", if 
> not in
> - its always "open" (which might or might not affect what it 
> does).
> The drawer open/close can be managed by a state - one for "open", 
> one fore
> "closed". This state will do all the work - it will set all the 
> props all
> over the drawer window and its contents. Lets say it hides all 
> on close.
> The beauty is - every control can define what it is to be in 
> that sate.
> Our icon for instance, when dragged into the drawer will also 
> become part
> of the drawer's state, but might be made semi transparent 
> instead of just
> hidden, by "attaching" the right property to the 
> sate
> (drawer_open->assignProperty(icon, "opacity", 1) ; 
> 
> drawer_closed->assignProperty(icon, "opacity", 0.5)).
> 
> So far 
> so good, problem is if we want our icon out of the drawer again,
> there 
> is no way to break the link with the drawer state. Outside of the
> drawer 
> it will still go semi transparent when the drawer is opened closed.
> What 
> we want is, upon dragging out, to "detach" or "unassing" the opacity
> and 
> to manually set it to 1 (or let some other state handle it)
> 
> 
> Again, I might be missing something.
> I know it possible to implement 
> this with custom state and or custom
> transition or destroy and recreate 
> the states every time... but then
> again, its also possible to implement 
> it without states at all :)

I'm not entirely sure that I follow all of 
> your example but it seems to me 
that you simply need to introduce a new pair 
> of states that sets the property 
of your icon independently to the state of 
> your tool window. I think you 
problem stems from trying to control 
> orthogonal properties on two object using 
the same pair of states.

So 
> I think you need to have four states in your case:

* drawer_open
* 
> drawer_closed
* icon_in_drawer (set opacity to 0.5)
* icon_not_in_drawer 
> (set opacity to 1)

I would try to arrange these in your state machine as 
> two pairs of parallel 
sub-states since the state of the drawer is 
> independent of the state of the 
icon. You can still get a degree of 
> interaction between them by usign guarded 
transitions. If I have 
> misunderstood your problem then you may need to have a 
different arrangement 
> of states.

If you emit a signal when the icon is moved in or out of the 
> drawer you can 
simply use QSignalTransitions to transition between the icon 
> states.

HTH,

Sean

_______________________________________________
Qt-interest 
> mailing list

> href="mailto:Qt-interest at trolltech.com">Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


      



More information about the Qt-interest-old mailing list