|
Lines 185-190
Link Here
|
| 185 |
currentLocation = newLocation; |
185 |
currentLocation = newLocation; |
| 186 |
showPerspectiveBar(); |
186 |
showPerspectiveBar(); |
| 187 |
if(newLocation == TOP_LEFT || newLocation == TOP_RIGHT) { |
187 |
if(newLocation == TOP_LEFT || newLocation == TOP_RIGHT) { |
|
|
188 |
updateCBannerHeight(); |
| 188 |
updatePerspectiveBar(); |
189 |
updatePerspectiveBar(); |
| 189 |
setCoolItemSize(coolItem); |
190 |
setCoolItemSize(coolItem); |
| 190 |
} |
191 |
} |
|
Lines 345-351
Link Here
|
| 345 |
} |
346 |
} |
| 346 |
perspectiveBar.update(true); |
347 |
perspectiveBar.update(true); |
| 347 |
setCoolItemSize(coolItem); |
348 |
setCoolItemSize(coolItem); |
| 348 |
|
|
|
| 349 |
} |
349 |
} |
| 350 |
} |
350 |
} |
| 351 |
}; |
351 |
}; |
|
Lines 416-433
Link Here
|
| 416 |
// there is no coolItem when the bar is on the left |
416 |
// there is no coolItem when the bar is on the left |
| 417 |
if (currentLocation == LEFT) |
417 |
if (currentLocation == LEFT) |
| 418 |
return; |
418 |
return; |
| 419 |
|
419 |
|
| 420 |
ToolBar toolbar = perspectiveBar.getControl(); |
420 |
ToolBar toolbar = perspectiveBar.getControl(); |
| 421 |
if (toolbar == null) |
421 |
if (toolbar == null) |
| 422 |
return; |
422 |
return; |
| 423 |
|
|
|
| 424 |
int rowHeight = toolbar.getItem(0).getBounds().height; |
| 425 |
|
423 |
|
| 426 |
// This gets the height of the tallest item. |
424 |
int rowHeight = 0; |
| 427 |
for (int i = 1; i < perspectiveBar.getControl().getItemCount(); i++) { |
425 |
ToolItem[] toolItems = perspectiveBar.getControl().getItems(); |
| 428 |
rowHeight = Math.max(rowHeight, perspectiveBar.getControl().getItem(i).getBounds().height); |
426 |
for (int i = 0; i < toolItems.length; i++) { |
|
|
427 |
rowHeight = Math.max(rowHeight, toolItems[i].getBounds().height); |
| 429 |
} |
428 |
} |
| 430 |
|
429 |
|
| 431 |
Rectangle area = perspectiveCoolBar.getClientArea(); |
430 |
Rectangle area = perspectiveCoolBar.getClientArea(); |
| 432 |
int rows = rowHeight <= 0 ? 1 : (int)Math.max(1, Math.floor(area.height / rowHeight)); |
431 |
int rows = rowHeight <= 0 ? 1 : (int)Math.max(1, Math.floor(area.height / rowHeight)); |
| 433 |
if (rows == 1 || (toolbar.getStyle() & SWT.WRAP) == 0 || currentLocation == TOP_LEFT) { |
432 |
if (rows == 1 || (toolbar.getStyle() & SWT.WRAP) == 0 || currentLocation == TOP_LEFT) { |
|
Lines 671-679
Link Here
|
| 671 |
IContributionItem [] items = perspectiveBar.getItems(); |
670 |
IContributionItem [] items = perspectiveBar.getItems(); |
| 672 |
for( int i = 0; i < items.length; i++ ) |
671 |
for( int i = 0; i < items.length; i++ ) |
| 673 |
items[i].update(); |
672 |
items[i].update(); |
|
|
673 |
|
| 674 |
// make sure the selected item is visible |
674 |
// make sure the selected item is visible |
| 675 |
perspectiveBar.arrangeToolbar(); |
675 |
perspectiveBar.arrangeToolbar(); |
|
|
676 |
setCoolItemSize(coolItem); |
| 676 |
perspectiveBar.getControl().redraw(); |
677 |
perspectiveBar.getControl().redraw(); |
| 677 |
} |
678 |
} |
| 678 |
|
679 |
|
|
|
680 |
/** |
| 681 |
* Updates the height of the CBanner if the perspective bar |
| 682 |
* is docked on the top right |
| 683 |
*/ |
| 684 |
public void updateCBannerHeight() { |
| 685 |
if (topBar == null || perspectiveBar == null || perspectiveBar.getControl() == null || |
| 686 |
currentLocation != TOP_RIGHT) |
| 687 |
return; |
| 688 |
// This gets the height of the tallest tool item. |
| 689 |
int maxRowHeight = 0; |
| 690 |
ToolItem[] toolItems = perspectiveBar.getControl().getItems(); |
| 691 |
for (int i = 0; i < toolItems.length; i++) { |
| 692 |
maxRowHeight = Math.max(maxRowHeight, toolItems[i].getBounds().height); |
| 693 |
} |
| 694 |
// This sets the CBanner's minimum height to support large fonts |
| 695 |
topBar.setMinRightHeight(maxRowHeight); |
| 696 |
LayoutUtil.resize(perspectiveBar.getControl()); |
| 697 |
} |
| 679 |
} |
698 |
} |