• Keine Ergebnisse gefunden

Shape Alignment and Position

Im Dokument Sketching Slides (Seite 85-89)

4.4 Manipulating Shapes

4.4.3 Shape Alignment and Position

Each handlehis attached to at most one gridline in each direction, i.e., corner handles are attached to one x- and y-gridline. By dragging a handle h and thus the attached gridline the user can express different things. Figure 4.12a shows how the left gridline gl of the object stack is dragged to the left so that it snaps to the table. Assume the handle is moved to coordinate xand let the rightmost gridline of the table be g2. The user has expressed two different things at the same time: Gridline gl is moved to location x and gl

is now identical tog2.

Quisque diam sapien, auctor sit amet, lacinia quis, eleifend sit amet, urna.

Praesent pretium ullamcorper urna.

Praesent nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla. Class aptent taciti sociosqu ad litora torquent per conubia n o s t r a , p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu. Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit

Praesent pretium ullamcorper urna.

Praesent nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla. Class aptent taciti sociosqu ad litora torquent per conubia n o s t r a , p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu. Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit ullamcorper urna. Praesent nulla.

Vestibulum ante ipsum primis in faucibus orci luctus et ultrices p o s u e r e c u b i l i a C u r a e ; U t vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla.

Class aptent taciti sociosqu ad litora torquent per conubia nostra, p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu.

Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit dolor. Curabitur eget magna eget neque bibendum ullamcorper urna. Praesent nulla.

Vestibulum ante ipsum primis in faucibus orci luctus et ultrices p o s u e r e c u b i l i a C u r a e ; U t vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla.

Class aptent taciti sociosqu ad litora torquent per conubia nostra, p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu.

Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit dolor. Curabitur eget magna eget neque bibendum

Figure 4.12: (a) Dragging a gridline changes gridline relations or (b) dragging a gridline changes gridline locations.

Changing the relation between gridlines, i.e., unifying gl and g2 into a single gridline, changes the way gap constraints are collected. Before, there was a gap between g2 and gl that kept the table and the object stack sepa-rated. Now, there can be no gap between g2 and gl anymore, meaning that the table will directly touch the object stack.

Figure 4.12b shows the alternative result if gridlinegl is fixed at location xwithout unifying gl and g2. The object stack has been extended to the left because gl was moved. The relations between the gridlines have remained unchanged, i.e., there is still a gap between gridlinesg2 and gl, and therefore the table has moved left. In a constraint-based layout system, the user should rarely need to explicitly fix a gridline’s position because the gridline positions should be calculated by the layout system.

When a handle is moved, we distinguish two different modes of specifying gridlinerelations and gridline locations as detailed in the interaction princi-ples on page 47. If GS = Ss∈Ss.Gx/y are the gridlines bound to the shape selection and G are the gridlines attached to unselected shapes, the default drag mode maintains the relations of gridlines in each set GS and G but the relations between the two sets may be changed. If the Alt-modifier key is pressed while a handle is moved, the user changes the interaction mode.

In this mode, only the position of gridline gl is fixed. All gridline relations remain constant.

Aligning Gridlines

Quisque diam sapien, auctor sit amet, lacinia quis, eleifend sit amet, urna.

Praesent pretium ullamcorper urna.

Praesent nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla. Class aptent taciti sociosqu ad litora torquent per conubia n o s t r a , p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu. Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit

Praesent pretium ullamcorper urna.

Praesent nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla. Class aptent taciti sociosqu ad litora torquent per conubia n o s t r a , p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu. Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit

Praesent pretium ullamcorper urna.

Praesent nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla. Class aptent taciti sociosqu ad litora torquent per conubia n o s t r a , p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu. Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit

Praesent pretium ullamcorper urna.

Praesent nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla. Class aptent taciti sociosqu ad litora torquent per conubia n o s t r a , p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu. Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit

Figure 4.13: Selected gridlines move along when the dragged gridline passes them.

The selected shapes sS ⊆ S are attached to a subset of all gridlines in each dimension GS =Ss∈Ss.Gx/y ⊆ Gx/y. On each gridline gis.Gx/y of each shapesSwill be at least one handleh, as in the examples of Fig. 4.13.

The example shows how the top-most handle h is dragged downwards and snapped to gridline g0 at the bottom of the table. The handle snaps to gridlineg0 and its occupied spans are highlighted to visualize the snapping.

4.4. MANIPULATING SHAPES 75 If the handle is dropped in this situation, gridlines g0 and gt will be merged and thus top of the object stack will be aligned to the bottom of the table.

While the handlehis dragged downwards, it passes gridlinegc. According to the principle explained above, all gridline relations inside the set of selected gridlines GS remain constant. Thus, when gt moves downwards, it collects all gridlines it passes and gridlinegcis moved downwards too, only separated by an infinitesimal . Gridline gb is of course still at its previous position because its relation to any other gridline in GS has not yet changed. This allows the user to express with a single drag operation that, everything else being equal, two gridlines should be aligned to each other.

gl gc gr

Figure 4.14: Internal gridline gc moves with the dragged gridline gr.

When a gridline is dragged, all other selected gridlines are collected and moved too once they are passed by the dragged gridline. For shapes that have internal gridlines like the pentagon does, this functionality alone is not enough. A pentagon has three gridlines in horizontal direction as Fig. 4.14 shows. When the gridlinegrat the pentagon tip is dragged to the right, grid-linegcshould follow so that the length of the pentagon tip remains constant.

Therefore Alg. 10 begins by collecting the set F of internal gridlines to-gether with their move factors. In the pentagon example, if dragged gridline g is gr, F would contain the pair (gc,1), meaning that gridline gc moves in parallel with gridline gr.

In a selection of multiple shapes, only the gridlines of shape sowning the drag handle are considered, to avoid conflicts between different shapes that would like to move gridlines by a different degree. Then, while the user keeps dragging the handle, the gridline location (v, Gv) is computed in the loop of lines 7-9. As in the previous algorithms, v ∈R is the snapped location and Gv the potentially empty set of gridlines at valuev that the user snapped to.

When the user has finished dragging, the input to procedureInsertGridlines (Alg. 5) is computed, the set of gridlines G0 and of snapped gridlines X.

Algorithm 10: Dragging a handle to change gridline alignment Input: The dragged handle h with the attached dragged gridlineg

and shapes and all selected shapes S.

Output: Moved gridlinesG0 with destination positions D and snapped gridlines X

1 begin

2 F ← ∅

3 foreach g0s.Gx/y do

4 // collect all gridlines of s that move along with g by factor f FF ∪(g0, f ∈R)

5 end

6 (v, Gv)←(g.v,∅)

7 while h is dragged do

8 n← current mouse position in x-direction

9 (v, Gv)←ClosestGridlines(Gx/y, n,snap tolerance constant)

10 end

11 G0 :={g00, . . . , g0n} ←Ss0∈Ss.Gx/y

12 V :={v0, . . . , vn} ← {g00.v, . . . , g0n.v}

13 DV

14 X :={x0, . . . , xn} ← {xi | if gi0.v =g.vGv 6=∅ then xigvGv, else xi ← ◦}

15 foreach gi0G0 with (gi0, f)∈F do

16 digi0.v+f ·(g.v −v)

17 end

18 foreach gi0G0 with (gi0, .)6∈F do

19 find largest k and smallest l,k < i < l, with (g0k, .),(gl0, .)F

20 if g0k.vg0i.vdk > g0i.v then

21 didk

22 else if g0i.vgl0.vgi0.v > dl then

23 didl

24 end

25 end

26 InsertGridlines (V, X, D)

27 MergeGridlines(Gv)

28 end

4.4. MANIPULATING SHAPES 77 If Gv is not empty, all gridlines with the same value as dragged gridline g are snapped to the gridlines Gv. The calculation of the set of destination values D is a bit more complicated. Calculating the destination values for the gridlines in F is straight-forward. For all other gridlines gi0G0, the (at most) two gridlines gk0, gl0 represented in F and surrounding gi0 are searched.

It holds that gk0.vg0i.vgl0.v and di is set so that dkdidl holds.

In other words, all gridlines that are moved directly by dragging the handle are in F. Their position is calculated first and afterwards all other gridline positions are computed such that the order of all gridlines in G0 remains constant.

Moving Gridlines

If the user drags handle h and simultaneously keeps the Alt-key pressed, the position of gridline g is fixed to a specific screen coordinate. Alt is used frequently as a modifier key. In PowerPoint, e.g., it can be used while dragging to disable the snapping. Here, it is used in a similar manner to disable the snapping to gridlines. The visual feedback is exactly the same as in Fig. 4.13. Now, assume handle h is dragged to some value v. Simply setting g.vv may change the relation of gridline g to all other gridlines in Gx/y. Setting the gridline location must maintain all gridline relations however. Adding the constraint g.v = v to the constraint set achieves this elegantly. The layout solver will maintain all relations between gridlines that have been defined previously. The layout solver may not be able to fulfill the constraint however, in which case it will be dropped and the drag operation will have had no effect.

Formally, when handlehis dropped at valuev, a new gridlineg0 is created withg0.v =v. Then procedureTryMergeIntois called, shown in Alg. 11, that manages the partitioning of gridlines to be mergedCMergethat will be passed to the layout algorithm.

Im Dokument Sketching Slides (Seite 85-89)