Permalink
Browse files

Initial work on the dock frame ui refresh

  • Loading branch information...
1 parent b0ec065 commit 06f554bf2004e44f8646bf5a48e8c8e7ff5203f4 @slluis slluis committed May 15, 2012
@@ -158,8 +158,11 @@ protected override void ForAll (bool include_internals, Gtk.Callback callback)
foreach (Widget w in notebooks)
widgets.Add (w);
foreach (DockItem it in items) {
- if (it.HasWidget && it.Widget.Parent == this)
+ if (it.HasWidget && it.Widget.Parent == this) {
widgets.Add (it.Widget);
+ if (it.TitleTab.Parent == this)
+ widgets.Add (it.TitleTab);
+ }
}
foreach (Widget w in widgets)
callback (w);
@@ -228,6 +231,8 @@ void LayoutWidgets ()
notebooks.Add (ts);
ts.Parent = this;
}
+ frame.UpdateRegionStyle (grp);
+ ts.VisualStyle = grp.VisualStyle;
grp.UpdateNotebook (ts);
}
@@ -336,8 +341,8 @@ bool FindHandle (DockGroup grp, int x, int y, out DockGroup foundGrp, out int ob
for (int n=0; n<grp.VisibleObjects.Count; n++) {
DockObject obj = grp.VisibleObjects [n];
if (n < grp.Objects.Count - 1) {
- if ((grp.Type == DockGroupType.Horizontal && x > obj.Allocation.Right && x < obj.Allocation.Right + frame.TotalHandleSize) ||
- (grp.Type == DockGroupType.Vertical && y > obj.Allocation.Bottom && y < obj.Allocation.Bottom + frame.TotalHandleSize))
+ if ((grp.Type == DockGroupType.Horizontal && x > obj.Allocation.Right && x < obj.Allocation.Right + frame.TotalSensitiveHandleSize) ||
+ (grp.Type == DockGroupType.Vertical && y > obj.Allocation.Bottom && y < obj.Allocation.Bottom + frame.TotalSensitiveHandleSize))
{
foundGrp = grp;
objectIndex = n;
@@ -46,7 +46,7 @@ public class DockFrame: HBox
DockContainer container;
- int handleSize = IsWindows ? 4 : 6;
+ int handleSize = 1;
int handlePadding = 0;
int defaultItemWidth = 300;
int defaultItemHeight = 250;
@@ -99,21 +99,113 @@ public DockFrame ()
get { return compactGuiLevel; }
set {
compactGuiLevel = value;
- switch (compactGuiLevel) {
+/* switch (compactGuiLevel) {
case 1: handleSize = 6; break;
case 2:
case 3: handleSize = IsWindows ? 4 : 6; break;
case 4:
case 5: handleSize = 3; break;
}
- handlePadding = 0;
+*/ handlePadding = 0;
dockBarTop.OnCompactLevelChanged ();
dockBarBottom.OnCompactLevelChanged ();
dockBarLeft.OnCompactLevelChanged ();
dockBarRight.OnCompactLevelChanged ();
container.RelayoutWidgets ();
}
}
+
+ Dictionary<string,string> regionStyles = new Dictionary<string, string> ();
+
+ public void SetRegionStyle (string regionPosition, string style)
+ {
+ regionStyles [regionPosition] = style;
+ }
+
+ internal void UpdateRegionStyle (DockObject obj)
+ {
+ if ((obj is DockGroupItem)) {
+ var s = ((DockGroupItem)obj).Item.VisualStyle;
+ if (!string.IsNullOrEmpty (s) && s != DockStyle.Default) {
+ obj.VisualStyle = s;
+ return;
+ }
+ }
+ obj.VisualStyle = GetRegionStyleForObject (obj);
+ }
+
+ internal string GetRegionStyleForObject (DockObject obj)
+ {
+ foreach (var e in regionStyles) {
+ if (InRegion (e.Key, obj))
+ return e.Value;
+ }
+ return "default";
+ }
+
+ bool InRegion (string location, DockObject obj)
+ {
+ string[] positions = location.Split (';');
+ foreach (string pos in positions) {
+ int i = pos.IndexOf ('/');
+ if (i == -1) continue;
+ string id = pos.Substring (0,i).Trim ();
+ DockGroup g = container.Layout.FindGroupContaining (id);
+ if (g != null) {
+ DockPosition dpos;
+ try {
+ dpos = (DockPosition) Enum.Parse (typeof(DockPosition), pos.Substring(i+1).Trim(), true);
+ }
+ catch {
+ continue;
+ }
+
+ var refItem = g.FindDockGroupItem (id);
+ if (InRegion (g, dpos, refItem, obj))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool InRegion (DockGroup grp, DockPosition pos, DockObject refObject, DockObject objToFind)
+ {
+ if (grp == null)
+ return false;
+
+ if (grp.Type == DockGroupType.Tabbed) {
+ if (pos != DockPosition.Center && pos != DockPosition.CenterBefore)
+ return InRegion (grp.ParentGroup, pos, grp, objToFind);
+ }
+ if (grp.Type == DockGroupType.Horizontal) {
+ if (pos != DockPosition.Left && pos != DockPosition.Right)
+ return InRegion (grp.ParentGroup, pos, grp, objToFind);
+ }
+ if (grp.Type == DockGroupType.Vertical) {
+ if (pos != DockPosition.Top && pos != DockPosition.Bottom)
+ return InRegion (grp.ParentGroup, pos, grp, objToFind);
+ }
+
+ bool left = true;
+ bool findingLeft = pos == DockPosition.Left || pos == DockPosition.Top || pos == DockPosition.CenterBefore;
+
+ foreach (var ob in grp.Objects) {
+ if (ob == refObject)
+ left = false;
+ else if (ob == objToFind)
+ return left == findingLeft;
+ else if (ob is DockGroup) {
+ if (ObjectHasAncestor (objToFind, (DockGroup)ob))
+ return left == findingLeft;
+ }
+ }
+ return InRegion (grp.ParentGroup, pos, grp, objToFind);
+ }
+
+ bool ObjectHasAncestor (DockObject obj, DockGroup ancestorToFind)
+ {
+ return obj != null && (obj.ParentGroup == ancestorToFind || ObjectHasAncestor (obj.ParentGroup, ancestorToFind));
+ }
public DockBar ExtractDockBar (PositionType pos)
{
@@ -185,6 +277,10 @@ internal DockBar GetDockBar (PositionType pos)
internal int TotalHandleSize {
get { return handleSize + handlePadding*2; }
}
+
+ internal int TotalSensitiveHandleSize {
+ get { return 6; }
+ }
public DockItem AddItem (string id)
{
@@ -704,6 +800,12 @@ internal static Cairo.Color ToCairoColor (Gdk.Color color)
return new Cairo.Color (color.Red / (double) ushort.MaxValue, color.Green / (double) ushort.MaxValue, color.Blue / (double) ushort.MaxValue);
}
}
+
+ public class DockStyle
+ {
+ public const string Default = "Default";
+ public const string Browser = "Browser";
+ }
internal delegate void DockDelegate (DockItem item);
@@ -348,7 +348,7 @@ public override void SizeAllocate (Gdk.Rectangle newAlloc)
if (type == DockGroupType.Tabbed) {
if (boundTabStrip != null) {
int tabsHeight = boundTabStrip.SizeRequest ().Height;
- boundTabStrip.SizeAllocate (new Gdk.Rectangle (newAlloc.X, newAlloc.Bottom - tabsHeight, newAlloc.Width, tabsHeight));
+ boundTabStrip.SizeAllocate (new Gdk.Rectangle (newAlloc.X, newAlloc.Y, newAlloc.Width, tabsHeight));
}
if (allocStatus == AllocStatus.Valid && newAlloc == oldAlloc) {
// Even if allocation has not changed, SizeAllocation has to be called on all items to avoid redrawing issues.
@@ -359,6 +359,7 @@ public override void SizeAllocate (Gdk.Rectangle newAlloc)
if (VisibleObjects.Count > 1 && boundTabStrip != null) {
int tabsHeight = boundTabStrip.SizeRequest ().Height;
newAlloc.Height -= tabsHeight;
+ newAlloc.Y += tabsHeight;
boundTabStrip.QueueDraw ();
} else if (VisibleObjects.Count != 0) {
((DockGroupItem)VisibleObjects [0]).Item.Widget.Show ();
@@ -619,7 +620,7 @@ internal void UpdateNotebook (TabStrip ts)
// Add missing pages
foreach (DockObject ob in VisibleObjects) {
DockGroupItem it = ob as DockGroupItem;
- ts.AddTab (it.Item.Widget, it.Item.Icon, it.Item.Label);
+ ts.AddTab (it.Item.TitleTab);
}
boundTabStrip = ts;
@@ -690,9 +691,14 @@ internal void ResetNotebook ()
public void LayoutWidgets ()
{
+ Frame.UpdateRegionStyle (this);
+
foreach (DockObject ob in VisibleObjects) {
DockGroupItem it = ob as DockGroupItem;
if (it != null) {
+ Frame.UpdateRegionStyle (it);
+ it.Item.Widget.VisualStyle = it.VisualStyle;
+ // Add the dock item to the container and show it if visible
if (it.Item.Widget.Parent != Frame.Container) {
if (it.Item.Widget.Parent != null) {
((Gtk.Container)it.Item.Widget.Parent).Remove (it.Item.Widget);
@@ -701,6 +707,19 @@ public void LayoutWidgets ()
}
if (!it.Item.Widget.Visible && type != DockGroupType.Tabbed)
it.Item.Widget.Show ();
+
+ // Do the same for the title tab
+ if ((type != DockGroupType.Tabbed || boundTabStrip == null) && (it.Item.Behavior & DockItemBehavior.NoGrip) == 0) {
+ var tab = it.Item.TitleTab;
+ tab.VisualStyle = it.VisualStyle;
+ if (tab.Parent != Frame.Container) {
+ if (tab.Parent != null) {
+ ((Gtk.Container)tab.Parent).Remove (tab);
+ }
+ Frame.Container.Add (tab);
+ }
+ tab.ShowAll ();
+ }
}
else
((DockGroup)ob).LayoutWidgets ();
@@ -77,12 +77,30 @@ internal override void GetMinSize (out int width, out int height)
internal override Requisition SizeRequest ()
{
- return item.Widget.SizeRequest ();
+ var req = item.Widget.SizeRequest ();
+
+ if (ParentGroup.Type != DockGroupType.Tabbed || ParentGroup.VisibleObjects.Count == 1) {
+ var tr = item.TitleTab.SizeRequest ();
+ req.Height += tr.Height;
+ return req;
+ } else
+ return req;
}
public override void SizeAllocate (Gdk.Rectangle newAlloc)
{
- item.Widget.SizeAllocate (newAlloc);
+ if ((ParentGroup.Type != DockGroupType.Tabbed || ParentGroup.VisibleObjects.Count == 1) && (item.Behavior & DockItemBehavior.NoGrip) == 0) {
+ var tr = newAlloc;
+ tr.Height = item.TitleTab.SizeRequest ().Height;
+ item.TitleTab.SizeAllocate (tr);
+ var wr = newAlloc;
+ wr.Y += tr.Height;
+ wr.Height -= tr.Height;
+ item.Widget.SizeAllocate (wr);
+ }
+ else
+ item.Widget.SizeAllocate (newAlloc);
+
base.SizeAllocate (newAlloc);
}
Oops, something went wrong.

0 comments on commit 06f554b

Please sign in to comment.