Werner F. Bruhin wrote:
> Sent a mail to floatcanvas-request yesterday about this - I
> assume/"hope" this has just gone to byte heaven.
I didn't see it.
> I really don't get it how I would make use of GUIMode(s), i.e. what
> confuses me is that move, resize, delete all need a select object "mode".
well, the idea with GUIMode is that it can define how every mouse event
gets handled, and you can use the GUIMode object to store ephemeral data
you need just for that mode, rather than dumping that into your frame or
whatever.
However, to be honest, there are some missing bits -- I never really
made the complete transition to doing things that way -- hence all the
demos that really should use it!
> The questions I have:
> - Should I have a "Select Mode" which depending on object selected
> enables the use of other modes - seems a bit user "un-friendly" e.g.
> select "select mode" select object, select "other mode" do other thing.
I think this is a UI question, more than a coding one, but most drawing
programs do have a select mode, though I'm not entirely sure what your
needs are. If there aren't many different things you need to do with an
object, there may be no need to have a selected state: i.e. you can move
any object around without selecting it first.
> - Should each mode have the same "select" code.
If you can select object in multiple modes, then I'd think so. You
should be able to do a fair bit with subclassing and mix-ins for this.
> - Can/should one switch mode in an event?
I think so.
> Or is the mode always selected from using a toolbar button or similar.
however, the code is a bit clunky for this -- you need to keep the
toolbar and the Canvas in sync some how, and I haven't put the mechanism
in pace to do that well. I think there should be either:
- use pubsub or something to propagate a "mode changed" event or
something t everything that needs it.
- have FloatCanvas raise a custom "mode changed" event, and have the
toolbar bind to it.
The later is probably less intrusive to the current structure of the
code. You could also write your own code that keeps everything in sync.
I had always intended to have the standard toolbar extensible for custom
applications, but it's a bit klunky to do so now -- it may b easier to
copy and paste the code from NavCanvas, and just write your own.
> - Or should I have some variables in the objects ("deleteAllowed",
> "moveAllowed", "resizeAllowed" etc) and depending on these call
> additional methods within the common event code.
That could work, though I think I'd have different modes for different
types of objects -- with mixins, it should be pretty easy.
> - Is there a standard to indicate that an object is selected.
nope -- I'd look at various drawing programs, etc, and see what you
like. You might want to have your custom draw objects have a IsSelected
flag that alters what the _Draw method does -- or you can have a
separate object for the selction handles etc. See the BNA Editor sample
for one way to do it.
> I am looking for pointers, but would very much appreciate some sample
> code which makes use of GUIMode, but a bit more advanced then the one
> sample I found in the demo. Maybe a sample which shows switching resize
> of e.g. a rectangle and moving it.
I wish I had one! I spent a little while working on a simple drawing
program as a demo, but didn't quite finish it -- I've enclosed what I
have -- it is a bit broken now, but maybe you can get some ideas. I
actually haven't had time to work on it in a while.
> Looking into the code in GUIMode there is a "move" mode which moves
> everything on the canvas.
What that does is move what you see -- also called "panning" (I probably
should have called it that. It changes the viewport, but doesn't alter
the coordinates of the objects at all, only what you see.
> Is there plans or has someone already done an
> "object move" mode?
nope, but it would be great to refactor the MovingObjects demo to use a
GUIMode...
> The attached code (as a 7z zip file, just for reference) includes the
> persistence mixins, but I commented the import of amara (the XML tool I
> use),
What is the status of that -- I played with it a bit and it was great,
but now when I look for it, they seem to have a next generation version,
but it doesn't look done, and I haven't been able to install it.
> Will need to clean up the images for the toolbar but they
> are already better then the "black splotches" I had before.
was I supposed to run:
dxf2gcode_wx28.py
I only get the standard NavCanvas toolbar (on my Mac)
Sorry, not much time to dig into this now. I'm also going on vacation
for the next week or so -- not sure how connected I'll be.
I hope this helps a bit.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
[email protected]
_______________________________________________
FloatCanvas mailing list
[email protected]
http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas