-
Notifications
You must be signed in to change notification settings - Fork 143
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
Issue 932: implement fixed line height for StyledText #1002
Issue 932: implement fixed line height for StyledText #1002
Conversation
I intend to merge this in a few days, unless someone wants to review. |
* layouts, including those caused by word wrapping. StyledText uses one | ||
* TextLayout per line and is only affected by word wrap restriction. | ||
* | ||
* @since 4.31 |
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.
This is wrong version with 99.9% probability (nust be 3.125 as we don't use SDK version but bundle version to track API changes), but unfortunately due a bug in PDE API tooling (eclipse-pde/eclipse.pde#1073) I'm unable to validate API on this PR, and I also assume the API checks are broken on SWT master build either.
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.
Thanks for taking you time to have a look!
Yes, sorry, since tags are quite confusing to me. There are 3 different version numbers in SWT (Eclipse, those mentioned in automatic commit messages, and fragment). I'll fix that.
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.
done
/** | ||
* See {@link TextLayout#setFixedLineMetrics} | ||
*/ | ||
public void setFixedLineMetrics(FontMetrics metrics) { |
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 believe with 99.9% probability this new method needs @since 3.125
comment and it would be an API error if API tooling would work properly.
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.
Confirmed, it is needed.
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.
done
@@ -180,6 +183,15 @@ public LineInfo(LineInfo info) { | |||
} | |||
} | |||
} | |||
|
|||
private static class LineDrawInfo { |
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 wonder if that should be a record (so implicitly final fields)
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.
Thanks, I'll try that. I learned about record
just a few days ago (my excuse is that I'm not a Java programmer)
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.
done
...eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
Show resolved
Hide resolved
@@ -31,6 +31,16 @@ public final class FontMetrics { | |||
FontMetrics() { | |||
} | |||
|
|||
public FontMetrics clone () { |
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.
Same here, I believe @since 3.125
is missing
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.
Confirmed, it is needed.
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.
done
* layouts, including those caused by word wrapping. StyledText uses one | ||
* TextLayout per line and is only affected by word wrap restriction. | ||
* | ||
* @since 4.31 |
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.
@since 4.31
is wrong and should be @since 3.125
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.
done
* layouts, including those caused by word wrapping. StyledText uses one | ||
* TextLayout per line and is only affected by word wrap restriction. | ||
* | ||
* @since 4.31 |
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.
@since 4.31
is wrong and should be @since 3.125
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.
done
Thanks Ed, I've created #1003. |
@SyntevoAlex : please rebase your PR on master, there were quite some changes in the SWT project infrastructure, so switching between your PR and master is not easy. Also with the fix for eclipse-pde/eclipse.pde#1073 I can finally see "proper" API errors, so those I've mentioned before are confirmed to be valid. |
d4dea60
to
8edce25
Compare
@SyntevoAlex : thanks for rebase. I still see API errors, did you forget to fix them? |
I will fix them later, just rebased quickly on your request |
70e7624
to
2967ed1
Compare
I applied code review suggestions, thanks for having a look! |
If there are no further issues, I intend to merge in a few days. |
* | ||
* @since 3.125 | ||
*/ | ||
public FontMetrics clone () { |
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.
Is this a new API in FontMetrics? In that case shouldn't it be added to all platforms?
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 had no intention to add a cross-platform API.
Just wanted a convenience method to avoid copy&pasting code.
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.
Does public part have to match on all platforms?
If yes, would you rather have the method on other platforms, or removed from macOS via moving it into TextLayout
as a private helper?
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.
Does public part have to match on all platforms?
Yes, otherwise there is a strong risk that the code written on a particular platform starts using those methods, and that as a result such code becomes non-portable, which is the opposite reason of why one would use SWT.
If yes, would you rather have the method on other platforms, or removed from macOS via moving it into TextLayout as a private helper?
Can't the method be only package visible here?
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.
Ah right, I was confused because StyledText
is in a different package. Will make it package-private then.
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.
Yes, otherwise there is a strong risk that the code written on a particular platform starts using those methods, and that as a result such code becomes non-portable, which is the opposite reason of why one would use SWT.
+1
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.
Yes, otherwise there is a strong risk that the code written on a particular platform starts using those methods, and that as a result such code becomes non-portable, which is the opposite reason of why one would use SWT.
To be fair we have this situation already with Windows OLE API .... in the end it might be better to throw unsupported operation and have the API everywhere as this is really a nightmare to develop.
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.
To be fair we have this situation already with Windows OLE API ....
Win OLE api is in a platform specific package org.eclipse.swt.ole.win32
, so all the classes in the package are platform specific - https://help.eclipse.org/latest/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/ole/win32/package-summary.html
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.
done
0ad2d77
to
4994559
Compare
@iloveeclipse automatic GitHub |
@SyntevoAlex I have reset the quality gate and triggered a new master build, so next build should show "green" here after that. |
4994559
to
6278bc6
Compare
@SyntevoAlex : next week is M3 and then no changes of such kind will be allowed for 4.31 (usually). I personally have no time for a review, so it would be nice if someone would do that now. |
Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
To be implemented in next commits Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
…xedLineMetrics Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
…FixedLineMetrics Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
…awLineForeground() Needed to paint entire background in next commit. Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
…fore content Needed to avoid clipping tall unicode characters in fixedLineMetrics mode. Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
…FixedLineMetrics Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
6278bc6
to
c9449b7
Compare
Thanks for the heads up. |
Verified this via #691 way of recreate. Tried with below environment |
Please see #932 and included testing snippet. In it, create two StyledText: basic and with
Use fixed line height
option.