Bug 219838 - Inconsistent truncation between drawers and tools on palette
Summary: Inconsistent truncation between drawers and tools on palette
Status: RESOLVED FIXED
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy GEF (MVC) (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4.0 (Ganymede) M6   Edit
Assignee: Cherie Revells CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-02-21 13:43 EST by Cherie Revells CLA
Modified: 2008-09-18 13:34 EDT (History)
3 users (show)

See Also:


Attachments
the patch (8.48 KB, patch)
2008-02-21 13:43 EST, Cherie Revells CLA
ahunter.eclipse: iplog+
Details | Diff
SimpleTextLayout bug fix (1.34 KB, patch)
2008-02-25 10:52 EST, Cherie Revells CLA
ahunter.eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cherie Revells CLA 2008-02-21 13:43:00 EST
Created attachment 90386 [details]
the patch

Palette tool and stack labels word wrap if there are multiple words, but the drawer titles always truncate.  It would be better if they were consistent.

The attached patch makes the following changes:

TruncatedSimpleTextLayout
- I added this new class which will always truncate the text and never wrap.  There didn't seem to be such a layout class in Draw2D.  It does respect carriage returns in the text like SimpleTextLayout does.  We have another use for this class in GMF as well.

DetailedLabelFigure
- The name text now uses the TruncatedSimpleTextLayout so that the text is truncated in a similar way to the drawer titles instead of wrapping.

SimpleTextLayout
- I modified this class slightly so that TruncatedSimpleTextLayout could reuse a few pieces.
- I also fixed a small bug with SimpleTextLayout that can result in the second line of text being cut off.  Let's say you had the text "little letters\nBIGGER LETTERS".  The call flowUtilities.setupFragment(fragment, font, text) always passes in the full text which means that when the width is calculated for the second line "BIGGER LETTERS", the "little letters" text is actually used in the calculation thus resulting in the string "BIGGER LETTERS" being cutoff.
Comment 1 Randy Hudson CLA 2008-02-21 18:04:31 EST
(In reply to comment #0)
> Created an attachment (id=90386) [details]
> the patch
> 
> Palette tool and stack labels word wrap if there are multiple words, but the
> drawer titles always truncate.  It would be better if they were consistent.

Which one is being made like the other?  If entries are being changed to only display one line of text, why couldn't we just use a plain Label figure?  If you're never going to wrap to multiple lines, then why support newlines at all?

> The attached patch makes the following changes:
> 
> TruncatedSimpleTextLayout
> - I added this new class which will always truncate the text and never wrap. 
> There didn't seem to be such a layout class in Draw2D.

Most of the time a Label is used for this.

> - I also fixed a small bug with SimpleTextLayout that can result in the second
> line of text being cut off.  Let's say you had the text "little letters\nBIGGER
> LETTERS".  The call flowUtilities.setupFragment(fragment, font, text) always
> passes in the full text which means that when the width is calculated for the

The string passed in is never measured as is. The length of the fragment determines the amount to be measured.

I think people want their entries to wrap, especially in details or column layout.
Comment 2 Cherie Revells CLA 2008-02-22 09:28:16 EST
> Which one is being made like the other?
The tool and stack labels are being made to truncate like the drawer titles unless there is an actual newline character in the string.

> If entries are being changed to only
> display one line of text, why couldn't we just use a plain Label figure? 
The DetailedLabelFigure contains a FlowPage with two TextFlow figures one for the name text and one for the description.  I thought this solution is easier than mixing a Label and a TextFlow figure.  Plus, we will use the TruncatedSimpleTextLayout in GMF anyways when we want to be able to turn wrapping on and off in a TextFlow.

> If you're never going to wrap to multiple lines, then why support newlines 
> at all?
It will wrap if the user actually puts a newline character in the string.  The SimpleTextLayout already supported this.  (Actually, this case doesn't work properly with a Label -- if a newline character is in the string, it wraps over two lines, but as soon as the text is truncated, the second line disappears.)

>The string passed in is never measured as is. The length of the fragment
>determines the amount to be measured.
The string is being measured based on the first characters in the string, not the characters that are actually being painted so the value returned can be smaller than required if the first characters in the string are small characters.  Did you try the use case?
Comment 3 Randy Hudson CLA 2008-02-22 11:23:54 EST
> It will wrap if the user actually puts a newline character in the string.

The user can not put newlines in the names, only descriptions. In most GEF-based tools, the user has no control over this text. There is no way for products to put newlines in appropriately since you can't predict whether the user will be using columns or list layout, or know to what width the user will size the palette.

To me, only the List Layout should be changed to display a truncated single line of text (and even then some may ask to support both modes). Details and Columns layouts should still wrap like before. Since List Layout only displays the name, which doesn't (or shouldn't) have newlines, a simple Label could be used when in this mode. SimpleTextLayout was only ever tested with the text example (to render "source code"). As a result, it does not support BiDi properly.

> The string is being measured based on the first characters in the string, not
> the characters that are actually being painted so the value returned can be
> smaller than required if the first characters in the string are small
> characters.

You're absolutely right, the fragment's offset is not being used.  I was only paying attention to the length.
Comment 4 Cherie Revells CLA 2008-02-22 11:45:15 EST
> SimpleTextLayout was only ever tested with the text
> example (to render "source code"). As a result, it does not support BiDi
> properly.

In my opinion, this is a bug/enhancement for GEF then.  There is no documentation regarding the use of this class and now we are using it in GMF where we actually do need BiDi support. 
Comment 5 Pratik Shah CLA 2008-02-22 12:05:12 EST
(In reply to comment #0)
> Palette tool and stack labels word wrap if there are multiple words, but the
> drawer titles always truncate.  It would be better if they were consistent.

Where's this coming from?  Have users asked for this change?  If you have a bunch of palette items like this:

Composite Alpha
Composite Bravo
Composite Charlie

Truncating them to "Composite..." would negatively impact the user experience.  Drawer names, on the other, are not that important, and should be truncated.  I don't think there's a need to touch this at all unless there've been problems reported.
Comment 6 Anthony Hunter CLA 2008-02-22 15:01:54 EST
Hi Cherie, Pratik may have a point here:

One of our tools has a stack:

Windows Server 2003
Windows XP
Windows 2000

A thin palette wraps to

Windows
Server
2003

With the fix it becomes

Windows...

And you cannot tell which tool is selected without the tooltip.

Comment 7 Cherie Revells CLA 2008-02-25 10:52:57 EST
Created attachment 90647 [details]
SimpleTextLayout bug fix

We are no longer making the change to the tool item truncation.  

I have attached a patch for the bug in SimpleTextLayout to be committed.
Comment 8 Anthony Hunter CLA 2008-02-25 16:48:50 EST
Committed the fix to HEAD