-
Notifications
You must be signed in to change notification settings - Fork 186
Adjust selection filling the curve for CTabFolder #2753
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
base: master
Are you sure you want to change the base?
Conversation
...eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java
Outdated
Show resolved
Hide resolved
...eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java
Outdated
Show resolved
Hide resolved
...eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java
Show resolved
Hide resolved
1f759d1 to
62054d9
Compare
HeikoKlare
left a comment
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 have to admit that I do not get why we need to add another complex implementation for calculating a shape, which then needs to be kept consistent with the existing shape(s) for the background and the outline. There is already the shape calculated in the touched method, which is used to draw the background of the tab header and the outline. The same shape is used for both of them and adapted in between where necessary. Can't we do something similar for the highlight line? Then we would not add another calculation logic that we need to comprehend and maintain independently.
But the polygon is not different from the shape (or if it is, it's wrong) except that the area it fills is larger (as it fills the whole header instead of only the topmost part of it). Why should the operation performed on the polygon be more simple than the ones on the existing shape? For people that have to maintain the code, it will become even more difficult when there are two implementations (that somehow need to be consistent) that they need to understand rather than one. If the current code is too hard to comprehend, we should first refactor it to improve comprehensibility. But replicating an implementation because we do not understand the existing one it not a good idea. And without understanding the existing shape implementation, how could we be sure that the added polygon one fits to it at all in every scenario? |
|
I quickly hacked this demonstration (just adopted what is done for the background, removing all unnecessary stuff and adapted the bottom left and bottom right coordinates of the shape): // draw highlight marker of selected tab
if (parent.selectionHighlightBarThickness > 0 && parent.simple) {
int[] shape2 = Arrays.copyOf(shape, shape.length);
shape2[1] = 3;
shape2[3] = 3;
shape2[shape2.length - 1] = 3;
shape2[shape2.length - 3] = 3;
Color defaultBackground = item.getDisplay().getSystemColor(parent.shouldHighlight() ? SWT.COLOR_LIST_SELECTION : SWT.COLOR_WIDGET_DISABLED_FOREGROUND);
xx = x;
yy = parent.onBottom ? y -1 : y + 1;
ww = width;
hh = height;
if (!parent.single && !parent.simple) ww += curveWidth - curveIndent;
drawBackground(gc, shape2, xx, yy, ww, hh, defaultBackground, null, null, null, false);
}This of course needs to be improved to deal with all the different cases (such as highlight at bottom/bottom) and has to be simplified, but the PoC makes me think even more that it should be quite easy to adapt and resue the existing shape to draw a properly fitting highlight. |
90e186d to
c586435
Compare
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.
Reusing the existing shape is definitely a step forward. But with the current state the highlight line now becomes much thinner than it was before. At 100% is looks like this:
In addition, the code needs to be cleaned up, as it currently (re)uses some random and badly named variables like xx, yy, shape2 etc. It's unclear why the GC background is set and reset while passing the color to some utility method as well. And is the call to drawBackground with so many null values necessary at all? I don't think there is much logic from drawBackground being used. It seems to be mostly about setting clipping and drawing a rectangle, so why not inline exactly the required code? Or maybe instead of setting clipping and drawing a rectangle, a drawPolygon could be used with the shape data.
5065068 to
49c352b
Compare
When CTabFolder is selected there is a visible gap on top as well as on the top left where there is a curve (in RCP when theming is disabled). Also the image was too close to selection highlight which is adjusted here as well.
49c352b to
bfa6a2e
Compare







When CTabFolder is selected there is a visible gap on top as well as on the top left where there is a curve (in RCP when theming is disabled). Also the image was too close to selection highlight which is adjusted here as well.
Results
Before Changes at 200%:
After Changes at 200%: