MCPcopy Create free account
hub / github.com/Card-Forge/forge / draw

Method draw

forge-gui-mobile/src/forge/menu/FMenuTab.java:141–208  ·  view source on GitHub ↗
(Graphics g)

Source from the content-addressed store, hash-verified

139 }
140
141 @Override
142 public void draw(Graphics g) {
143 float x, y, w, h;
144
145 FSkinColor foreColor;
146 if (dropDown.isVisible()) {
147 x = PADDING; //round so lines show up reliably
148 y = PADDING;
149 w = getWidth() - 2 * x + 1;
150 h = getHeight() - y + 1;
151
152 g.startClip(x, y, w, h);
153 g.fillRect(getSelBackColor(), x, y, w, h);
154 g.drawRect(2, getSelBorderColor(), x, y, w, h);
155 g.endClip();
156
157 foreColor = getSelForeColor();
158 }
159 else {
160 foreColor = getForeColor();
161 }
162
163 //draw right separator
164 if (index < menuBar.getTabCount() - 1) {
165 x = getWidth();
166 y = getHeight() / 4;
167 g.drawLine(SEPARATOR_WIDTH, getSeparatorColor(), x, y, x, getHeight() - y);
168 }
169
170 x = PADDING;
171 y = PADDING;
172 w = getWidth() - 2 * PADDING;
173 h = getHeight() - 2 * PADDING;
174 if (isHovered())
175 g.fillRect(getSelBackColor().brighter(), x, y, w, h);
176
177 //flash overlay while a recent unread message highlights the tab
178 if (flashStartMs > 0) {
179 long elapsed = System.currentTimeMillis() - flashStartMs;
180 if (elapsed < FLASH_DURATION_MS) {
181 float alpha = 0.55f * (1f - (float) elapsed / FLASH_DURATION_MS);
182 g.fillRect(BADGE_COLOR.alphaColor(alpha), x, y, w, h);
183 Gdx.graphics.requestRendering();
184 } else {
185 flashStartMs = 0;
186 }
187 }
188
189 if (iconOnly) {
190 float mod = w * 0.75f;
191 FImage icon = active ? FSkinImage.SEE : FSkinImage.UNSEE;
192 float scaleW = w * 0.8f;
193 float scaleH = scaleW * 0.6f;
194 g.drawImage(icon, x + w/2 - scaleW/2, y + h/2 - scaleH/2, scaleW, scaleH);
195 } else
196 g.drawText(text, FONT, foreColor, x, y, w, h, false, Align.center, true);
197
198 //unread badge in the top-right corner

Callers

nothing calls this directly

Calls 15

getSelBackColorMethod · 0.95
getSelBorderColorMethod · 0.95
getSelForeColorMethod · 0.95
getForeColorMethod · 0.95
getSeparatorColorMethod · 0.95
scaleMethod · 0.95
fillRectMethod · 0.80
drawRectMethod · 0.80
endClipMethod · 0.80
getTabCountMethod · 0.80
drawLineMethod · 0.80
isHoveredMethod · 0.80

Tested by

no test coverage detected