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

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


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 :)

thanks
MihailNaydenov



Original Message ----
> From: K. Frank <kfrank29.c at gmail.com>
> To: Qt-interest <qt-interest at trolltech.com>
> Sent: Wed, April 14, 2010 8:52:37 PM
> Subject: Re: [Qt-interest] Is it possible with the State Machine Framework?
> 
> Mihail -

Could you give a little more information about what you are 
> trying to
accomplish?
Perhaps a concrete example -- even if a toy -- would 
> be helpful.

On Wed, Apr 14, 2010 at 1:06 PM, Mihail Naydenov <
> ymailto="mailto:mlists at ymail.com" 
> href="mailto:mlists at ymail.com">mlists at ymail.com> wrote:
> Hello, 
> first I must note Im pretty new with The State Machine Framework, but 
> nevertheless I like it *very* much! I see it as the biggest feature that hit Qt 
> in the recent years!
>
> Now, the idea to let a state control 
> objects is *great*, it adds really nice abstraction to the object management. 
> (Adding animations for the transitions is even greater)

Could you be more 
> specific about what you mean by having a state
control an object?

> 
> However, I ran into trouble on how to specify witch state manages which 
> object(s)?

This I don't follow.  You wish to associate object(s) 
> with a state in
some way.  What
do you mean by this, and what is it 
> supposed to accomplish?

> I can state->assignProperty(object, 
> property, value)
> but there is no unassignProperty :\

> Im 
> probably "doing it wrong", but I imagined objects can be "moved around" states? 
> Is it possible?

I don't know what you mean by "moved around."

> 
> How can I make a state no longer assign property?
> I have read all the 
> docs and studied all samples.
> Im I missing something?
>
> 
> Thank You
> MihailNaydenov

If you good give us a use case and toy 
> design sketch, maybe we could give you
some advice about how best (or 
> whether) to use state machines to accomplish
your goal.

Good 
> luck.


K. 
> Frank
_______________________________________________
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