Re: Changing control layouts
Re: Changing control layouts
- Subject: Re: Changing control layouts
- From: Mark Dawson <email@hidden>
- Date: Thu, 17 Feb 2005 09:31:33 -0800
(there's nothing more annoying to
me than to select different objects that I want to say turn green, but
that program's inspector doesn't allow me to edit multiple "different"
objects--in my opinion, I should always be able to edit intersected
properties).
I also find that really annoying. In IB, for example, selecting
mutliple objects and setting their autosizing properties would be
nice. You're right in that it's an implementation limitation.
To do separate inspectors, I would need an inspector for every
combination of objects & properties.
Yeah, obviously this isn't an ideal solution in the case where the
objects share many similar properties.
Especially for graphics programs, it would be often nice to put every
selected object at the same x or y coordinate. Because most programs
don't allow editing of intersecting properties, you typically have to
put one object there, then do an align-to-top (i.e., two steps). For
something like color or line thickness, there is no shortcut--usually
you have to manually select each different object and set it…
Bindings would help you out here nicely. See the multiple values
stuff. One of the things to be aware of in an inspector though is
that, yes, object A and object B may both support the Position
property but they're different for each. How do you represent that in
the UI? You can't have one Position field with two values in it so you
either need 2 Position fields or a "Multiple Selection" marker telling
the user they can't edit multiple things at once.
For text overlaps (such as position), I've seen the use of dashes ("-")
to indicate that the fields are different; I can't remember if I've
seen anything for sliders or color controls. I think they are actually
harder to represent than numbers (as for numbers, you can more easily
cheat and add something like a "-"). I do need to look into this.
As for bindings, my app is currently targeted at 10.2 and above, so I
think bindings are out for now. However, with Tiger on the horizon,
and my app not released, it may make sense to up to 10.3 (i.e., only
support the last two major OS versions).
Off the top of my
head you can look at Delcious Library to a good example of how the
bindings and inspector thing can fit together - the right hand detail
panel is all bindings driven and if you play around for a bit you'll
get the feel of what is possible.
I'll take a look at this.
If you're not into bindings it's more complicated. But here's a
suggestion: Each of your objects has a method that returns a n NSSet
of strings that tell you which property sets it has. "Placement",
"Coloring", "Identifiers", whatever. Run through all the objects
selected and take the union of all their property sets. You could do
this with bitmasks too if you want I guess but it's not as dynamic.
Now you're holding a set of strings that represent the properties that
are common to all the selected objects. For each property set you've
got a Nib. So ... Plaement Nib, Coloring Nib, etc. The Nibs are pretty
standard except that they don't have a window just a view. The files
owner should have an outlet to this view and is an object that stands
in for the property set in your code. Loop through the property set
you've generated, load the nib for each, and stack as children of an
NSView. You'll need to size the parent view dynamically with the
addition of each child. This in turn can either grow the inspector
window or you can have it in an NSScrollView. The result (after
debugging it all) should be an inspector shows a stack of all the
properties editable on all the objects selected. It's nice because
you've got only as many Nibs as you have property sets and it's still
plenty dynamic. Objects can advertise property sets that you don't
nessessarilly have a Nib for yet - you just ignore those gracefully.
That's kind of what I was looking for. However, how does one create a
NIB in IB without a window? I see I can create "Application", "empty",
"Attention panel", "Inspector", and "IB Palette" from a "New…". I
could create an "empty" NIB, but I'm not sure what I first drag in to
create the view that contains that NIB's information (do I use the
"custom view"?)…
I'm not really clean on the nature of your objects. If the you've got
properties that don't group well (unlike x,y,width,height or color,
font, point size, shadow, etc ) then you're dealing with a pretty fine
grained problem. In that case I'd really suggest you use bindings
'cause they'll save you a ton of work. Despite a bit of a leap in the
learning curve because they seem so abstract at first there are some
good resources available and Mmalc is all over any question you ask.
I have some that group (x, y, width, etc) and some that don't (length,
which is separate than width). I'll take a look at the bindings,
though…
Thanks!
Mark
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden