internal static DockToolbarPosition Create(DockToolbar bar) { if (bar.Floating) return new FloatingPosition (bar); else return new DockedPosition (bar); }
public void Attach(DockToolbar bar) { this.bar = bar; bar.FloatingDock = this; Frame f = new Frame (); f.Shadow = ShadowType.Out; f.Add (bar); Add (f); f.Show (); bar.Show (); Show (); }
void InsertRow(DockToolbar ibar, int offset, int row) { MoveBar (ibar, offset, row); foreach (DockToolbar bar in bars) { if (ibar != bar && bar.DockRow >= row) bar.DockRow++; } SortBars (); UpdateRowHeight (row); }
internal void EndDragBar(DockToolbar bar, uint time) { Pointer.Ungrab (time); if (targetPanel != null) { targetPanel.DropDragBar (bar); targetPanel.EndDragBar (bar); } dragBar = null; }
int GetChildRightOffset(DockToolbar bar) { return bar.DockOffset + bar.Size; }
void SetNewRowPlaceholder(DockToolbar bar, int offset, int toprow) { if (dropRow != -1) RestoreShiftedBars (dropRow); int y = GetRowTop (toprow) - parentFrame.DockMargin; int h = parentFrame.DockMargin * 2; ShowPlaceholder (bar, true, offset, y, GetChildWidth (bar), h); dropOffset = offset; dropRow = toprow; dropNewRow = true; }
void ShowPlaceholder(DockToolbar bar, bool horz, int x, int y, int w, int h) { if (orientation != Orientation.Horizontal) horz = !horz; PanelToWindow (x, y, w, h, out x, out y, out w, out h); bool created = false; if (placeholder == null || horz != currentPlaceholderHorz) { HidePlaceholder (); placeholder = new PlaceholderWindow (parentFrame); placeholderArrow1 = new ArrowWindow (parentFrame, horz ? ArrowWindow.Direction.Right : ArrowWindow.Direction.Down); placeholderArrow2 = new ArrowWindow (parentFrame, horz ? ArrowWindow.Direction.Left : ArrowWindow.Direction.Up); currentPlaceholderHorz = horz; created = true; } int sx, sy; this.GdkWindow.GetOrigin (out sx, out sy); sx += x; sy += y; int mg = -4; placeholder.Move (sx - mg, sy - mg); placeholder.Resize (w + mg*2, h + mg * 2); if (horz) { placeholderArrow1.Move (sx - placeholderArrow1.Width, sy + (h/2) - placeholderArrow1.Height/2); placeholderArrow2.Move (sx + w, sy + (h/2) - placeholderArrow1.Height/2); } else { int px = sx + w/2 - placeholderArrow1.Width/2; if (px < 0) px = 0; placeholderArrow1.Move (px, sy - placeholderArrow1.Height); placeholderArrow2.Move (px, sy + h); } if (created) { placeholder.Show (); placeholder.Present (); if (bar.FloatingDock != null) bar.FloatingDock.Present (); placeholderArrow1.Present (); placeholderArrow2.Present (); } }
bool IsSingleBarRow(DockToolbar bar) { int row = bar.DockRow; foreach (DockToolbar b in bars) { if (bar != b && b.DockRow == row) return false; } return true; }
void MoveBar(DockToolbar bar, int x, int row, bool setAnchorOffset) { int rt = GetRowTop (row); bar.DockRow = row; bar.DockOffset = x; if (bar.Floating) { FloatingDock win = bar.FloatingDock; win.Detach (); win.Destroy (); InternalAdd (bar); Put (bar, x, rt); SortBars (); ResetAnchorOffsets (row); } else { if (setAnchorOffset) ResetAnchorOffsets (row); InternalMove (bar, x, rt, true); } }
public void AddDockToolbar(DockToolbar bar, int offset, int row) { bool ea = EnableAnimation (false); InternalAdd (bar); Put (bar, 0, 0); bar.Orientation = orientation; MoveBar (bar, offset, row, false); bar.AnchorOffset = offset; SortBars (); PackBars (); EnableAnimation (ea); }
public void DropDragBar(DockToolbar bar) { if (!IsPlaceHolderVisible) return; foreach (DockToolbar b in bars) { if (b.DockRow == dropRow && b.DockShiftOffset != -1) { b.DockShiftOffset = -1; b.AnchorOffset = b.DockRow; } } if (dropRow != -1) { if (dropNewRow) InsertRow (bar, dropOffset, dropRow); else { MoveBar (bar, dropOffset, dropRow); UpdateRowHeight (dropRow); } SortBars (); dropRow = -1; } }
internal override void RestorePosition(DockToolbarFrame frame, DockToolbar bar) { frame.DockToolbar (bar, placement, dockOffset, dockRow); }
public void AddDockToolbar(DockToolbar bar) { bool ea = EnableAnimation (false); Put (bar, 0, 0); bar.Orientation = orientation; if (bars.Count > 0 && IsRealized) { DockToolbar last = (DockToolbar) bars [bars.Count - 1]; int width = bar.DefaultSize; int lastx = last.DockOffset + last.DefaultSize; if (lastx + width <= PanelWidth) MoveBar (bar, lastx, last.DockRow, false); else MoveBar (bar, 0, last.DockRow + 1, false); bar.AnchorOffset = bar.DockOffset; InternalAdd (bar); SortBars (); } else { MoveBar (bar, 0, 0); bar.AnchorOffset = bar.DockOffset; InternalAdd (bar); } EnableAnimation (ea); }
internal DockedPosition(DockToolbar bar) { dockOffset = bar.AnchorOffset; dockRow = bar.DockRow; placement = ((DockToolbarPanel)bar.Parent).Placement; }
internal void StartDragBar(DockToolbar bar, int x, int y, uint time) { dragBar = bar; xDragDif = -x; yDragDif = -y; Pointer.Grab (this.GdkWindow, false, EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask, null, new Cursor (CursorType.Hand2), time); if (!bar.Floating) { DockToolbarPanel panel = (DockToolbarPanel) dragBar.Parent; panel.StartDragBar (bar); } }
internal void FloatBar(DockToolbar bar, Orientation orientation, int x, int y) { FloatingDock fdock = new FloatingDock (this); fdock.Move (x, y); bar.ResetSize (); fdock.Attach (bar); bar.Orientation = orientation; }
void InternalAdd(DockToolbar bar) { bars.Add (bar); bar.DefaultSizeChanged += new EventHandler (OnBarSizeChanged); }
public void EndDragBar(DockToolbar bar) { if (IsPlaceHolderVisible) { HidePlaceholder (); } }
void InternalMove(DockToolbar bar, int x, int y, bool animate) { if (bar.Animation != null) { bar.Animation.Cancel (); bar.Animation = null; } if (animate && enableAnimations) { bar.Animation = new MoveAnimation (this, bar, x, y); bar.Animation.Start (); } else Move (bar, x, y); }
public void RemoveBar(DockToolbar bar) { if (IsSingleBarRow (bar)) RemoveRow (bar.DockRow); Remove (bar); bars.Remove (bar); bar.DefaultSizeChanged -= new EventHandler (OnBarSizeChanged); UpdateRowHeight (bar.DockRow); PackBars (); }
void MoveBar(DockToolbar bar, int x, int row) { MoveBar (bar, x, row, true); }
public void Reposition(DockToolbar bar, int xcursor, int ycursor, int difx, int dify) { if (!bar.CanDockTo (this)) return; bar.Orientation = orientation; int x, y; WindowToPanel (xcursor + difx, ycursor + dify, bar.Allocation.Width, bar.Allocation.Height, out x, out y); WindowToPanel (xcursor, ycursor, 0, 0, out xcursor, out ycursor); RepositionInternal (bar, x, y, xcursor, ycursor); }
void RepositionInternal(DockToolbar bar, int x, int y, int xcursor, int ycursor) { int width = GetChildWidth (bar); ycursor = y + bar.DefaultHeight / 2; if (bars.Count == 0 && bar.Floating) { SetNewRowPlaceholder (bar, x, 0); return; } int dx = (x + width) - PanelWidth; if (dx > parentFrame.DockMargin && !bar.Floating) { HidePlaceholder (); FloatBar (bar, x, y); return; } else if (dx > 0) x -= dx; else if (x < -parentFrame.DockMargin && !bar.Floating) { HidePlaceholder (); FloatBar (bar, x, y); return; } else if (x < 0) x = 0; int nx = x; int row = -1; // Get the old bar y position int panelBottom = GetPanelBottom (); if (ycursor < - parentFrame.DockMargin || ycursor > panelBottom + parentFrame.DockMargin) { HidePlaceholder (); FloatBar (bar, x, y); return; } int rtop = 0; int prevtop = 0; row = 0; while (ycursor >= rtop) { prevtop = rtop; row++; if (rtop >= panelBottom) break; rtop += GetRowSize (row - 1); } row--; int ry = ycursor - prevtop; if (ry <= parentFrame.DockMargin && ry >= 0) { SetNewRowPlaceholder (bar, x, row); FloatBar (bar, x, y); return; } else if (ry >= (GetRowSize(row) - parentFrame.DockMargin) || (ry < 0 && -ry < parentFrame.DockMargin)) { SetNewRowPlaceholder (bar, x, row + 1); FloatBar (bar, x, y); return; } // Can't create a new row. Try to fit the bar in the current row // Find the first bar in the row: int ns = -1; for (int n=0; n<bars.Count; n++) { DockToolbar b = (DockToolbar)bars[n]; // Ignore the bar being moved if (b == bar) continue; if (b.DockRow == row) { ns = n; break; } } if (ns == -1) { // There are no other bars, no problem then if (bar.Floating) { SetPlaceholder (bar, nx, row); return; } if ((nx == bar.DockOffset && row == bar.DockRow) || (row != bar.DockRow)) { SetPlaceholder (bar, nx, row); FloatBar (bar, x, y); return; } HidePlaceholder (); MoveBar (bar, nx, row); return; } // Compute the available space, and find the bars at the // left and the right of the bar being moved int gapsTotal = 0; int lastx = 0; int leftIndex=-1, rightIndex = -1; int gapsLeft = 0, gapsRight = 0; for (int n=ns; n<bars.Count; n++) { DockToolbar b = (DockToolbar)bars[n]; // Ignore the bar being moved if (b == bar) continue; if (b.DockRow != row) break; int bx = b.DockOffset; if (bx > x && (rightIndex == -1)) rightIndex = n; else if (bx <= x) leftIndex = n; if (bx < x) gapsLeft += bx - lastx; else { if (lastx < x) { gapsLeft += x - lastx; gapsRight += bx - x; } else gapsRight += bx - lastx; } gapsTotal += bx - lastx; lastx = GetChildRightOffset (b); } if (lastx < x) { gapsLeft += x - lastx; gapsRight += PanelWidth - x; } else { gapsRight += PanelWidth - lastx; } gapsTotal += PanelWidth - lastx; // Is there room for the bar? if (gapsTotal < width) { HidePlaceholder (); FloatBar (bar, x, y); return; } // Shift the bars at the left and the right int oversizeLeft = 0; int oversizeRight = 0; if (leftIndex != -1) { int r = GetChildRightOffset ((DockToolbar) bars [leftIndex]); oversizeLeft = r - nx; } if (rightIndex != -1) { int r = ((DockToolbar) bars [rightIndex]).DockOffset; oversizeRight = (nx + width) - r; } if (oversizeLeft > gapsLeft) oversizeRight += (oversizeLeft - gapsLeft); else if (oversizeRight > gapsRight) oversizeLeft += (oversizeRight - gapsRight); if (leftIndex != -1 && oversizeLeft > 0) { ShiftBar (leftIndex, -oversizeLeft); nx = GetChildRightOffset ((DockToolbar) bars [leftIndex]); } if (rightIndex != -1 && oversizeRight > 0) { ShiftBar (rightIndex, oversizeRight); nx = ((DockToolbar) bars [rightIndex]).DockOffset - width; } if (bar.Floating) { SetPlaceholder (bar, nx, row); return; } if ((nx == bar.DockOffset && row == bar.DockRow) || (row != bar.DockRow)) { if (bar.Floating) { SetPlaceholder (bar, nx, row); FloatBar (bar, x, y); } return; } HidePlaceholder (); MoveBar (bar, nx, row); }
internal FloatingPosition(DockToolbar bar) { orientation = bar.Orientation; bar.FloatingDock.GetPosition (out x, out y); }
void SetPlaceholder(DockToolbar bar, int offset, int row) { if (dropRow != row && dropRow != -1) RestoreShiftedBars (dropRow); ShowPlaceholder (bar, false, offset, GetRowTop (row), GetChildWidth (bar), GetRowSize (row)); dropOffset = offset; dropRow = row; dropNewRow = false; }
public IDockToolbar AddBar(DockToolbar bar, Placement defaultPanel, bool defaultVisible) { bar.SetParentFrame (this); bars.Add (bar); DockToolbarPosition pos = new DockedPosition (defaultPanel); DockToolbarStatus s = new DockToolbarStatus (bar.Id, defaultVisible, pos); bar.DefaultStatus = s; bar.Status = s; return bar; }
public void StartDragBar(DockToolbar bar) { }
internal void DockToolbar(DockToolbar bar, Placement placement, int offset, int row) { DockToolbarPanel p = GetPanel (placement); if (row != -1) p.AddDockToolbar (bar, offset, row); else p.AddDockToolbar (bar); }
internal override void RestorePosition(DockToolbarFrame frame, DockToolbar bar) { frame.FloatBar (bar, orientation, x, y); }
void FloatBar(DockToolbar bar, int x, int y) { if (bar.Floating) return; int wx,wy,w,h; PanelToWindow (x, y, GetChildWidth (bar), bar.DefaultHeight, out x, out y, out w, out h); this.GdkWindow.GetOrigin (out wx, out wy); RemoveBar (bar); parentFrame.FloatBar (bar, orientation, wx + x, wy + y); }