-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fade out tabs when sizing is set to shrink (fix #39417) #39829
Conversation
@Dari-K looks wonderful! however, I fear that using |
Was trying to play with this, but as far as I can tell, the stable release has subpixel-AA there, but the insider build/ a HEAD build doesn't, any ideas @bpasero ? |
@Dari-K seems to depend on more factors. can you check when just one editor is open and no sidebar or panel is visible around the editor? Also make sure your zoom level is 1. |
Ahh yeah, with the sidebar closed it has the sub-pixel antialiasing. |
@Dari-K yeah looks like we regressed. It is very hard to find the cause for Chrome falling back to greyscale AA. I will have to do some git bisect to find the culprit. |
@Dari-K found the issue, see #24957 (comment) |
@Dari-K let me know if you are planning to look into a solution that does not require |
@bpasero I did have a look at using pseudo elements to overlay a fade in from transparent to the colour of the tab which gives the same effect, and doesn't cause greyscale AA, but then I have the issue of knowing what colour the tab is, as that depends on the theme, which seems to be applied using JS rather than by style rules? Not sure I can think of another CSS only method for this. |
@Dari-K yeah we know the theme colors only from the JS side, but why not apply your change also from the JS side? The tabs are being created from |
Ok thanks, I'll have a look later |
So it's using the pseudo elements now, which seems to be working well with most of the built in themes, but there's some issues with the high contrast theme. The active tab has a border all the way around it, which the label text passes through. This ends up looking rather odd with the fade on the right side of the text. Any ideas about this? That theme also has no |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a nice solution, and I verified that subpixel AA is still being used.
Yeah, I recently added some new colors to the tabs, mainly the hover border and hover background color. All of the colors for tabs are optional for a theme but some provide a default and some do not. You can see this here.
As for HC theme: I think it is fine in that case to not show a gradient at all. Can we restore the text-overflow: ellipsis
just for the HC theme? You can use the CSS selector .hc-black
for that purpose.
@@ -34,6 +34,10 @@ | |||
text-overflow: ellipsis; | |||
} | |||
|
|||
.sizing-shrink > .monaco-icon-label > .monaco-icon-label-description-container { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to move this into tabstitle.css after line 104 where we have a similar rule.
@@ -85,6 +85,17 @@ | |||
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab .tab-label { | |||
margin-top: auto; | |||
margin-bottom: auto; | |||
position: relative; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please set position: relative
only when we are in sizing-shrink
mode.
One other thing is the tab colours sometimes use alpha, which means the fade goes from transparent to a partially transparent colour, so the fade effect is much less noticeable, I guess I can check if the colour is rgba and maybe do something special for that case if you think it's needed. |
@Dari-K when I set this via settings:
I am seeing a weird result: Do you see this as well? |
Hmm, will take a look soon |
@bpasero ahh ok managed to reproduce it, it doesn't happen unless you're hovering a tab that's part of an unfocused group, I'll investigate a bit more. |
@@ -950,6 +950,10 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { | |||
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title.active .tabs-container > .tab:hover { | |||
background: ${tabHoverBackground} !important; | |||
} | |||
|
|||
.monaco-shell:not(.hc-black) .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title.active .tabs-container > .tab.sizing-shrink:hover > .tab-label::after { | |||
background: linear-gradient(to left, ${theme.getColor(TAB_HOVER_BACKGROUND)}, transparent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dari-K in many places here you seem to unnecessarily call theme.getColor(TAB_HOVER_BACKGROUND)
even though the color was already resolved from the step before.
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.sizing-fit .monaco-icon-label, | ||
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.sizing-fit .monaco-icon-label > .monaco-icon-label-description-container { | ||
overflow: visible; /* fixes https://github.com/Microsoft/vscode/issues/20182 */ | ||
} | ||
|
||
.sizing-shrink > .monaco-icon-label > .monaco-icon-label-description-container { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dari-K please prefix more specifically by adding .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.sizing-shrink
@bpasero ok everything now works as I expect it to apart from I need to be able to tell when The other problem is when the tab colour is partially transparent and you drag the tab, the background is no longer fixed, so the colour of the pseudo element will be wrong. So I need to hide the pseudo element on the copy of the tab that follows the mouse. Any ideas? |
@Dari-K can you try adding classes to both the tab bar and the dragged tab when it is being dragged to remove the styles for that condition? The tab that is being dragged is the actual tab as it appears in the DOM, so any style applied on the tab will show up for the dragged tab as well. There is already code that flips some CSS classes when dragging begins (either dragging over or the actual tab being dragged), e.g. here. |
@bpasero seems like For the dragged tab do you mean I should add a class specifically for this and not use |
@Dari-K using the |
@bpasero I had a look, but as far as I can tell Now there's just the other problem I mentioned |
@Dari-K so the remaining issues are that the shadow looks broken when
Would it help if you would use the theming API to get the color values of Alternatively, we could disable the shadow effect when:
|
@Dari-K should I test your change? |
src/vs/base/common/color.ts
Outdated
@@ -399,6 +399,22 @@ export class Color { | |||
return new Color(new RGBA(r, g, b, a)); | |||
} | |||
|
|||
toRGB(...backgrounds: Color[]): Color { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dari-K should this have a better name to reflect what it does? It seems to blend multiple colors into one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, can change the name, not entirely sure what would fit though, because blend would imply to me that it's a mix of the colours (if I did blend on red and blue I would expect to get purple), but if the foreground colour is opaque, it will be returned unchanged. It's more like a flatten operation. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dari-K yeah better 👍
@@ -1564,6 +1564,7 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro | |||
private updateFromDropping(element: HTMLElement, isDropping: boolean): void { | |||
const groupCount = this.stacks.groups.length; | |||
const background = this.getColor(isDropping ? EDITOR_DRAG_AND_DROP_BACKGROUND : groupCount > 0 ? EDITOR_GROUP_BACKGROUND : null); | |||
isDropping ? DOM.addClass(element, 'dropping') : DOM.removeClass(element, 'dropping'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dari-K isn't this rather "dragged-over
"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, not exactly. The element that the class will be applied to is the container for all editor panes/tabs. When you drag over the tab list the class is applied (but not to the tab list, to the container mentioned earlier), when you drag over any of the editor panes the class is removed. In either case you are still dragging over the container the class is applied to. If you drag over anything else the class just retains its previous state.
let adjustedTabBackground: Color; | ||
let adjustedTabDragBackground: Color; | ||
|
||
switch (theme.type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dari-K this seems at the wrong place, can we move it into theme.ts
e.g. where the knowledge belongs to?
@Dari-K no, it is not editable as far as I know, I just suggested it to have a better logical place for it. I was not suggesting to introduce areal color, just move the code. |
@Dari-K I went ahead and did some 💄 changes on top of yours to be able to merge. I hope I did not break anything. I noticed a couple of null exceptions when dealing with colors: any color can be null (except for workbench background). Btw I notice that the same color is being used ( adjustedTabBackground = editorGroupHeaderTabsBackground.flatten(editorBackgroundColor, editorGroupBackground, editorBackgroundColor, workbenchBackground); |
@bpasero Hey, yeah the colour does get used multiple times, because it is used multiple times on different elements. So say we have red on blue on red on green. If all the colours are 0.8 alpha then if you don't flatten on red twice you'll get the wrong colour out. |
@Dari-K ok. any thoughts on making the shadow be larger and less subtle? E.g. 10px instead of 5px. |
@bpasero sorry for being slow to reply, I don't seem to be getting emails from mentions for some reason. Yeah think increasing it's fine, I made it small to begin with because I wasn't sure how noticeable you wanted it, go for whatever you think looks best. |
@Dari-K I changed it to 10px, I think thats good. |
Don't know how you feel about using prefixed CSS properties. Also there isn't a way to detect a text overflow just with CSS as far as I know, so I've just masked the end of the parent element of the icon label. This seems to stop the fade from affecting tabs that have short enough names not to overflow, not sure it works 100% of the time though.