# Shapes layout proposal

• From: John Palmieri <johnp martianrock com>
• To: dia-list gnome org
• Subject: Shapes layout proposal
• Date: Tue, 12 Jun 2001 15:59:25 +0100

```Well, I was racking my head for a simple algorithm that could be used
for layouts involving dynamic shapes (ie UML shapes that "grow" when
data is placed in them).  I hadn't realized how simple the algorithm
could be.  First off I must introduce the concept of a container shape.
Container shapes would be shapes that held widgets for entering data
(most likely they would be rectangles).  These shapes have the ability
to expand or contract based on the size of the widgets contained within
them.  Naturally when a container shape expands or contracts all other
shapes must be translated or stretched accordingly.  Since container
resizing only modifies the y2 and x2 points we simply compare these
points to every other point in the composited shape.  All points with a
y >= the container shape's y2 (assuming the origin is the upper left of
the screen) are translated according to the delta of the container
shape's y2. The same goes for the x components.  This allows for one
algorithm to handle both stretching and translation.  Here is a visual
example:

+-+--------------+
|    |                      |
| 1 |    Container   |              shape is placed on dia's canvas
|    |                      |
+-+--------------+
|            2             |
+-----------------+

+-+--------------+            container shape is stretched
|    |                      |             in the y direction by data
| 1 |    Container   |             manually entered.
|    |                      |
|    |                      |             All y points on shape 2 are
|    |                      |             >= to Container's y2. shape 2
+-+--------------+             is translated.
|            2             |
+-----------------+           Only the bottom two y points on
shape 1 are >= Container's y2.
shape 1 is stretched.

+-+-------------------+   container shape is stretched
|    |                              |    in the x direction by data
| 1 |    Container           |    manually entered.
|    |                              |
|    |                              |    All x points on shape 1 are not

|    |                              |    >= to Container's x2. shape 1
+-+-------------------+    stays the same.
|            2                     |
+----------------------+    Only the right two x points on
shape 2 are >= Container's x2.
shape 2 is stretched.

While this doesn't answer all layout questions it seems like a good
start to getting rid of hard coded shapes (I'm thinking of UML) and
pushing dia to become a pretty nifty frontend/widget for a wide range of
development tools.

More to come

-J5

```

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]