Skip to content

Commit 618a6e5

Browse files
committed
Allowed menu to 'stick' to the right when too many tabs exist. Tabs that cannot be displayed are automatically hidden. Removed old code which attempted to reduce tab size by hiding the text
1 parent ac8ebc4 commit 618a6e5

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

app/src/processing/app/EditorHeader.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,9 @@ public void paintComponent(Graphics screen) {
273273
tab.textWidth = (int)
274274
font.getStringBounds(tab.text, g2.getFontRenderContext()).getWidth();
275275
}
276-
276+
/* TODO eliminated 279-302 because it doesn't really work to reduce the tab size (by much anyways)
277+
* and makes it confusing to find the tab you want because the name is hidden
278+
*
277279
// make sure everything can fit
278280
if (!placeTabs(MARGIN_WIDTH, tabMax, null)) {
279281
//System.arraycopy(tabs, 0, visitOrder, 0, tabs.length);
@@ -297,14 +299,19 @@ public void paintComponent(Graphics screen) {
297299
break;
298300
}
299301
}
300-
}
302+
}*/
301303

302304
// now actually draw the tabs
303-
placeTabs(MARGIN_WIDTH, tabMax, g2);
304-
305-
// draw the dropdown menu target
306-
menuLeft = tabs[tabs.length - 1].right + TAB_BETWEEN;
307-
menuRight = menuLeft + ARROW_TAB_WIDTH;
305+
if(!placeTabs(MARGIN_WIDTH, tabMax - ARROW_TAB_WIDTH, g2)){
306+
// draw the dropdown menu target at the right of the window
307+
menuRight = tabMax;
308+
menuLeft = menuRight - ARROW_TAB_WIDTH;
309+
} else {
310+
// draw the dropdown menu target next to the tabs
311+
menuLeft = tabs[tabs.length - 1].right + TAB_BETWEEN;
312+
menuRight = menuLeft + ARROW_TAB_WIDTH;
313+
}
314+
308315
g.setColor(tabColor[UNSELECTED]);
309316
drawTab(g, menuLeft, menuRight);
310317
// int arrowY = (getHeight() - TAB_HEIGHT - TAB_STRETCH) + (TAB_HEIGHT - ARROW_HEIGHT)/2;
@@ -370,7 +377,7 @@ private boolean placeTabs(int left, int right, Graphics2D g) {
370377
// }
371378
tab.right = x;
372379

373-
if (g != null) {
380+
if (g != null && tab.right < right) {
374381
g.setColor(tabColor[state]);
375382
drawTab(g, tab.left, tab.right);
376383
// path.lineTo(x - NOTCH, top);

0 commit comments

Comments
 (0)