| Summary: | [ToolTip] Improve small screen presentation | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Sebastian Habenicht <dev> | ||||||
| Component: | RWT | Assignee: | Project Inbox <rap-inbox> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | enhancement | ||||||||
| Priority: | P3 | ||||||||
| Version: | 3.2 | ||||||||
| Target Milestone: | 3.5 M2 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows 7 | ||||||||
| See Also: |
https://git.eclipse.org/r/116054 https://git.eclipse.org/c/rap/org.eclipse.rap.git/commit/?id=05ca8cdfc38299f6e053937d67656339ee9e61ec |
||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Sebastian Habenicht
TollTip widget now supports fixed width/height set by the theming [1]. [1] http://download.eclipse.org/rt/rap/doc/3.3/guide/reference/theming/ToolTip.html Thanks, setting width and height works. Unfortunately, the change does not help with the initial issue for two reasons:
- max width and max height are still set to 50% of the available client document's size; hence, setting reasonable fix width will have no effect if it is greater than the respective max width (which will be the case on small screens)
- content is still cut off if it is too long
It would be great if width and height adjust automatically when no fix width and height has been defined via theming.
As a quick test I set the popup's maxWidth and maxHeight to 100% (instead of 50%) in Tooltip.construct and use the available width in ToolTip._update to calculate the message area's text and height:
_update : function() {
var popupWidth = this.getWidth();
if( popupWidth === "auto" ) {
//calculate how long the text may be at the most; start with calculating the message area's margin
var marginWidth = (this._wantedLeft ? this._wantedLeft : 20) * 2; //left margin * 2 to center the box; 20 as fallback...
//take the tooltip's other widths into account
marginWidth += this._image._computePreferredInnerWidth();
marginWidth += (this.getPaddingLeft() + this.getPaddingRight());
marginWidth += this._contentArea.getSpacing();
//subtract the value from the available client width
var doc = rwt.widgets.base.ClientDocument.getInstance();
var maxTextWidth = doc.getClientWidth() - marginWidth;
//proceed with calculating the message size
var message = this._message.getText();
var textSize = this._getTextSize( this._text.getText(), maxTextWidth );
var messageSize = this._getTextSize( message, maxTextWidth );
//following code omitted, since unchanged
}
}
This has also the benefit that long markup text without line breaks is not shown in a single line (which currently exceeds the popup width).
I don't know if this is a proper approach, and it has only quickly been tested with FF, Chrome and IE11 and with Chrome on a mobile. However, it does what I needed in my case, maybe you want to take a look at it.
Created attachment 272180 [details]
Current behavior with RWT 3.3.0...
Created attachment 272182 [details]
Changed behavior with RWT 3.3.0
I belatedly attached two images with current behavior and adjusted behavior of tool tip to show the differences.
Sebastian, could you provide a Gerrit change with your solution? It will be easer to evaluate and review it. New Gerrit change created: https://git.eclipse.org/r/116054 Ivan, I created the Gerrit change as requested (after reworking the approach). Sorry that it took me so long, I just had to find some time to set everything up. FYI: the rap-head-runtime-gerrit build failed after my first commit due to an error that does not seem to relate to the change (a test related to server push failed). Later, I amended my commit to remove some white space and fix indentations and after that the build was successful. Maybe you want to look into the failed build: [1] [1] https://hudson.eclipse.org/rap/job/rap-head-runtime-gerrit/2372/ Gerrit change https://git.eclipse.org/r/116054 was merged to [master]. Commit: http://git.eclipse.org/c/rap/org.eclipse.rap.git/commit/?id=05ca8cdfc38299f6e053937d67656339ee9e61ec |