Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 234037

Summary: [ToolBar] Preferred size too wide
Product: [RT] RAP Reporter: Ralf Sternberg <rsternberg>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ruediger.herrmann
Version: 1.0Flags: ruediger.herrmann: review+
Target Milestone: 1.1.1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 190072    
Attachments:
Description Flags
Screenshot of the sample snippet
none
Patch that repairs the width computation of ToolItem none

Description Ralf Sternberg CLA 2008-05-26 17:41:55 EDT
The width computed by ToolBars exceeds the width of the included ToolItems.

public class ToolBarSnippet implements IEntryPoint {

  public int createUI() {
    Display display = new Display();
    Shell shell = new Shell( display );
    shell.setText( "ToolBar Snippet" );
    shell.setLayout( new GridLayout() );

    ToolBar toolBar = new ToolBar( shell, SWT.BORDER );
    new ToolItem( toolBar, SWT.PUSH ).setText( "Item 1" );
    new ToolItem( toolBar, SWT.PUSH ).setText( "Item 2" );

    shell.setSize( 400, 300 );
    shell.open();
    while( !shell.isDisposed() ) {
      if( !display.readAndDispatch() ) {
        display.sleep();
      }
    }
    return 0;
  }
}
Comment 1 Ralf Sternberg CLA 2008-05-26 17:43:02 EDT
Created attachment 102059 [details]
Screenshot of the sample snippet
Comment 2 Ralf Sternberg CLA 2008-05-30 16:58:46 EDT
Created attachment 102960 [details]
Patch that repairs the width computation of ToolItem

With this patch the computed width matches exactly the real client-side width.

In getWidth(), there were 11 px added in favor of the workbench perspective switcher. I assume that this appeared in TextSizeEstimation times and is now obsolete. Although the perspective switcher is still too small in the first session, I do not see a difference through this patch.
Comment 3 Ralf Sternberg CLA 2008-06-02 05:32:09 EDT
Not sure whether this is critical enough to commit it into the release. Anyway, I think it's harmless.
Comment 4 Ralf Sternberg CLA 2008-08-19 16:58:46 EDT
Fixed in CVS HEAD. Size computation works correct now for ToolItem and ToolBar.