Summary: | [StyledText] StyleRange to allow horizontal spacing before characters (instead of GlyphMetrics replacement) | ||
---|---|---|---|
Product: | [Eclipse Project] Platform | Reporter: | Angelo ZERR <azerr> |
Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
Status: | NEW --- | QA Contact: | |
Severity: | enhancement | ||
Priority: | P3 | CC: | akurtako, daniel_megert, gautier.desaintmartinlacaze, karsten.thoms, mistria |
Version: | 4.8 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
See Also: |
https://git.eclipse.org/r/118321 https://bugs.eclipse.org/bugs/show_bug.cgi?id=531719 https://bugs.eclipse.org/bugs/show_bug.cgi?id=539618 https://bugs.eclipse.org/bugs/show_bug.cgi?id=533194 |
||
Whiteboard: | |||
Bug Depends on: | |||
Bug Blocks: | 531957, 534314, 538262 |
Description
Angelo ZERR
2018-02-27 19:11:36 EST
New Gerrit change created: https://git.eclipse.org/r/118321 *** Bug 531768 has been marked as a duplicate of this bug. *** Do we need a new field? Isn't the current GlyphMetrics behavior a bug or is there any use-case for which it's desired? How does vertical glyphMetrics behave, is it just an "insert"? > Do we need a new field? Yes we need it to disting insert or replace. > Isn't the current GlyphMetrics behavior a bug or is there any use-case for which it's desired? Here 2 samples: * http://www.java2s.com/Tutorial/Java/0280__SWT/StyledTextembedimages.htm * http://www.java2s.com/Tutorial/Java/0280__SWT/StyledTextembedcontrols.htm Those samples replace \uFFFC character with images, control which take place with GlyphMetrics. > How does vertical glyphMetrics behave, is it just an "insert"? We have 2 usecases: * replace character like \uFFFC with images, control, etc by using GlyphMetrics * insert images, control, etc before a character by using GlyphMetrics What does happen when style.lenght == 0? I think this should be interpreted as an insert (ie replace 0 character with the GlyphMetric.width). > What does happen when style.lenght == 0?
It's not supported, When you have a style with length = 0, it is ignored. (See StyledTextRenderer#updateRanges (first test).
Even if you comment this test, it doesn't work.
To be honnest with you, my fear is not about this API (I understand that you don't want to add insert flag and use length = 0) but more for update of TextLayout of the other 2 OS.
Do you know people who could do that? Please note my gerrit patch is not perfect with windows, there is a little bug when cursor is moved accross the GlyphMetrics (it doesn't position the cursor in well place).
(In reply to Angelo ZERR from comment #6) > To be honnest with you, my fear is not about this API (I understand that you > don't want to add insert flag and use length = 0) We need to focus on keeping API meaningful and easy. If we have to update stuff, we'll do it. > more for update of TextLayout of the other 2 OS. Does the TextLayout need to be updated? Looking at the Linux code, it seems to me that the test layout is applied even for width = 0. > We need to focus on keeping API meaningful and easy. If we have to update stuff, we'll do it. Yes sure! > Does the TextLayout need to be updated? Looking at the Linux code, it seems to me that the test layout is applied even for width = 0. In win32, I'm afraid that it doesn't work (but I will study more why style.length doesn't work) Have you tried my snippet https://git.eclipse.org/r/#/c/118321/1/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet400.java (remove code metrics.insert and set style.length to 0) If it works with your OS, you should see: ----------------------------------------------------------------- a bc ----------------------------------------------------------------- I don't think introducing an "insert" flag is a nice solution. It will make the code more complex to maintain as GlyphMetrics would suddenly have different meaning. Either we manage to deal with case of length==0 in TextLayout or we need to introduce a whole new concept in the StyledText such as "setSpacing(offset, width)" to properly inform that we want an extra space at given offset. >I don't think introducing an "insert" flag is a nice solution. It will make the code more complex to maintain as GlyphMetrics would suddenly have different meaning. +1 > Either we manage to deal with case of length==0 in TextLayout +1 > or we need to introduce a whole new concept in the StyledText such as "setSpacing(offset, width)" to properly inform that we want an extra space at given offset. -1 The lines which cause 0-length styles to be ignored is StyledTextRenderer:1121&1128 which override the previously defined style on the same index. I've got an idea of a workaround that would remain on the StyledTextRenderer layer: if we have a style with lenght==0 on the line, when creating the layout, we instead some blank characters in the line and modify the following layouts to that the glyphmetrics is applied on the invisible character. It has a big impact though on getOffsetAtPoint and family. Overall, I'm also worried that 0-length styles may get wiped out in other layers such as "mergeStyles" here and there and that even improving stuff on SWT layer wouldn't have any effect because the received style would be erroneous. I'm afraid there is no good solution at all with the current state. Have you investigated trying to draw with some transparent background? > I've got an idea of a workaround that would remain on the StyledTextRenderer layer: if we have a style with lenght==0 on the line, when creating the layout, we instead some blank characters in the line and modify the following layouts to that the glyphmetrics is applied on the invisible character. It has a big impact though on getOffsetAtPoint and family. I think it's a dangerous idea to do that. > Overall, I'm also worried that 0-length styles may get wiped out in other layers such as "mergeStyles" here and there and that even improving stuff on SWT layer wouldn't have any effect because the received style would be erroneous. I'm afraid there is no good solution at all with the current state. Yes exactly. > Have you investigated trying to draw with some transparent background? Yes it's not possible. Use of GlyphMetrics draw blank space, so it's not possible. Why you don't like my gerrit patch? It's because it changes the API? (In reply to Angelo ZERR from comment #13) > Why you don't like my gerrit patch? It's because it changes the API? Yes. And also because it requires to adopt this new setting in all OSs, which is much more difficult. > Yes. And also because it requires to adopt this new setting in all OSs, which is much more difficult.
I'm afraid that there is not other mean to support clean draw of inlined annotation -(
I see 2 Gerrit patches on this topic https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/118321 and https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/149673 . @Angelo @Paul Should we keep both, none, or just one? |