MCPcopy Index your code
hub / github.com/benfry/processing4 / placeTabs

Method placeTabs

app/src/processing/app/ui/EditorHeader.java:268–310  ·  view source on GitHub ↗
(int left, int right, Graphics2D g)

Source from the content-addressed store, hash-verified

266
267
268 private boolean placeTabs(int left, int right, Graphics2D g) {
269 Sketch sketch = editor.getSketch();
270 int x = left;
271
272 for (int i = 0; i < sketch.getCodeCount(); i++) {
273 SketchCode code = sketch.getCode(i);
274 Tab tab = tabs[i];
275
276 int state = (code == sketch.getCurrentCode()) ? SELECTED : UNSELECTED;
277 tab.left = x;
278 x += TEXT_MARGIN;
279
280 int drawWidth = tab.textVisible ? tab.textWidth : NO_TEXT_WIDTH;
281 x += drawWidth + TEXT_MARGIN;
282 tab.right = x;
283
284 if (g != null && tab.right < right) {
285 g.setColor(tabColor[state]);
286 drawTab(g, tab.left, tab.right, i == 0, false, state == SELECTED);
287
288 if (tab.textVisible) {
289 int textLeft = tab.left + ((tab.right - tab.left) - tab.textWidth) / 2;
290 g.setColor(textColor[state]);
291 int tabHeight = TAB_BOTTOM - TAB_TOP;
292 int baseline = TAB_TOP + (tabHeight + fontAscent) / 2 + 1;
293 g.drawString(tab.text, textLeft, baseline);
294 }
295
296 if (code.isModified()) {
297 g.setColor(modifiedColor);
298 int barTop = TAB_TOP;
299 int barWidth = Toolkit.zoom(1);
300 int barHeight = (TAB_BOTTOM - barTop) + ((state == SELECTED) ? TAB_BELOW : 0);
301 int barLeft = tab.right - barWidth;
302 g.fillRect(barLeft, barTop,
303 barWidth,
304 barHeight);
305 }
306 }
307 x += TAB_BETWEEN;
308 }
309 return x <= right;
310 }
311
312
313 private void drawTab(Graphics g, int left, int right,

Callers 1

paintComponentMethod · 0.95

Calls 9

getCodeCountMethod · 0.95
getCodeMethod · 0.95
getCurrentCodeMethod · 0.95
drawTabMethod · 0.95
isModifiedMethod · 0.95
zoomMethod · 0.95
getSketchMethod · 0.80
setColorMethod · 0.45
drawStringMethod · 0.45

Tested by

no test coverage detected