Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial work on the dock frame ui refresh

  • Loading branch information...
commit 06f554bf2004e44f8646bf5a48e8c8e7ff5203f4 1 parent b0ec065
@slluis slluis authored
View
11 main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockContainer.cs
@@ -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;
View
108 main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockFrame.cs
@@ -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,14 +99,14 @@ 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 ();
@@ -114,6 +114,98 @@ public DockFrame ()
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);
View
23 main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockGroup.cs
@@ -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 ();
View
22 main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockGroupItem.cs
@@ -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);
}
View
98 main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItem.cs
@@ -32,6 +32,7 @@
using System.Xml;
using Gtk;
using Mono.Unix;
+using Mono.TextEditor;
namespace MonoDevelop.Components.Docking
{
@@ -63,7 +64,12 @@ public class DockItem
DockItemToolbar toolbarBottom;
DockItemToolbar toolbarLeft;
DockItemToolbar toolbarRight;
-
+
+ Tab titleTab;
+ bool allowPlaceholderDocking;
+ static Gdk.Cursor fleurCursor = new Gdk.Cursor (Gdk.CursorType.Fleur);
+ static Gdk.Cursor handCursor = new Gdk.Cursor (Gdk.CursorType.Hand2);
+
public event EventHandler VisibleChanged;
public event EventHandler ContentVisibleChanged;
public event EventHandler ContentRequired;
@@ -74,13 +80,11 @@ internal DockItem (DockFrame frame, string id)
this.id = id;
}
- internal DockItem (DockFrame frame, Widget w, string id)
+ internal DockItem (DockFrame frame, Widget w, string id): this (frame, id)
{
- this.frame = frame;
- this.id = id;
content = w;
}
-
+
public string Id {
get { return id; }
}
@@ -94,8 +98,8 @@ internal DockItem (DockFrame frame, Widget w, string id)
get { return label ?? string.Empty; }
set {
label = value;
- if (widget != null)
- widget.Label = label;
+ if (titleTab != null)
+ titleTab.SetLabel (widget, icon, label);
frame.UpdateTitle (this);
if (floatingWindow != null)
floatingWindow.Title = GetWindowTitle ();
@@ -118,6 +122,78 @@ public bool VisibleInLayout (string layout)
return frame.GetVisible (this, layout);
}
+ internal Tab TitleTab {
+ get {
+ if (titleTab == null) {
+ titleTab = new Tab ();
+ titleTab.SetLabel (Widget, icon, label);
+ titleTab.ShowAll ();
+ titleTab.ButtonPressEvent += HeaderButtonPress;
+ titleTab.ButtonPressEvent += HeaderButtonPress;
+ titleTab.ButtonReleaseEvent += HeaderButtonRelease;
+ titleTab.MotionNotifyEvent += HeaderMotion;
+ titleTab.KeyPressEvent += HeaderKeyPress;
+ titleTab.KeyReleaseEvent += HeaderKeyRelease;
+ }
+ return titleTab;
+ }
+ }
+
+ void HeaderButtonPress (object ob, Gtk.ButtonPressEventArgs args)
+ {
+ if (args.Event.TriggersContextMenu ()) {
+ ShowDockPopupMenu (args.Event.Time);
+ args.RetVal = false;
+ } else if (args.Event.Button == 1) {
+ frame.ShowPlaceholder ();
+ titleTab.GdkWindow.Cursor = fleurCursor;
+ frame.Toplevel.KeyPressEvent += HeaderKeyPress;
+ frame.Toplevel.KeyReleaseEvent += HeaderKeyRelease;
+ allowPlaceholderDocking = true;
+ }
+ }
+
+ void HeaderButtonRelease (object ob, Gtk.ButtonReleaseEventArgs args)
+ {
+ if (!args.Event.TriggersContextMenu () && args.Event.Button == 1) {
+ frame.DockInPlaceholder (this);
+ frame.HidePlaceholder ();
+ if (titleTab.GdkWindow != null)
+ titleTab.GdkWindow.Cursor = handCursor;
+ frame.Toplevel.KeyPressEvent -= HeaderKeyPress;
+ frame.Toplevel.KeyReleaseEvent -= HeaderKeyRelease;
+ }
+ }
+
+ [GLib.ConnectBeforeAttribute]
+ void HeaderKeyPress (object ob, Gtk.KeyPressEventArgs a)
+ {
+ if (a.Event.Key == Gdk.Key.Control_L || a.Event.Key == Gdk.Key.Control_R) {
+ allowPlaceholderDocking = false;
+ frame.UpdatePlaceholder (this, titleTab.Allocation.Size, false);
+ }
+ if (a.Event.Key == Gdk.Key.Escape) {
+ frame.HidePlaceholder ();
+ frame.Toplevel.KeyPressEvent -= HeaderKeyPress;
+ frame.Toplevel.KeyReleaseEvent -= HeaderKeyRelease;
+ Gdk.Pointer.Ungrab (0);
+ }
+ }
+
+ [GLib.ConnectBeforeAttribute]
+ void HeaderKeyRelease (object ob, Gtk.KeyReleaseEventArgs a)
+ {
+ if (a.Event.Key == Gdk.Key.Control_L || a.Event.Key == Gdk.Key.Control_R) {
+ allowPlaceholderDocking = true;
+ frame.UpdatePlaceholder (this, titleTab.Allocation.Size, true);
+ }
+ }
+
+ void HeaderMotion (object ob, Gtk.MotionNotifyEventArgs args)
+ {
+ frame.UpdatePlaceholder (this, titleTab.Allocation.Size, allowPlaceholderDocking);
+ }
+
public DockItemStatus Status {
get {
return frame.GetStatus (this);
@@ -137,12 +213,13 @@ public bool VisibleInLayout (string layout)
if (widget == null) {
widget = new DockItemContainer (frame, this);
widget.Visible = false; // Required to ensure that the Shown event is fired
- widget.Label = label;
widget.Shown += SetupContent;
}
return widget;
}
}
+
+ public string VisualStyle { get; set; }
void SetupContent (object ob, EventArgs args)
{
@@ -247,6 +324,8 @@ public DockItemToolbar GetToolbar (PositionType position)
}
set {
icon = value;
+ if (titleTab != null)
+ titleTab.SetLabel (widget, icon, label);
}
}
@@ -272,7 +351,8 @@ public DockItemToolbar GetToolbar (PositionType position)
public bool DrawFrame {
get {
- return drawFrame;
+ return false;
+// return drawFrame;
}
set {
drawFrame = value;
View
226 main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemContainer.cs
@@ -32,42 +32,19 @@
using Gtk;
using Mono.Unix;
using Mono.TextEditor;
+using MonoDevelop.Ide.Gui;
namespace MonoDevelop.Components.Docking
{
class DockItemContainer: VBox
{
- static Gdk.Pixbuf pixClose;
- static Gdk.Pixbuf pixAutoHide;
- static Gdk.Pixbuf pixDock;
-
- Gtk.Label title;
- Gtk.Button btnClose;
- Gtk.Button btnDock;
- string txt;
- Gtk.EventBox header;
- Gtk.Alignment headerAlign;
DockFrame frame;
DockItem item;
Widget widget;
Container borderFrame;
- bool allowPlaceholderDocking;
bool pointerHover;
Box contentBox;
-
- static Gdk.Cursor fleurCursor = new Gdk.Cursor (Gdk.CursorType.Fleur);
- static Gdk.Cursor handCursor = new Gdk.Cursor (Gdk.CursorType.Hand2);
-
- static DockItemContainer ()
- {
- try {
- pixClose = Gdk.Pixbuf.LoadFromResource ("stock-close-12.png");
- pixAutoHide = Gdk.Pixbuf.LoadFromResource ("stock-auto-hide.png");
- pixDock = Gdk.Pixbuf.LoadFromResource ("stock-dock.png");
- } catch (Exception) {
- }
- }
-
+
public DockItemContainer (DockFrame frame, DockItem item)
{
this.frame = frame;
@@ -76,55 +53,6 @@ public DockItemContainer (DockFrame frame, DockItem item)
ResizeMode = Gtk.ResizeMode.Queue;
Spacing = 0;
- title = new Gtk.Label ();
- title.Xalign = 0;
- title.Xpad = 3;
- title.UseMarkup = true;
- title.Ellipsize = Pango.EllipsizeMode.End;
-
- btnDock = new Button (new Gtk.Image (pixAutoHide));
- btnDock.Relief = ReliefStyle.None;
- btnDock.CanFocus = false;
- btnDock.WidthRequest = btnDock.HeightRequest = 17;
- btnDock.Clicked += OnClickDock;
-
- btnClose = new Button (new Gtk.Image (pixClose));
- btnClose.TooltipText = Catalog.GetString ("Hide");
- btnClose.Relief = ReliefStyle.None;
- btnClose.CanFocus = false;
- btnClose.WidthRequest = btnClose.HeightRequest = 17;
- btnClose.Clicked += delegate {
- item.Visible = false;
- };
-
- HBox box = new HBox (false, 0);
- box.PackStart (title, true, true, 0);
- box.PackEnd (btnClose, false, false, 0);
- box.PackEnd (btnDock, false, false, 0);
-
- headerAlign = new Alignment (0.0f, 0.0f, 1.0f, 1.0f);
- headerAlign.TopPadding = headerAlign.BottomPadding = headerAlign.RightPadding = headerAlign.LeftPadding = 1;
- headerAlign.Add (box);
-
- header = new EventBox ();
- header.Events |= Gdk.EventMask.KeyPressMask | Gdk.EventMask.KeyReleaseMask;
- header.ButtonPressEvent += HeaderButtonPress;
- header.ButtonReleaseEvent += HeaderButtonRelease;
- header.MotionNotifyEvent += HeaderMotion;
- header.KeyPressEvent += HeaderKeyPress;
- header.KeyReleaseEvent += HeaderKeyRelease;
- header.Add (headerAlign);
- header.ExposeEvent += HeaderExpose;
- header.Realized += delegate {
- header.GdkWindow.Cursor = handCursor;
- };
-
- foreach (Widget w in new Widget [] { header, btnDock, btnClose }) {
- w.EnterNotifyEvent += HeaderEnterNotify;
- w.LeaveNotifyEvent += HeaderLeaveNotify;
- }
-
- PackStart (header, false, false, 0);
ShowAll ();
PackStart (item.GetToolbar (PositionType.Top).Container, false, false, 0);
@@ -145,7 +73,9 @@ public DockItemContainer (DockFrame frame, DockItem item)
UpdateBehavior ();
}
-
+
+ public string VisualStyle { get; set; }
+
void OnClickDock (object s, EventArgs a)
{
if (item.Status == DockItemStatus.AutoHide || item.Status == DockItemStatus.Floating)
@@ -159,7 +89,10 @@ public void UpdateContent ()
if (widget != null)
((Gtk.Container)widget.Parent).Remove (widget);
widget = item.Content;
-
+
+ if (widget != null)
+ SetStyle (widget);
+
if (item.DrawFrame) {
if (borderFrame == null) {
borderFrame = new CustomFrame (1, 1, 1, 1);
@@ -180,128 +113,51 @@ public void UpdateContent ()
widget.Show ();
}
}
-
- public void UpdateBehavior ()
+
+ void SetStyle (Gtk.Widget w)
{
- btnClose.Visible = (item.Behavior & DockItemBehavior.CantClose) == 0;
- header.Visible = (item.Behavior & DockItemBehavior.Locked) == 0;
- btnDock.Visible = (item.Behavior & DockItemBehavior.CantAutoHide) == 0;
-
- if (item.Status == DockItemStatus.AutoHide || item.Status == DockItemStatus.Floating) {
- btnDock.Image = new Gtk.Image (pixDock);
- btnDock.TooltipText = Catalog.GetString ("Dock");
+ if (w is Gtk.TreeView) {
+ if (w.IsRealized)
+ OnTreeRealized (w, null);
+ else
+ w.Realized += OnTreeRealized;
}
else {
- btnDock.Image = new Gtk.Image (pixAutoHide);
- btnDock.TooltipText = Catalog.GetString ("Auto Hide");
- }
- }
-
- void HeaderButtonPress (object ob, Gtk.ButtonPressEventArgs args)
- {
- if (args.Event.TriggersContextMenu ()) {
- item.ShowDockPopupMenu (args.Event.Time);
- } else if (args.Event.Button == 1) {
- frame.ShowPlaceholder ();
- header.GdkWindow.Cursor = fleurCursor;
- frame.Toplevel.KeyPressEvent += HeaderKeyPress;
- frame.Toplevel.KeyReleaseEvent += HeaderKeyRelease;
- allowPlaceholderDocking = true;
- }
- }
-
- void HeaderButtonRelease (object ob, Gtk.ButtonReleaseEventArgs args)
- {
- if (!args.Event.TriggersContextMenu () && args.Event.Button == 1) {
- frame.DockInPlaceholder (item);
- frame.HidePlaceholder ();
- if (header.GdkWindow != null)
- header.GdkWindow.Cursor = handCursor;
- frame.Toplevel.KeyPressEvent -= HeaderKeyPress;
- frame.Toplevel.KeyReleaseEvent -= HeaderKeyRelease;
- }
- }
-
- void HeaderMotion (object ob, Gtk.MotionNotifyEventArgs args)
- {
- frame.UpdatePlaceholder (item, Allocation.Size, allowPlaceholderDocking);
- }
-
- [GLib.ConnectBeforeAttribute]
- void HeaderKeyPress (object ob, Gtk.KeyPressEventArgs a)
- {
- if (a.Event.Key == Gdk.Key.Control_L || a.Event.Key == Gdk.Key.Control_R) {
- allowPlaceholderDocking = false;
- frame.UpdatePlaceholder (item, Allocation.Size, false);
- }
- if (a.Event.Key == Gdk.Key.Escape) {
- frame.HidePlaceholder ();
- frame.Toplevel.KeyPressEvent -= HeaderKeyPress;
- frame.Toplevel.KeyReleaseEvent -= HeaderKeyRelease;
- Gdk.Pointer.Ungrab (0);
- }
- }
-
- [GLib.ConnectBeforeAttribute]
- void HeaderKeyRelease (object ob, Gtk.KeyReleaseEventArgs a)
- {
- if (a.Event.Key == Gdk.Key.Control_L || a.Event.Key == Gdk.Key.Control_R) {
- allowPlaceholderDocking = true;
- frame.UpdatePlaceholder (item, Allocation.Size, true);
+ var c = w as Gtk.Container;
+ if (c != null) {
+ foreach (var cw in c.Children)
+ SetStyle (cw);
+ }
}
}
-
- private void HeaderExpose (object ob, Gtk.ExposeEventArgs a)
+
+ void OnTreeRealized (object sender, EventArgs e)
{
- Gdk.Rectangle rect = new Gdk.Rectangle (0, 0, header.Allocation.Width - 1, header.Allocation.Height);
- HslColor gcol = frame.Style.Background (Gtk.StateType.Normal);
-
- if (pointerHover)
- gcol.L *= 1.05;
- gcol.L = Math.Min (1, gcol.L);
-
- using (Cairo.Context cr = Gdk.CairoHelper.Create (a.Event.Window)) {
- cr.NewPath ();
- cr.MoveTo (0, 0);
- cr.RelLineTo (rect.Width, 0);
- cr.RelLineTo (0, rect.Height);
- cr.RelLineTo (-rect.Width, 0);
- cr.RelLineTo (0, -rect.Height);
- cr.ClosePath ();
- Cairo.SolidPattern solidPattern = new Cairo.SolidPattern (gcol);
- cr.Pattern = solidPattern;
- cr.FillPreserve ();
- solidPattern.Destroy ();
-
- cr.NewPath ();
- cr.LineWidth = 1d;
- cr.Color = (HslColor) frame.Style.Dark (StateType.Normal);
- cr.Rectangle (rect.X + 0.5d, rect.Y + 0.5d, rect.Width, rect.Height);
- cr.Stroke ();
+ var w = (Gtk.TreeView)sender;
+ if (VisualStyle == DockStyle.Browser) {
+ w.ModifyBase (StateType.Normal, Styles.BrowserPadBackground);
+ w.ModifyBase (StateType.Insensitive, Styles.BrowserPadBackground);
+// w.ModifyBase (StateType.Active, Styles.BrowserPadBackground);
+ // w.ModifyBase (StateType.Prelight, Styles.BrowserPadBackground);
+ } else {
+ w.ModifyBase (StateType.Normal, Parent.Style.Base (StateType.Normal));
+ w.ModifyBase (StateType.Insensitive, Parent.Style.Base (StateType.Insensitive));
}
-
- foreach (Widget child in header.Children)
- header.PropagateExpose (child, a.Event);
}
- private void HeaderLeaveNotify (object ob, EventArgs a)
+ public void UpdateBehavior ()
{
- pointerHover = false;
- header.QueueDraw ();
}
-
- private void HeaderEnterNotify (object ob, EventArgs a)
+
+ protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
- pointerHover = true;
- header.QueueDraw ();
- }
-
- public string Label {
- get { return txt; }
- set {
- title.Markup = "<small>" + value + "</small>";
- txt = value;
+ if (VisualStyle == DockStyle.Browser) {
+ Gdk.GC gc = new Gdk.GC (GdkWindow);
+ gc.RgbFgColor = Styles.BrowserPadBackground;
+ evnt.Window.DrawRectangle (gc, true, Allocation);
+ gc.Dispose ();
}
+ return base.OnExposeEvent (evnt);
}
}
View
11 main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemToolbar.cs
@@ -32,7 +32,7 @@ namespace MonoDevelop.Components.Docking
public class DockItemToolbar
{
DockItem parentItem;
- CustomFrame frame;
+ Gtk.Widget frame;
Box box;
PositionType position;
bool empty = true;
@@ -41,7 +41,7 @@ internal DockItemToolbar (DockItem parentItem, PositionType position)
{
this.parentItem = parentItem;
frame = new CustomFrame ();
- switch (position) {
+/* switch (position) {
case PositionType.Top:
frame.SetMargins (0, 0, 1, 1);
frame.SetPadding (0, 2, 2, 0);
@@ -58,15 +58,16 @@ internal DockItemToolbar (DockItem parentItem, PositionType position)
frame.SetMargins (0, 1, 0, 1);
frame.SetPadding (0, 0, 2, 2);
break;
- }
+ }*/
this.position = position;
if (position == PositionType.Top || position == PositionType.Bottom)
box = new HBox (false, 3);
else
box = new VBox (false, 3);
box.Show ();
- frame.Add (box);
- frame.GradientBackround = true;
+ frame = box;
+// frame.Add (box);
+// frame.GradientBackround = true;
}
public DockItem DockItem {
View
4 main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockObject.cs
@@ -41,7 +41,7 @@ internal abstract class DockObject
DockGroup parentGroup;
DockFrame frame;
Gdk.Rectangle rect;
-
+
// The current size in pixels of this item
double size = -1;
@@ -109,6 +109,8 @@ public DockObject (DockFrame frame)
}
}
}
+
+ public string VisualStyle { get; set; }
internal void ResetDefaultSize ()
{
View
287 main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/TabStrip.cs
@@ -31,28 +31,28 @@
using Gtk;
using System;
+using MonoDevelop.Ide.Gui;
namespace MonoDevelop.Components.Docking
{
- class TabStrip: Notebook
+ class TabStrip: Gtk.EventBox
{
int currentTab = -1;
bool ellipsized = true;
HBox box = new HBox ();
DockFrame frame;
Label bottomFiller = new Label ();
-
+ string visualStyle;
+
public TabStrip (DockFrame frame)
{
this.frame = frame;
frame.ShadedContainer.Add (this);
VBox vbox = new VBox ();
- box = new HBox ();
+ box = new TabStripBox () { TabStrip = this };
vbox.PackStart (box, false, false, 0);
- vbox.PackStart (bottomFiller, false, false, 0);
- AppendPage (vbox, null);
- ShowBorder = false;
- ShowTabs = false;
+ // vbox.PackStart (bottomFiller, false, false, 0);
+ Add (vbox);
ShowAll ();
bottomFiller.Hide ();
BottomPadding = 3;
@@ -65,18 +65,38 @@ public TabStrip (DockFrame frame)
bottomFiller.Visible = value > 0;
}
}
+
+ public string VisualStyle {
+ get { return visualStyle; }
+ set {
+ visualStyle = value;
+ foreach (Tab t in box.Children)
+ t.VisualStyle = value;
+ box.QueueDraw ();
+ }
+ }
public void AddTab (Gtk.Widget page, Gdk.Pixbuf icon, string label)
{
Tab tab = new Tab ();
tab.SetLabel (page, icon, label);
tab.ShowAll ();
+ AddTab (tab);
+ }
+
+ public void AddTab (Tab tab)
+ {
+ if (tab.Parent != null)
+ ((Gtk.Container)tab.Parent).Remove (tab);
+
+ tab.VisualStyle = VisualStyle;
+
box.PackStart (tab, true, true, 0);
if (currentTab == -1)
CurrentTab = box.Children.Length - 1;
else {
tab.Active = false;
- page.Hide ();
+ tab.Page.Hide ();
}
tab.ButtonPressEvent += OnTabPress;
@@ -143,10 +163,8 @@ public void Clear ()
{
ellipsized = true;
currentTab = -1;
- foreach (Widget w in box.Children) {
+ foreach (Widget w in box.Children)
box.Remove (w);
- w.Destroy ();
- }
}
void OnTabPress (object s, Gtk.ButtonPressEventArgs args)
@@ -178,115 +196,34 @@ void UpdateEllipsize (Gdk.Rectangle allocation)
}
ellipsized = ellipsize;
}
- }
-
- public Gdk.Rectangle GetTabArea (int ntab)
- {
- Gtk.Widget[] tabs = box.Children;
- Tab tab = (Tab) tabs[ntab];
- Gdk.Rectangle rect = GetTabArea (tab, ntab);
- int x, y;
- tab.GdkWindow.GetRootOrigin (out x, out y);
- rect.X += x;
- rect.Y += y;
- return rect;
}
-
- protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+
+ internal class TabStripBox: HBox
{
- frame.ShadedContainer.DrawBackground (this);
+ public TabStrip TabStrip;
- Gtk.Widget[] tabs = box.Children;
- for (int n=tabs.Length - 1; n>=0; n--) {
- Tab tab = (Tab) tabs [n];
- if (n != currentTab)
- DrawTab (evnt, tab, n);
- }
- if (currentTab != -1) {
- Tab ctab = (Tab) tabs [currentTab];
-// GdkWindow.DrawLine (Style.DarkGC (Gtk.StateType.Normal), Allocation.X, Allocation.Y, Allocation.Right, Allocation.Y);
- DrawTab (evnt, ctab, currentTab);
+ protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+ {
+ if (TabStrip.VisualStyle == DockStyle.Browser) {
+ var alloc = Allocation;
+ var c = new HslColor (Styles.BrowserPadBackground);
+ c.L *= 0.9;
+ Gdk.GC gc = new Gdk.GC (GdkWindow);
+ gc.RgbFgColor = c;
+ evnt.Window.DrawRectangle (gc, true, alloc);
+ gc.Dispose ();
+
+ Gdk.GC bgc = new Gdk.GC (GdkWindow);
+ c = new HslColor (Styles.BrowserPadBackground);
+ c.L *= 0.7;
+ bgc.RgbFgColor = c;
+ evnt.Window.DrawLine (bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
+ bgc.Dispose ();
+ }
+ return base.OnExposeEvent (evnt);
}
- return base.OnExposeEvent (evnt);
- }
-
- public Gdk.Rectangle GetTabArea (Tab tab, int pos)
- {
- Gdk.Rectangle rect = tab.Allocation;
-
- int xdif = 0;
- if (pos > 0)
- xdif = 2;
-
- int reqh;
-// StateType st;
-
- if (tab.Active) {
-// st = StateType.Normal;
- reqh = tab.Allocation.Height;
- }
- else {
- reqh = tab.Allocation.Height - 3;
-// st = StateType.Active;
- }
-
- if (DockFrame.IsWindows) {
- rect.Height = reqh - 1;
- rect.Width--;
- if (pos > 0) {
- rect.X--;
- rect.Width++;
- }
- return rect;
- }
- else {
- rect.X -= xdif;
- rect.Width += xdif;
- rect.Height = reqh;
- return rect;
- }
- }
-
- void DrawTab (Gdk.EventExpose evnt, Tab tab, int pos)
- {
- Gdk.Rectangle rect = GetTabArea (tab, pos);
- StateType st;
- if (tab.Active)
- st = StateType.Normal;
- else
- st = StateType.Active;
-
- if (DockFrame.IsWindows) {
- GdkWindow.DrawRectangle (Style.DarkGC (Gtk.StateType.Normal), false, rect);
- rect.X++;
- rect.Width--;
- if (tab.Active) {
- GdkWindow.DrawRectangle (Style.LightGC (Gtk.StateType.Normal), true, rect);
- }
- else {
- using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) {
- cr.NewPath ();
- cr.MoveTo (rect.X, rect.Y);
- cr.RelLineTo (rect.Width, 0);
- cr.RelLineTo (0, rect.Height);
- cr.RelLineTo (-rect.Width, 0);
- cr.RelLineTo (0, -rect.Height);
- cr.ClosePath ();
- Cairo.Gradient pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, rect.Y + rect.Height);
- Cairo.Color color1 = DockFrame.ToCairoColor (Style.Mid (Gtk.StateType.Normal));
- pat.AddColorStop (0, color1);
- color1.R *= 1.2;
- color1.G *= 1.2;
- color1.B *= 1.2;
- pat.AddColorStop (1, color1);
- cr.Pattern = pat;
- cr.FillPreserve ();
- }
- }
- }
- else
- Gtk.Style.PaintExtension (Style, GdkWindow, st, ShadowType.Out, evnt.Area, this, "tab", rect.X, rect.Y, rect.Width, rect.Height, Gtk.PositionType.Top);
}
+
}
class Tab: Gtk.EventBox
@@ -295,18 +232,27 @@ class Tab: Gtk.EventBox
Gtk.Widget page;
Gtk.Label labelWidget;
int labelWidth;
+ string visualStyle;
- const int TopPadding = 2;
- const int BottomPadding = 4;
- const int TopPaddingActive = 3;
- const int BottomPaddingActive = 5;
- const int HorzPadding = 5;
+ const int TopPadding = 7;
+ const int BottomPadding = 7;
+ const int TopPaddingActive = 7;
+ const int BottomPaddingActive = 7;
+ const int HorzPadding = 11;
public Tab ()
{
this.VisibleWindow = false;
}
-
+
+ public string VisualStyle {
+ get { return visualStyle; }
+ set {
+ visualStyle = value;
+ QueueDraw ();
+ }
+ }
+
public void SetLabel (Gtk.Widget page, Gdk.Pixbuf icon, string label)
{
Pango.EllipsizeMode oldMode = Pango.EllipsizeMode.End;
@@ -329,6 +275,7 @@ public void SetLabel (Gtk.Widget page, Gdk.Pixbuf icon, string label)
if (!string.IsNullOrEmpty (label)) {
labelWidget = new Gtk.Label (label);
labelWidget.UseMarkup = true;
+ labelWidget.Xalign = 0;
box.PackStart (labelWidget, true, true, 0);
} else {
labelWidget = null;
@@ -403,5 +350,103 @@ protected override void OnSizeAllocated (Gdk.Rectangle rect)
}
Child.SizeAllocate (rect);
}
+
+ protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+ {
+ if (VisualStyle == DockStyle.Browser)
+ DrawAsBrowser (evnt);
+ else
+ DrawNormal (evnt);
+ return base.OnExposeEvent (evnt);
+ }
+
+ void DrawAsBrowser (Gdk.EventExpose evnt)
+ {
+ var alloc = Allocation;
+
+ Gdk.GC bgc = new Gdk.GC (GdkWindow);
+ var c = new HslColor (Styles.BrowserPadBackground);
+ c.L *= 0.7;
+ var cc = (Gdk.Color)c;
+ bgc.RgbFgColor = c;
+ bool first = true;
+ bool last = true;
+ if (Parent is TabStrip.TabStripBox) {
+ var cts = ((TabStrip.TabStripBox)Parent).Children;
+ first = cts[0] == this;
+ last = cts[cts.Length - 1] == this;
+ }
+
+ if (Active || (first && last)) {
+ Gdk.GC gc = new Gdk.GC (GdkWindow);
+ gc.RgbFgColor = Styles.BrowserPadBackground;
+ evnt.Window.DrawRectangle (gc, true, alloc);
+ if (!first)
+ evnt.Window.DrawLine (bgc, alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height - 1);
+ if (!last || !first)
+ evnt.Window.DrawLine (bgc, alloc.X + alloc.Width - 1, alloc.Y, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
+ gc.Dispose ();
+
+ } else {
+ c = new HslColor (Styles.BrowserPadBackground);
+ c.L *= 0.9;
+ Gdk.GC gc = new Gdk.GC (GdkWindow);
+ gc.RgbFgColor = c;
+ evnt.Window.DrawRectangle (gc, true, alloc);
+ gc.Dispose ();
+ evnt.Window.DrawLine (bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
+ }
+ bgc.Dispose ();
+ }
+
+ void DrawNormal (Gdk.EventExpose evnt)
+ {
+ using (var ctx = Gdk.CairoHelper.Create (GdkWindow)) {
+ var x = Allocation.X;
+ var y = Allocation.Y;
+
+ ctx.Rectangle (x, y + 1, Allocation.Width, Allocation.Height - 1);
+ var g = new Cairo.LinearGradient (x, y + 1, x, y + Allocation.Height - 1);
+ g.AddColorStop (0, Styles.DockTabBarGradientStart);
+ g.AddColorStop (1, Styles.DockTabBarGradientEnd);
+ ctx.Pattern = g;
+ ctx.Fill ();
+ g.Dispose ();
+
+ ctx.MoveTo (x + 0.5, y + 0.5);
+ ctx.LineTo (x + Allocation.Width - 0.5d, y + 0.5);
+ ctx.Color = Styles.DockTabBarGradientTop;
+ ctx.Stroke ();
+
+ if (active) {
+
+ ctx.Rectangle (x, y + 1, Allocation.Width, Allocation.Height - 1);
+ g = new Cairo.LinearGradient (x, y + 1, x, y + Allocation.Height - 1);
+ g.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.01));
+ g.AddColorStop (0.5, new Cairo.Color (0, 0, 0, 0.08));
+ g.AddColorStop (1, new Cairo.Color (0, 0, 0, 0.01));
+ ctx.Pattern = g;
+ ctx.Fill ();
+ g.Dispose ();
+
+/* double offset = Allocation.Height * 0.25;
+ var rect = new Cairo.Rectangle (x - Allocation.Height + offset, y, Allocation.Height, Allocation.Height);
+ var cg = new Cairo.RadialGradient (rect.X + rect.Width / 2, rect.Y + rect.Height / 2, 0, rect.X, rect.Y + rect.Height / 2, rect.Height / 2);
+ cg.AddColorStop (0, Styles.DockTabBarShadowGradientStart);
+ cg.AddColorStop (1, Styles.DockTabBarShadowGradientEnd);
+ ctx.Pattern = cg;
+ ctx.Rectangle (rect);
+ ctx.Fill ();
+
+ rect = new Cairo.Rectangle (x + Allocation.Width - offset, y, Allocation.Height, Allocation.Height);
+ cg = new Cairo.RadialGradient (rect.X + rect.Width / 2, rect.Y + rect.Height / 2, 0, rect.X, rect.Y + rect.Height / 2, rect.Height / 2);
+ cg.AddColorStop (0, Styles.DockTabBarShadowGradientStart);
+ cg.AddColorStop (1, Styles.DockTabBarShadowGradientEnd);
+ ctx.Pattern = cg;
+ ctx.Rectangle (rect);
+ ctx.Fill ();*/
+ }
+ }
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.