Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Ungureanu <therzok@gmail.com>2017-04-30 19:32:26 +0300
committerMarius Ungureanu <teromario@yahoo.com>2017-05-09 14:51:42 +0300
commit65dd2be4b0d7272cc84b4a97d372dfd8688a0255 (patch)
tree1f097830e1ef4b90d5cb69677f0bced3b467e142 /main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking
parent44b730b960d81ee33d96961fc71efa6f080779bc (diff)
[Ide] Don't reconstruct dockitems every time we set a label.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs171
1 files changed, 87 insertions, 84 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs
index 6836185999..1e385e7637 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs
@@ -51,10 +51,12 @@ namespace MonoDevelop.Components.Docking
int minWidth;
DockVisualStyle visualStyle;
ImageView tabIcon;
+ Gtk.HBox box;
DockFrame frame;
string label;
ImageButton btnDock;
ImageButton btnClose;
+ Gtk.Alignment al;
DockItem item;
bool allowPlaceholderDocking;
bool mouseOver;
@@ -141,7 +143,7 @@ namespace MonoDevelop.Components.Docking
else
inactiveIconAlpha = 0.6;
- if (labelWidget != null && label != null) {
+ if (labelWidget?.Visible == true && label != null) {
if (visualStyle.UppercaseTitles.Value)
labelWidget.Text = label.ToUpper ();
else
@@ -152,13 +154,14 @@ namespace MonoDevelop.Components.Docking
if (!(Parent is TabStrip.TabStripBox))
labelWidget.Xalign = 0;
- }
-
- if (tabIcon != null) {
- tabIcon.Image = tabIcon.Image.WithAlpha (active ? 1.0 : inactiveIconAlpha);
+ }
+
+ if (tabIcon != null) {
+ tabIcon.Image = tabIcon.Image.WithAlpha (active ? 1.0 : inactiveIconAlpha);
tabIcon.Visible = visualStyle.ShowPadTitleIcon.Value;
}
- if (IsRealized && labelWidget != null) {
+
+ if (IsRealized && labelWidget?.Visible == true) {
var font = FontService.SansFont.CopyModified (null, Pango.Weight.Bold);
font.AbsoluteSize = Pango.Units.FromPixels (11);
labelWidget.ModifyFont (font);
@@ -178,12 +181,84 @@ namespace MonoDevelop.Components.Docking
{
string labelNoSpaces = label != null ? label.Replace (' ', '-') : null;
this.label = label;
- this.page = page;
- if (Child != null) {
- Gtk.Widget oc = Child;
- Remove (oc);
- oc.Destroy ();
- }
+ this.page = page;
+
+ if (icon == null)
+ icon = ImageService.GetIcon ("md-empty");
+
+ if (box == null) {
+ box = new HBox ();
+ box.Accessible.SetShouldIgnore (true);
+ box.Spacing = -2;
+
+ tabIcon = new ImageView ();
+ tabIcon.Accessible.SetShouldIgnore (true);
+ tabIcon.Show ();
+ box.PackStart (tabIcon, false, false, 3);
+
+ labelWidget = new ExtendedLabel (label);
+ // Ignore the label because the title tab already contains its name
+ labelWidget.Accessible.SetShouldIgnore (true);
+ labelWidget.UseMarkup = true;
+ var alignLabel = new Alignment (0.0f, 0.5f, 1, 1);
+ alignLabel.Accessible.SetShouldIgnore (true);
+ alignLabel.BottomPadding = 0;
+ alignLabel.RightPadding = 15;
+ alignLabel.Add (labelWidget);
+ box.PackStart (alignLabel, false, false, 0);
+
+ btnDock = new ImageButton ();
+ btnDock.Image = pixAutoHide;
+ btnDock.TooltipText = GettextCatalog.GetString ("Auto Hide");
+ btnDock.CanFocus = false;
+ // btnDock.WidthRequest = btnDock.HeightRequest = 17;
+ btnDock.Clicked += OnClickDock;
+ btnDock.ButtonPressEvent += (o, args) => args.RetVal = true;
+ btnDock.WidthRequest = btnDock.SizeRequest ().Width;
+ UpdateDockButtonAccessibilityLabels ();
+
+ btnClose = new ImageButton ();
+ btnClose.Image = pixClose;
+ btnClose.TooltipText = GettextCatalog.GetString ("Close");
+ btnClose.CanFocus = false;
+ // btnClose.WidthRequest = btnClose.HeightRequest = 17;
+ btnClose.WidthRequest = btnDock.SizeRequest ().Width;
+ btnClose.Clicked += delegate {
+ item.Visible = false;
+ };
+ btnClose.ButtonPressEvent += (o, args) => args.RetVal = true;
+
+ al = new Alignment (0, 0.5f, 1, 1);
+ al.Accessible.SetShouldIgnore (true);
+ HBox btnBox = new HBox (false, 0);
+ btnBox.Accessible.SetShouldIgnore (true);
+ btnBox.PackStart (btnDock, false, false, 3);
+ btnBox.PackStart (btnClose, false, false, 1);
+ al.Add (btnBox);
+ box.PackEnd (al, false, false, 3);
+
+ Add (box);
+ }
+
+ tabIcon.Image = icon;
+
+ string realLabel, realHelp;
+ if (!string.IsNullOrEmpty (label)) {
+ labelWidget.Parent.Show ();
+ labelWidget.Name = label;
+ btnDock.Name = string.Format ("btnDock_{0}", labelNoSpaces ?? string.Empty);
+ btnClose.Name = string.Format ("btnClose_{0}", labelNoSpaces ?? string.Empty);
+ realLabel = GettextCatalog.GetString ("Close {0}", label);
+ realHelp = GettextCatalog.GetString ("Close the {0} pad", label);
+ }
+ else {
+ labelWidget.Parent.Hide ();
+ realLabel = GettextCatalog.GetString ("Close pad");
+ realHelp = GettextCatalog.GetString ("Close the pad");
+ }
+
+ btnClose.Accessible.SetLabel (realLabel);
+ btnClose.Accessible.Description = realHelp;
if (label != null) {
Accessible.Name = $"DockTab.{labelNoSpaces}";
@@ -191,78 +266,6 @@ namespace MonoDevelop.Components.Docking
Accessible.SetTitle (label);
Accessible.SetLabel (label);
}
-
- Gtk.HBox box = new HBox ();
- box.Accessible.SetShouldIgnore (true);
- box.Spacing = -2;
-
- if (icon == null)
- icon = ImageService.GetIcon ("md-empty");
-
- tabIcon = new ImageView (icon);
- tabIcon.Accessible.SetShouldIgnore (true);
- tabIcon.Show ();
- box.PackStart (tabIcon, false, false, 3);
-
- if (!string.IsNullOrEmpty (label)) {
- labelWidget = new ExtendedLabel (label);
- // Ignore the label because the title tab already contains its name
- labelWidget.Accessible.SetShouldIgnore (true);
- labelWidget.UseMarkup = true;
- labelWidget.Name = label;
- var alignLabel = new Alignment (0.0f, 0.5f, 1, 1);
- alignLabel.Accessible.SetShouldIgnore (true);
- alignLabel.BottomPadding = 0;
- alignLabel.RightPadding = 15;
- alignLabel.Add (labelWidget);
- box.PackStart (alignLabel, false, false, 0);
- } else {
- labelWidget = null;
- }
-
- btnDock = new ImageButton ();
- btnDock.Image = pixAutoHide;
- btnDock.TooltipText = GettextCatalog.GetString ("Auto Hide");
- btnDock.CanFocus = false;
-// btnDock.WidthRequest = btnDock.HeightRequest = 17;
- btnDock.Clicked += OnClickDock;
- btnDock.ButtonPressEvent += (o, args) => args.RetVal = true;
- btnDock.WidthRequest = btnDock.SizeRequest ().Width;
- btnDock.Name = string.Format("btnDock_{0}", labelNoSpaces ?? string.Empty);
- UpdateDockButtonAccessibilityLabels ();
-
- btnClose = new ImageButton ();
- btnClose.Image = pixClose;
- btnClose.TooltipText = GettextCatalog.GetString ("Close");
- btnClose.CanFocus = false;
-// btnClose.WidthRequest = btnClose.HeightRequest = 17;
- btnClose.WidthRequest = btnDock.SizeRequest ().Width;
- btnClose.Clicked += delegate {
- item.Visible = false;
- };
- btnClose.ButtonPressEvent += (o, args) => args.RetVal = true;
- btnClose.Name = string.Format ("btnClose_{0}", labelNoSpaces ?? string.Empty);
- string realLabel, realHelp;
- if (string.IsNullOrEmpty (label)) {
- realLabel = GettextCatalog.GetString ("Close pad");
- realHelp = GettextCatalog.GetString ("Close the pad");
- } else {
- realLabel = GettextCatalog.GetString ("Close {0}", label);
- realHelp = GettextCatalog.GetString ("Close the {0} pad", label);
- }
- btnClose.Accessible.SetLabel (realLabel);
- btnClose.Accessible.Description = realHelp;
-
- Gtk.Alignment al = new Alignment (0, 0.5f, 1, 1);
- al.Accessible.SetShouldIgnore (true);
- HBox btnBox = new HBox (false, 0);
- btnBox.Accessible.SetShouldIgnore (true);
- btnBox.PackStart (btnDock, false, false, 3);
- btnBox.PackStart (btnClose, false, false, 1);
- al.Add (btnBox);
- box.PackEnd (al, false, false, 3);
-
- Add (box);
// Get the required size before setting the ellipsize property, since ellipsized labels
// have a width request of 0