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

Method drawPopupMenuItem

Source/UIComponents/CtrlrComponents/CtrlrCombo.cpp:335–438  ·  view source on GitHub ↗

void CtrlrCombo::CtrlrComboLF::drawPopupMenuItem (Graphics &g, int width, int height, bool isSeparator, bool isActive, bool isHighlighted, bool isTicked, bool hasSubMenu, const String &text, const String &shortcutKeyText, Image *image, const Colour *const textColourToUse)

Source from the content-addressed store, hash-verified

333
334//void CtrlrCombo::CtrlrComboLF::drawPopupMenuItem (Graphics &g, int width, int height, bool isSeparator, bool isActive, bool isHighlighted, bool isTicked, bool hasSubMenu, const String &text, const String &shortcutKeyText, Image *image, const Colour *const textColourToUse)
335void CtrlrCombo::CtrlrComboLF::drawPopupMenuItem (Graphics &g, const Rectangle<int>& area,
336 bool isSeparator, bool isActive, bool isHighlighted, bool isTicked, bool hasSubMenu,
337 const String& text, const String& shortcutKeyText,
338 const Drawable* icon, const Colour* textColourToUse)
339{
340 const int width = area.getWidth();
341 const int height = area.getHeight();
342
343 const float halfH = height * 0.5f;
344
345 if (isSeparator)
346 {
347 const float separatorIndent = 5.5f;
348
349 g.setColour (Colour (0x33000000));
350 g.drawLine (separatorIndent, halfH, width - separatorIndent, halfH);
351
352 g.setColour (Colour (0x66ffffff));
353 g.drawLine (separatorIndent, halfH + 1.0f, width - separatorIndent, halfH + 1.0f);
354 }
355 else
356 {
357 Colour textColour = VAR2COLOUR(owner.getProperty(Ids::uiComboMenuFontColour));
358
359 if (textColourToUse != nullptr)
360 {
361 _DBG("Using passed in colour: "+textColourToUse->toString());
362 textColour = *textColourToUse;
363 }
364
365 if (isHighlighted)
366 {
367 g.setColour (VAR2COLOUR(owner.getProperty(Ids::uiComboMenuHighlightColour)));
368 g.fillRect (1, 1, width - 2, height - 2);
369
370 g.setColour (VAR2COLOUR(owner.getProperty(Ids::uiComboMenuFontHighlightedColour)));
371 }
372 else
373 {
374 g.setColour (textColour);
375 }
376
377 if (! isActive)
378 g.setOpacity (0.3f);
379
380 Font font = owner.getOwner().getOwnerPanel().getCtrlrManagerOwner().getFontManager().getFontFromString (owner.getProperty(Ids::uiComboMenuFont));
381
382 if (font.getHeight() > height / 1.3f)
383 font.setHeight (height / 1.3f);
384
385 g.setFont (font);
386
387 const int leftBorder = (height * 5) / 4;
388 const int rightBorder = 4;
389
390 if (icon != nullptr)
391 {
392 icon->drawWithin (g, Rectangle<float>(2, 1, leftBorder - 4, height - 2), RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f);

Callers

nothing calls this directly

Calls 15

ColourFunction · 0.85
getFontFromStringMethod · 0.80
drawWithinMethod · 0.80
drawFittedTextMethod · 0.80
setHorizontalScaleMethod · 0.80
drawTextMethod · 0.80
addTriangleMethod · 0.80
getWidthMethod · 0.45
getHeightMethod · 0.45
setColourMethod · 0.45
drawLineMethod · 0.45

Tested by

no test coverage detected