From: Mark R. <mr...@st...> - 2001-12-13 10:09:40
|
On Wed, Dec 12, 2001 at 09:17:18PM +0100, Bernhard Herzog wrote: > > A property stack more or less guarantees that all the properties (of the > base style) are there. There were some situations where that may not be > true anymore but they're hopefully fixed now. See the file Doc/styles. What exactly is the base style? It seems there are three types of properties: line, fill, font. The base styles seem to derive from 'factory_defaults' which gets initialized with every known property, even if not really appropriate for a given object. I noticed also that text objects were obtaining their base style from FactoryTextStyle(). Shouldn't they use DefaultTextProperties() to construct their PropertyStacks instead? > > The motivation for all this is to have the style dialogs respect > > conflicting style attributes for multiple object selections so as > > not to disturb them when other attributes are changed. > > The dialogs usually only deal with the properties of one style. They > don't really need the whole property stack (with the obvious exception > of the dialog that displayd the entire property stack). So we could have > an editor method that returns a style with only those properties that > the currently selected objects or object parts have in common. > > I'm not sure what that means for, say, the line dialog if the style > returned by that method contains only the line color but not the line > width. Should the line width be grayed out? Probably not, because you > couldn't modify it then. So there'd have to be one way to indicate that > a proprty can be set, but that current value is not the one take from > the selected object. OTOH, that might be too much information for the > user. I've implemented it as follows. When the panel's context_changed() method is called, it passes a list of selected objects and a Property- Stack (probably should be a Style) of common attributes to the dialog widget. The common attributes are compiled using a helper function that should probably go in the Sketch.Graphics.properties module. It uses a new PropertyStack method called get_properties() that updates the stack's cache and returns the __dict__ (minus the 'stack' variable). The dialogs get the appropriate style attributes using getattr with a default of NO_ATTR (just a module-level string). That way 'None' (e.g. no arrows) can be distinguished from 'missing' or 'conflicting'. Widgets for NO_ATTR properties display differently from usual widgets to visually indicate the lack of the style. For example, the check box for 'underline' has three states: on, off, absent. Absent properties use a common color for consistency (low saturation red as I have it now). If Apply is pressed, only non-NO_ATTR properties are set. If the user changes a widget that has a NO_ATTR property, is loses the NO_ATTR state and appears as a normal widget. This was actually a lot easier to implement than it sounds. A simple mixin class makes it easy to add the 'absent' feature to existing gtk widgets. The result looks good IMHO, and I don't think it will prove confusing to the user (in fact it seems very intuitive). It is really no different than the standard paradigm used throughout M$ office and many other apps. Mark |