MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / drawPopupMenuItem

Method drawPopupMenuItem

Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.cpp:1221–1339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1219}
1220
1221void CtrlrPopupMenuLook::drawPopupMenuItem (Graphics& g,
1222 int width, int height,
1223 const bool isSeparator,
1224 const bool isActive,
1225 const bool isHighlighted,
1226 const bool isTicked,
1227 const bool hasSubMenu,
1228 const String& text,
1229 const String& shortcutKeyText,
1230 Image* image,
1231 const Colour* const textColourToUse)
1232{
1233 const float halfH = height * 0.5f;
1234
1235 bool hasSecondLine = false;
1236 if (text.indexOf("\n") > 0)
1237 hasSecondLine = true;
1238 const int secondLineStart = Font(14).getStringWidth(text.upToFirstOccurrenceOf("\n",false, true));
1239 const String secondLine = text.fromLastOccurrenceOf("\n", false, true);
1240 const String ttext = text.upToFirstOccurrenceOf("\n", false, true);
1241
1242 if (isSeparator)
1243 {
1244 const float separatorIndent = 5.5f;
1245
1246 g.setColour (Colour (0x33000000));
1247 g.drawLine (separatorIndent, halfH, width - separatorIndent, halfH);
1248
1249 g.setColour (Colour (0x66ffffff));
1250 g.drawLine (separatorIndent, halfH + 1.0f, width - separatorIndent, halfH + 1.0f);
1251 }
1252 else
1253 {
1254 Colour textColour (Colours::black);
1255
1256 if (textColourToUse != nullptr)
1257 textColour = *textColourToUse;
1258
1259 if (isHighlighted)
1260 {
1261 g.setColour (Colour(0x991111aa));
1262 g.fillRect (1, 1, width - 2, height - 2);
1263
1264 g.setColour (Colours::white);
1265 }
1266 else
1267 {
1268 g.setColour (textColour);
1269 }
1270
1271 if (! isActive)
1272 g.setOpacity (0.3f);
1273
1274 Font font (14);
1275
1276 if (font.getHeight() > height / 1.3f)
1277 font.setHeight (height / 1.3f);
1278

Callers

nothing calls this directly

Calls 15

FontClass · 0.85
ColourFunction · 0.85
upToFirstOccurrenceOfMethod · 0.80
fromLastOccurrenceOfMethod · 0.80
drawImageWithinMethod · 0.80
drawFittedTextMethod · 0.80
setHorizontalScaleMethod · 0.80
addTriangleMethod · 0.80
indexOfMethod · 0.45
getStringWidthMethod · 0.45
setColourMethod · 0.45

Tested by

no test coverage detected