Skip to content
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

Conversation

SyntevoAlex
Copy link
Member

Please see #932 and included testing snippet. In it, create two StyledText: basic and with Use fixed line height option.

@SyntevoAlex
Copy link
Member Author

I intend to merge this in a few days, unless someone wants to review.

Copy link
Contributor

github-actions bot commented Jan 24, 2024

Test Results

   299 files  ±0     299 suites  ±0   6m 37s ⏱️ +31s
 4 100 tests ±0   4 092 ✅ ±0   8 💤 ±0  0 ❌ ±0 
12 212 runs  ±0  12 137 ✅ ±0  75 💤 ±0  0 ❌ ±0 

Results for commit c9449b7. ± Comparison against base commit 15d3065.

♻️ This comment has been updated with latest results.

* layouts, including those caused by word wrapping. StyledText uses one
* TextLayout per line and is only affected by word wrap restriction.
*
* @since 4.31
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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) {
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, it is needed.

Copy link
Member Author

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 {
Copy link
Member

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)

Copy link
Member Author

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -31,6 +31,16 @@ public final class FontMetrics {
FontMetrics() {
}

public FontMetrics clone () {
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, it is needed.

Copy link
Member Author

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
Copy link
Member

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

Copy link
Member Author

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
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@iloveeclipse
Copy link
Member

@merks : on #995 you've mentioned, that you are able to get API tooling work on SWT. May I ask you to checkout this PR and check if there will be any API errors reported?

If yes, we have also another issue with build not properly validating that on Jenkins...

@merks
Copy link
Contributor

merks commented Jan 25, 2024

When I check out this PR I see these two errors (on Windows):

image

@iloveeclipse
Copy link
Member

When I check out this PR I see these two errors

Thanks Ed, I've created #1003.

@iloveeclipse
Copy link
Member

@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.

@SyntevoAlex SyntevoAlex force-pushed the z_alexandr.miloslavskiy/#0113_SWT_Bug527917_StyledText_IncreasesRowHeightOnHieroglyph branch from d4dea60 to 8edce25 Compare January 31, 2024 12:05
@iloveeclipse
Copy link
Member

@SyntevoAlex : thanks for rebase. I still see API errors, did you forget to fix them?

@SyntevoAlex
Copy link
Member Author

I will fix them later, just rebased quickly on your request

@SyntevoAlex SyntevoAlex force-pushed the z_alexandr.miloslavskiy/#0113_SWT_Bug527917_StyledText_IncreasesRowHeightOnHieroglyph branch 2 times, most recently from 70e7624 to 2967ed1 Compare January 31, 2024 22:44
@SyntevoAlex
Copy link
Member Author

I applied code review suggestions, thanks for having a look!

@SyntevoAlex
Copy link
Member Author

If there are no further issues, I intend to merge in a few days.

*
* @since 3.125
*/
public FontMetrics clone () {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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?

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Contributor

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.

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@SyntevoAlex SyntevoAlex force-pushed the z_alexandr.miloslavskiy/#0113_SWT_Bug527917_StyledText_IncreasesRowHeightOnHieroglyph branch 2 times, most recently from 0ad2d77 to 4994559 Compare February 6, 2024 02:51
@SyntevoAlex
Copy link
Member Author

@iloveeclipse automatic GitHub Compiler and API Tools verification now reports 99 new issues, and these look unrelated to my change. Should I just ignore it for now?

@laeubi
Copy link
Contributor

laeubi commented Feb 6, 2024

@SyntevoAlex I have reset the quality gate and triggered a new master build, so next build should show "green" here after that.

@SyntevoAlex SyntevoAlex force-pushed the z_alexandr.miloslavskiy/#0113_SWT_Bug527917_StyledText_IncreasesRowHeightOnHieroglyph branch from 4994559 to 6278bc6 Compare February 6, 2024 11:40
@iloveeclipse iloveeclipse dismissed their stale review February 8, 2024 10:48

No time, sorry

@iloveeclipse
Copy link
Member

@SyntevoAlex : next week is M3 and then no changes of such kind will be allowed for 4.31 (usually).
Please rebase and merge if everything will be green (github indikates there were some changes on SWT in the meantime).

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>
@SyntevoAlex SyntevoAlex force-pushed the z_alexandr.miloslavskiy/#0113_SWT_Bug527917_StyledText_IncreasesRowHeightOnHieroglyph branch from 6278bc6 to c9449b7 Compare February 8, 2024 17:47
@SyntevoAlex SyntevoAlex merged commit 0f7a1c6 into eclipse-platform:master Feb 8, 2024
13 checks passed
@SyntevoAlex
Copy link
Member Author

Thanks for the heads up.
All green, merged.

@SyntevoAlex SyntevoAlex deleted the z_alexandr.miloslavskiy/#0113_SWT_Bug527917_StyledText_IncreasesRowHeightOnHieroglyph branch February 12, 2024 21:24
@deepika-u
Copy link
Contributor

Verified this via #691 way of recreate.

Tried with below environment
Eclipse SDK
Version: 2024-03 (4.31)
Build id: I20240220-1800
OS: Windows 11, v.10.0, x86_64 / win32
Java vendor: Eclipse Adoptium
Java runtime version: 17.0.6+10
Java version: 17.0.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants