diff options
author | Vsevolod Kukol <sevoku@xamarin.com> | 2016-01-20 12:56:23 +0300 |
---|---|---|
committer | Vsevolod Kukol <sevoku@xamarin.com> | 2016-01-20 12:56:49 +0300 |
commit | d2c7e5e9ada0934958918d1e2e6e4e06ac46237f (patch) | |
tree | 1fe6a0f3507e8a6d4c85de8034207c790257cb33 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage | |
parent | 6fdc65c2243104a10ff3d704e9461d29999528a2 (diff) |
[Ide] Initial WelcomePage theme change support
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage')
4 files changed, 113 insertions, 94 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageBarButton.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageBarButton.cs index 870fe1db0b..e38918156b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageBarButton.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageBarButton.cs @@ -74,11 +74,7 @@ namespace MonoDevelop.Ide.WelcomePage public WelcomePageBarButton (string title, string href, string iconResource = null) { - FontFamily = Platform.IsMac ? Styles.WelcomeScreen.FontFamilyMac : Styles.WelcomeScreen.FontFamilyWindows; - HoverColor = Styles.WelcomeScreen.Links.HoverColor; - Color = Styles.WelcomeScreen.Links.Color; - FontSize = Styles.WelcomeScreen.Links.FontSize; - FontWeight = Pango.Weight.Bold; + UpdateStyle (); VisibleWindow = false; this.Text = GettextCatalog.GetString (title); @@ -99,11 +95,33 @@ namespace MonoDevelop.Ide.WelcomePage box.ShowAll (); Add (box); + Gui.Styles.Changed += UpdateStyle; Update (); Events |= (Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask | Gdk.EventMask.ButtonReleaseMask); } + void UpdateStyle (object sender = null, EventArgs e = null) + { + OnUpdateStyle (); + if (label != null) { + box.Remove (label); + box.PackStart (label = CreateLabel ()); + box.ShowAll (); + Update (); + } + QueueResize (); + } + + protected virtual void OnUpdateStyle () + { + FontFamily = Platform.IsMac ? Styles.WelcomeScreen.FontFamilyMac : Styles.WelcomeScreen.FontFamilyWindows; + HoverColor = Styles.WelcomeScreen.Links.HoverColor; + Color = Styles.WelcomeScreen.Links.Color; + FontSize = Styles.WelcomeScreen.Links.FontSize; + FontWeight = Pango.Weight.Bold; + } + protected virtual Label CreateLabel () { return new Label (); @@ -162,6 +180,12 @@ namespace MonoDevelop.Ide.WelcomePage var color = mouseOver ? HoverColor : Color; label.Markup = WelcomePageSection.FormatText (FontFamily, FontSize, FontWeight, color, Text); } + + protected override void OnDestroyed () + { + Gui.Styles.Changed -= UpdateStyle; + base.OnDestroyed (); + } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageFeedItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageFeedItem.cs index d133140cb4..0e62e2707e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageFeedItem.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageFeedItem.cs @@ -36,10 +36,10 @@ namespace MonoDevelop.Ide.WelcomePage {
class WelcomePageFeedItem : Gtk.EventBox
{
- static readonly string linkUnderlinedFormat;
- static readonly string linkFormat;
- static readonly string descFormat;
- static readonly string subtitleFormat;
+ static string linkUnderlinedFormat;
+ static string linkFormat;
+ static string descFormat;
+ static string subtitleFormat;
Label titleLabel;
Label subtitleLabel;
@@ -56,6 +56,12 @@ namespace MonoDevelop.Ide.WelcomePage static WelcomePageFeedItem ()
{
+ UpdateStyle ();
+ Gui.Styles.Changed += (sender, e) => UpdateStyle();
+ }
+
+ static void UpdateStyle ()
+ {
var face = Platform.IsMac ? Styles.WelcomeScreen.Pad.TitleFontFamilyMac : Styles.WelcomeScreen.Pad.TitleFontFamilyWindows;
linkUnderlinedFormat = Styles.GetFormatString (face, Styles.WelcomeScreen.Pad.MediumTitleFontSize, Styles.WelcomeScreen.Pad.News.Item.TitleHoverColor, Pango.Weight.Bold);
linkFormat = Styles.GetFormatString (face, Styles.WelcomeScreen.Pad.MediumTitleFontSize, Styles.WelcomeScreen.Pad.MediumTitleColor, Pango.Weight.Bold);
@@ -171,6 +177,13 @@ namespace MonoDevelop.Ide.WelcomePage summaryLabel.Attributes.Insert (rise);
Add (box);
+
+ Gui.Styles.Changed += UpdateStyle;
+ }
+
+ void UpdateStyle (object sender, EventArgs args)
+ {
+ UpdateLabel (false);
}
int allocWidth;
@@ -365,5 +378,11 @@ namespace MonoDevelop.Ide.WelcomePage return GettextCatalog.GetString ("Open {0}", link);
}
}
+
+ protected override void OnDestroyed ()
+ {
+ Gui.Styles.Changed -= UpdateStyle;
+ base.OnDestroyed ();
+ }
}
}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageListButton.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageListButton.cs index fcaeb1b5b9..d869cbc26c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageListButton.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageListButton.cs @@ -57,86 +57,17 @@ namespace MonoDevelop.Ide.WelcomePage public int LeftTextPadding { get; set; } public int InternalPadding { get; set; } + public string SmallTitleColor { get; set; } + public string MediumTitleColor { get; set; } - string smallTitleColor = Styles.WelcomeScreen.Pad.SmallTitleColor; - public string SmallTitleColor { - get { - return smallTitleColor; - } - set { - smallTitleColor = value; - } - } - - string mediumTitleColor = Styles.WelcomeScreen.Pad.MediumTitleColor; - public string MediumTitleColor { - get { - return mediumTitleColor; - } - set { - mediumTitleColor = value; - } - } - - string titleFontFace = Platform.IsMac ? Styles.WelcomeScreen.Pad.TitleFontFamilyMac : Styles.WelcomeScreen.Pad.TitleFontFamilyWindows; - public string TitleFontFace { - get { - return titleFontFace; - } - set { - titleFontFace = value; - } - } - - string smallTitleFontFace = Platform.IsMac ? Styles.WelcomeScreen.Pad.TitleFontFamilyMac : Styles.WelcomeScreen.Pad.TitleFontFamilyWindows; - public string SmallTitleFontFace { - get { - return smallTitleFontFace; - } - set { - smallTitleFontFace = value; - } - } - - string hoverBackgroundColor = Styles.WelcomeScreen.Pad.Solutions.SolutionTile.HoverBackgroundColor; - public string HoverBackgroundColor { - get { - return hoverBackgroundColor; - } - set { - hoverBackgroundColor = value; - } - } - - string hoverBorderColor = Styles.WelcomeScreen.Pad.Solutions.SolutionTile.HoverBorderColor; - public string HoverBorderColor { - get { - return hoverBorderColor; - } - set { - hoverBorderColor = value; - } - } + public string TitleFontFace { get; set; } + public string SmallTitleFontFace { get; set; } - int titleFontSize = Styles.WelcomeScreen.Pad.Solutions.SolutionTile.TitleFontSize; - public int TitleFontSize { - get { - return titleFontSize; - } - set { - titleFontSize = value; - } - } + public string HoverBackgroundColor { get; set; } + public string HoverBorderColor { get; set; } - int smallTitleFontSize = Styles.WelcomeScreen.Pad.Solutions.SolutionTile.PathFontSize; - public int SmallTitleFontSize { - get { - return smallTitleFontSize; - } - set { - smallTitleFontSize = value; - } - } + public int TitleFontSize { get; set; } + public int SmallTitleFontSize { get; set; } static WelcomePageListButton () { @@ -153,14 +84,37 @@ namespace MonoDevelop.Ide.WelcomePage this.subtitle = subtitle; this.icon = icon; this.actionUrl = actionUrl; - this.SmallTitleColor = smallTitleColor; - this.MediumTitleColor = mediumTitleColor; + WidthRequest = Styles.WelcomeScreen.Pad.Solutions.SolutionTile.Width; HeightRequest = Styles.WelcomeScreen.Pad.Solutions.SolutionTile.Height + 2; Events |= (Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask); LeftTextPadding = Styles.WelcomeScreen.Pad.Solutions.SolutionTile.TextLeftPadding; InternalPadding = Styles.WelcomeScreen.Pad.Padding; + + Gui.Styles.Changed += UpdateStyle; + UpdateStyle (); + } + + void UpdateStyle (object sender = null, EventArgs e = null) + { + OnUpdateStyle (); + QueueDraw (); + } + + protected virtual void OnUpdateStyle () + { + SmallTitleColor = Styles.WelcomeScreen.Pad.SmallTitleColor; + MediumTitleColor = Styles.WelcomeScreen.Pad.MediumTitleColor; + + TitleFontFace = Platform.IsMac ? Styles.WelcomeScreen.Pad.TitleFontFamilyMac : Styles.WelcomeScreen.Pad.TitleFontFamilyWindows; + SmallTitleFontFace = Platform.IsMac ? Styles.WelcomeScreen.Pad.TitleFontFamilyMac : Styles.WelcomeScreen.Pad.TitleFontFamilyWindows; + + HoverBackgroundColor = Styles.WelcomeScreen.Pad.Solutions.SolutionTile.HoverBackgroundColor; + HoverBorderColor = Styles.WelcomeScreen.Pad.Solutions.SolutionTile.HoverBorderColor; + + TitleFontSize = Styles.WelcomeScreen.Pad.Solutions.SolutionTile.TitleFontSize; + SmallTitleFontSize = Styles.WelcomeScreen.Pad.Solutions.SolutionTile.PathFontSize; } public bool AllowPinning { get; set; } @@ -298,7 +252,7 @@ namespace MonoDevelop.Ide.WelcomePage Pango.Layout titleLayout = new Pango.Layout (PangoContext); titleLayout.Width = Pango.Units.FromPixels (textWidth); titleLayout.Ellipsize = Pango.EllipsizeMode.End; - titleLayout.SetMarkup (WelcomePageSection.FormatText (TitleFontFace, titleFontSize, Pango.Weight.Bold, MediumTitleColor, title)); + titleLayout.SetMarkup (WelcomePageSection.FormatText (TitleFontFace, TitleFontSize, Pango.Weight.Bold, MediumTitleColor, title)); Pango.Layout subtitleLayout = null; @@ -306,7 +260,7 @@ namespace MonoDevelop.Ide.WelcomePage subtitleLayout = new Pango.Layout (PangoContext); subtitleLayout.Width = Pango.Units.FromPixels (textWidth); subtitleLayout.Ellipsize = Pango.EllipsizeMode.Start; - subtitleLayout.SetMarkup (WelcomePageSection.FormatText (SmallTitleFontFace, smallTitleFontSize, Pango.Weight.Normal, SmallTitleColor, subtitle)); + subtitleLayout.SetMarkup (WelcomePageSection.FormatText (SmallTitleFontFace, SmallTitleFontSize, Pango.Weight.Normal, SmallTitleColor, subtitle)); } int height = 0; @@ -322,15 +276,21 @@ namespace MonoDevelop.Ide.WelcomePage int tx = Allocation.X + InternalPadding + LeftTextPadding; int ty = Allocation.Y + (Allocation.Height - height) / 2; - DrawLayout (ctx, titleLayout, TitleFontFace, titleFontSize, Pango.Weight.Bold, MediumTitleColor, tx, ty); + DrawLayout (ctx, titleLayout, TitleFontFace, TitleFontSize, Pango.Weight.Bold, MediumTitleColor, tx, ty); if (subtitleLayout != null) { ty += h1 + Styles.WelcomeScreen.Pad.Solutions.SolutionTile.TitleBottomMargin; - DrawLayout (ctx, subtitleLayout, SmallTitleFontFace, smallTitleFontSize, Pango.Weight.Bold, SmallTitleColor, tx, ty); + DrawLayout (ctx, subtitleLayout, SmallTitleFontFace, SmallTitleFontSize, Pango.Weight.Normal, SmallTitleColor, tx, ty); } } return true; } + + protected override void OnDestroyed () + { + Gui.Styles.Changed -= UpdateStyle; + base.OnDestroyed (); + } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageSection.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageSection.cs index 969fbb2fa7..5e88950dbb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageSection.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageSection.cs @@ -35,14 +35,21 @@ namespace MonoDevelop.Ide.WelcomePage { string title; - static readonly string headerFormat; + static string headerFormat; + Label label; Alignment root = new Alignment (0, 0, 1f, 1f); protected Gtk.Alignment ContentAlignment { get; private set; } protected Gtk.Alignment TitleAlignment { get; private set; } static WelcomePageSection () { + UpdateStyle (); + Gui.Styles.Changed += (sender, e) => UpdateStyle(); + } + + static void UpdateStyle () + { var face = Platform.IsMac ? Styles.WelcomeScreen.Pad.TitleFontFamilyMac : Styles.WelcomeScreen.Pad.TitleFontFamilyWindows; headerFormat = Styles.GetFormatString (face, Styles.WelcomeScreen.Pad.LargeTitleFontSize, Styles.WelcomeScreen.Pad.LargeTitleFontColor); } @@ -62,6 +69,15 @@ namespace MonoDevelop.Ide.WelcomePage TitleAlignment.SetPadding (p, Styles.WelcomeScreen.Pad.LargeTitleMarginBottom, p, p); ContentAlignment = new Alignment (0f, 0f, 1f, 1f); ContentAlignment.SetPadding (0, p, p, p); + + Gui.Styles.Changed += UpdateStyle; + } + + void UpdateStyle (object sender, EventArgs args) + { + if (label != null) + label.Markup = string.Format (headerFormat, title); + QueueDraw (); } public void SetContent (Gtk.Widget w) @@ -75,7 +91,7 @@ namespace MonoDevelop.Ide.WelcomePage } var box = new VBox (); - var label = new Gtk.Label () { Markup = string.Format (headerFormat, title), Xalign = (uint) 0 }; + label = new Label () { Markup = string.Format (headerFormat, title), Xalign = (uint) 0 }; TitleAlignment.Add (label); box.PackStart (TitleAlignment, false, false, 0); box.PackStart (ContentAlignment, false, false, 0); |