On Tue, 6 Apr 2010, Mattias Gärtner wrote:
Zitat von Michael Van Canneyt <[email protected]>:
On Tue, 6 Apr 2010, Mattias Gärtner wrote:
Zitat von Michael Van Canneyt <[email protected]>:
[...]
I would use a mechanism similar to the datalink. As soon as you tell
the
layout manager to manage a certain control, a hook is installed in the
control.
And where is the hook stored?
In TWinControl, protected or even private.
And how to find out which layout a control uses?
The control has no need to know which layout it uses.
How can a designer tool find out what layout a control uses?
Why does it need to know ?
If it needs to know what layout a control uses, the designer is flawed by
design:
There may be layouters that the designer has no knowledge of, and
hence if such a layouter is dropped on the form, the designer will
be lost.
It just needs to know that it must handle positioning/sizing over to
the layout.
(through the hook).
[...]
Then don't publish it for TEdit.
Btw, even a TEdit can need a layout to store extra properties, for
autosizing itself, for special docking, for alignment or for
designer specials.
I don't believe this should be so. If this is so, then the layouting
is badly designed.
How would you do that?
For example you want a group of TEdits to position/resize according to
a policy, so you set for all your edits a layouter.
I don't see what is to store in the TEdits ?
The 'policy' is a property of the layouter, not of the TEdits.
I understand this, I thought of this also. But I think it is more
clean if the hook is hidden completely; This
way one cannot 'forget' to publish it or publish it when it is not
needed.
Finally, it doesn't really matter. To my taste, my solution is cleaner.
Opinions may vary on what 'clean' is, of course :-)
Your solution seems somewhat limited to the ExtJS layouts.
Maybe, but it has the advantage of being very clear and simple.
And I think clarity is a virtue, for which I am prepared to sacrifice
a few corner cases.
Counter example:
When I first suggested to extend the Anchors I only suggested a simple
anchor to one control. AFAIR it was Marc who said, we should do that
for each side. I thought: This is only useful for a very few corner
cases. Nowadays we use this feature at hundreds of places in the IDE.
I'm very glad that Marc had the foresight.
No problem when using layouters: just create/adapt a new layouter class.
The simplicity and clarity is the following:
Layouter: Layouter manages everything. Each layouter has a few simple
properties that determine it's (and only it's) behaviour, and no more.
Now the TControl/TWinControl classes have a set of properties that is the
union of all properties of a large set of layouters (because it must mimic
the behaviour of all these layouters put together):
* AutoSize
* Anchors
* Align
* Constraints
* BorderSpacing
* ChildSizing
In difference, each layouter would have only the properties that it
needs to implement it's behaviour. That is simple to understand.
Currently, the layouting is simply a mess, with added ad-hoc properties
and no clear rules that determine which property has precedence over
other properties.
See here:
http://wiki.lazarus.freepascal.org/Autosize_/_Layout
I find the concept of a layouter with 1 or 2 properties more clear
than all these properties thrown together.
Michael.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus