Krypton-Suite / Standard-Toolkit

An update to Component factory's krypton toolkit to support .NET Framework 4.6.2 - 4.8.1 to .NET 6 - 8
BSD 3-Clause "New" or "Revised" License
403 stars 61 forks source link

[Bug]: `Office 365 - Black` does not display text correctly #876

Closed Smurf-IV closed 9 months ago

Smurf-IV commented 1 year ago

image

PWagner1 commented 1 year ago

@Smurf-IV Done, though it may look as if a toolbar button text look as if it's disabled...

image

PWagner1 commented 1 year ago

Fixed 21/12/2022

Smurf-IV commented 9 months ago

This is broken in V8 and still broken in V9 alpha And it also affects the Ribbons tabs: Office365Black

PWagner1 commented 9 months ago

Ok, this is related to an issue in the Office 2010 renderer where Aero glass was being used.

Smurf-IV commented 9 months ago

It was broken in the 2023 May code base, so it's not the removal of the embedded Aero stuff I did this month !

PWagner1 commented 9 months ago

It was broken in the 2023 May code base, so it's not the removal of the embedded Aero stuff I did this month !

@Smurf-IV Where is the 'white' aera (background) in the tab strip coming from?

tobitege commented 9 months ago

@Smurf-IV Where is the 'white' aera (background) in the tab strip coming from?

I can't say the technical reason, but I know that I can fix it (to see the items right of "File") by setting this palette's value to Black: Palette.Ribbon.RibbonTab.StateNormal.TextColor

The BasePalette's ColorTable for that theme does have a value of Black for menu item text, but I don't know if that is actually the source for above RibbonTab color and is maybe just missing the assignment? Palette.BasePalette.ColorTable.MenuItemText

(I'm mentioning BasePalette 'cause I'm dabbling around with a KryptonCustomPaletteBase component and have it assigned the Black theme)

PWagner1 commented 9 months ago

@Smurf-IV Where is the 'white' aera (background) in the tab strip coming from?

I can't say the technical reason, but I know that I can fix it (to see the items right of "File") by setting this palette's value to Black: Palette.Ribbon.RibbonTab.StateNormal.TextColor

The BasePalette's ColorTable for that theme does have a value of Black for menu item text, but I don't know if that is actually the source for above RibbonTab color and is maybe just missing the assignment? Palette.BasePalette.ColorTable.MenuItemText

@Smurf-IV & @tobitege Is it this?

protected override IDisposable DrawRibbonTabContext(RenderContext context,
                                                            Rectangle rect,
                                                            IPaletteRibbonGeneral paletteGeneral,
                                                            IPaletteRibbonBack paletteBack,
                                                            IDisposable memento)
        {
            if (rect is { Width: > 0, Height: > 0 })
            {
                Color c1 = paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal);
                Color c2 = paletteBack.GetRibbonBackColor5(PaletteState.ContextCheckedNormal);

                var generate = true;
                MementoRibbonTabContextOffice2010 cache;

                // Access a cache instance and decide if cache resources need generating
                if (memento is MementoRibbonTabContextOffice2010 contextOffice2010)
                {
                    cache = contextOffice2010;
                    generate = !cache.UseCachedValues(rect, c1, c2);
                }
                else
                {
                    memento?.Dispose();

                    cache = new MementoRibbonTabContextOffice2010(rect, c1, c2);
                    memento = cache;
                }

                // Do we need to generate the contents of the cache?
                if (generate)
                {
                    // Dispose of existing values
                    cache.Dispose();

                    cache.BorderOuterPen = new Pen(c1);
                    cache.BorderInnerPen = new Pen(CommonHelper.MergeColors(Color.Black, 0.1f, c2, 0.9f));
                    cache.TopBrush = new SolidBrush(c2);
                    Color lightC2 = ControlPaint.Light(c2);
                    cache.BottomBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y, rect.Width + 2, rect.Height + 1),
                                                                Color.FromArgb(128, lightC2), Color.FromArgb(64, lightC2), 90f);
                }

                // Draw the left and right borders
                context.Graphics.DrawLine(cache.BorderOuterPen, rect.X, rect.Y, rect.X, rect.Bottom);
                context.Graphics.DrawLine(cache.BorderInnerPen, rect.X + 1, rect.Y, rect.X + 1, rect.Bottom - 1);
                context.Graphics.DrawLine(cache.BorderOuterPen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1);
                context.Graphics.DrawLine(cache.BorderInnerPen, rect.Right - 2, rect.Y, rect.Right - 2, rect.Bottom - 1);

                // Draw the solid block of colour at the top
                context.Graphics.FillRectangle(cache.TopBrush, rect.X + 2, rect.Y, rect.Width - 4, 4);

                // Draw the gradient to the bottom
                context.Graphics.FillRectangle(cache.BottomBrush, rect.X + 2, rect.Y + 4, rect.Width - 4, rect.Height - 4);
            }

            return memento;
        }

In RenderOffice2010.cs

tobitege commented 9 months ago

The Black theme has empty color entries for RibbonGroupTitle1 and RibbonGroupTitle2 in the 365Black theme file, whereas the 365DarkGray theme - as example - has values specified for it. Are these background colors only?

Although, it does have a value for RibbonGroupTitleText (Color 36, 36, 36), which is actually returned when getting it at runtime via
Palette.BasePalette.GetRibbonTextColor(PaletteRibbonTextStyle.RibbonGroupNormalTitle, PaletteState.Normal);

PWagner1 commented 9 months ago

Found the bug, both the colours set for RibbonGroupTitle1 & RibbonGroupTitle2 are too light in the xxxDarkGray themes.

Edit: No, it does something else...

PWagner1 commented 9 months ago

@Smurf-IV & @tobitege

Ribbon colours sorted

image

tobitege commented 9 months ago

Ribbon colours sorted hmm... and the 365 Black one, too? with the white font ribbon tab titles?

PWagner1 commented 9 months ago

Ribbon colours sorted hmm... and the 365 Black one, too? with the white font ribbon tab titles?

Yes, plus a few other fixes too

image

MS365 black (dark mode)

image