//------------------------------------------------------------------------------ void MappingsDialog::paintListBoxItem(int rowNumber, Graphics &g, int width, int height, bool rowIsSelected) { Colour highlight = ColourScheme::getInstance().colours[L"List Selected Colour"]; if(rowIsSelected) { ColourGradient basil(highlight.brighter(0.4f), 0.0f, 0.0f, highlight.darker(0.125f), 0.0f, (float)height, false); g.setGradientFill(basil); g.fillAll(); } else if(rowNumber%2) g.fillAll(Colour(0x10000000)); /*else g.fillAll(Colour(0xFFFFFFFF));*/ }
//============================================================================== void LookAndFeel_V1::drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) { const int width = button.getWidth(); const int height = button.getHeight(); const float indent = 2.0f; const int cornerSize = jmin (roundToInt (width * 0.4f), roundToInt (height * 0.4f)); Path p; p.addRoundedRectangle (indent, indent, width - indent * 2.0f, height - indent * 2.0f, (float) cornerSize); Colour bc (backgroundColour.withMultipliedSaturation (0.3f)); if (shouldDrawButtonAsHighlighted) { if (shouldDrawButtonAsDown) bc = bc.brighter(); else if (bc.getBrightness() > 0.5f) bc = bc.darker (0.1f); else bc = bc.brighter (0.1f); } g.setColour (bc); g.fillPath (p); g.setColour (bc.contrasting().withAlpha ((shouldDrawButtonAsHighlighted) ? 0.6f : 0.4f)); g.strokePath (p, PathStrokeType ((shouldDrawButtonAsHighlighted) ? 2.0f : 1.4f)); }
//------------------------------------------------------------------------------ void StartupPreferences::setColours(const Colour& backCol, const Colour& textCol, const Colour& buttonCol) { backgroundColour = backCol; textColour = textCol; startupsLabel->setColour(Label::textColourId, textColour); textLabel->setColour(Label::textColourId, textColour); execLabel->setColour(Label::textColourId, textColour); addItem->setBackgroundColours(buttonCol, buttonCol.darker(2.5f)); removeItem->setBackgroundColours(buttonCol, buttonCol.darker(2.5f)); clearItems->setBackgroundColours(buttonCol, buttonCol.darker(2.5f)); itemUp->setBackgroundColours(buttonCol, buttonCol.darker(2.5f)); itemDown->setBackgroundColours(buttonCol, buttonCol.darker(2.5f)); }
void DemoLookAndFeel::drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour, bool isMouseOverButton, bool isButtonDown) { const int width = button.getWidth(); const int height = button.getHeight(); // const float outlineThickness = button.isEnabled() ? ((isButtonDown || isMouseOverButton) ? 1.2f : 0.7f) : 0.4f; // const float halfThickness = outlineThickness * 0.5f; // const float indentL = button.isConnectedOnLeft() ? 0.1f : halfThickness; // const float indentR = button.isConnectedOnRight() ? 0.1f : halfThickness; // const float indentT = button.isConnectedOnTop() ? 0.1f : halfThickness; // const float indentB = button.isConnectedOnBottom() ? 0.1f : halfThickness; const Colour baseColour (GuiHelpers::createBaseColour (backgroundColour, button.hasKeyboardFocus (true), isMouseOverButton, isButtonDown) .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f)); ColourGradient cg (baseColour.brighter (0.5f), 0.0f, 0.0f, baseColour.darker (0.5f), 0.0f, (float)height, false); Rectangle<float> bounds (g.getClipBounds().toFloat().reduced (0.0f, 1.0f)); g.setGradientFill (cg); g.fillRoundedRectangle (bounds, 4.0f); bounds.setX (bounds.getX() + 0.5f); bounds.setWidth (bounds.getWidth() - 1.0f); bounds.setY (bounds.getY() - 0.5f); bounds.setHeight (bounds.getHeight()); g.setColour (Colours::black); g.drawRoundedRectangle (bounds, 4.0f, 1.0f); ColourGradient highlight (Colours::white.withAlpha (0.1f), 2.0f, (float)height, Colours::white.withAlpha (0.1f), width - 2.0f, (float)height, false); highlight.addColour (2.0f / (width - 4.0f), Colours::white.withAlpha (0.5f)); highlight.addColour (1.0f - (2.0f / (width - 4.0f)), Colours::white.withAlpha (0.5f)); g.setGradientFill (highlight); g.drawLine (2.0f, height - 0.5f, width - 2.0f, height - 0.5f, 0.5f); // drawGlassLozenge (g, // indentL, // indentT, // width - indentL - indentR, // height - indentT - indentB, // baseColour, outlineThickness, -1.0f, // button.isConnectedOnLeft(), // button.isConnectedOnRight(), // button.isConnectedOnTop(), // button.isConnectedOnBottom()); }
void AutomationEvent::paint (Graphics& g) { Colour fillColour = colour; Colour borderColour = outlineColour; int borderWidth = 1; if (hasBeenSelected) { fillColour = fillColour.darker (0.6); borderColour = borderColour.darker (); borderWidth = 2; } g.setColour (fillColour); g.fillEllipse (0, 0, getWidth(), getHeight()); g.setColour (borderColour); g.drawEllipse (0, 0, getWidth(), getHeight(), borderWidth); }
void CustomLookAndFeel::drawLinearSliderThumb (Graphics& g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle style, Slider& slider) { if (style == Slider::LinearVertical) { bool isDownOrDragging = slider.isEnabled() && (slider.isMouseOverOrDragging() || slider.isMouseButtonDown()); Colour knobColour (slider.findColour (Slider::thumbColourId).withMultipliedSaturation ((slider.hasKeyboardFocus (false) || isDownOrDragging) ? 1.3f : 0.9f) .withMultipliedAlpha (slider.isEnabled() ? 1.0f : 0.7f)); const float thumbWidth = jmin (slider.getWidth() - 2 * spaceBetweenThumbAndComponentBorder, maxThumbWidthVertical); const float thumbHeight = thumbWidth * heightToWidthRatioVertical; const float xCenter = x + width * 0.5f; // Originally it was yCenter = sliderPos. But that way the thumb (and especially the center line) did // not always look the same because of aliasing. With this additional rounding it is ensured that the // vertical position of the thumb "snaps" to the closest pixel and therefore looks always the same. const float yCenter = (int)(sliderPos) + 0.5f; const float xThumb = xCenter - 0.5f * thumbWidth; const float yThumb = yCenter - 0.5f * thumbHeight; // The shape of the thumb Path p; p.addRoundedRectangle(xThumb, yThumb, thumbWidth, thumbHeight, 5.0f); // Drop shadow const DropShadow ds (Colours::black, 4, Point<int> (0, 0)); ds.drawForPath (g, p); // Outline const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f; g.setColour (Colours::black); //g.setColour (knobColour.darker()); g.strokePath (p, PathStrokeType (outlineThickness)); // Fill ColourGradient gradient (knobColour.darker(), xThumb, yThumb, knobColour.darker(), xThumb, yThumb + thumbHeight, false); gradient.addColour (0.5, knobColour.brighter()); g.setGradientFill(gradient); g.fillPath (p); // g.setColour (knobColour); // g.fillPath (p); // Middle line g.setColour(Colours::black); g.drawLine(xThumb, yCenter, xThumb + thumbWidth, yCenter); } else { // Just call the base class for the demo LookAndFeel_V3::drawLinearSliderThumb (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider); } }
//============================================================================== void PianoGrid::paint (Graphics& g) { Colour blackKey = findColour (MidiGrid::blackKeyColourId); Colour blackKeyBright = findColour (MidiGrid::blackKeyBrightColourId); Colour whiteKey = findColour (MidiGrid::whiteKeyColourId); Colour whiteKeyBright = findColour (MidiGrid::whiteKeyBrightColourId); Colour rowGrid = findColour (MidiGrid::backGridColourId); Colour rowGridDark = rowGrid.darker (1.0f); Colour rowGridBright = rowGrid.brighter (1.0f); float currentHeight = rowHeight - noteAdjustOffset [0]; float previousHeight = 0; float pos_y = getHeight() - currentHeight; // draw rows for (int i = rowsOffset; (i < numRows) && ((pos_y + previousHeight) >= 0.0f); i++) { int noteNumber = i % 12; int octaveNumber = i / 12; previousHeight = currentHeight; switch (noteNumber) { case 1: case 3: case 6: case 8: case 10: // black keys g.setColour (blackKeyBright); break; default: // white keys g.setColour (whiteKeyBright); break; } // fill background g.fillRect (0, (int) pos_y + 1, getWidth(), (int) previousHeight - 1); // fill divider line g.setColour (rowGridBright); g.drawHorizontalLine ((int) pos_y, 0, getWidth()); // offset for next height int nextNoteNumber = (i + 1) % 12; int nextOctaveNumber = (i + 1) / 12; currentHeight = rowHeight - noteAdjustOffset [nextNoteNumber] - ((nextOctaveNumber != octaveNumber) ? 1 : 0); pos_y -= currentHeight; } MidiGrid::paintBarLines(g); }
void PianoGridNote::paint (Graphics& g) { Colour fillColour = findColour (PianoGrid::noteFillColourId); Colour borderColour = findColour (PianoGrid::noteBorderColourId); int borderWidth = 1; if (hasBeenSelected) { fillColour = fillColour.darker (0.6); borderColour = borderColour.darker (); borderWidth = 2; } float alphaStep = 0.2f + velocity * 0.8f; fillColour = fillColour.withAlpha (alphaStep); borderColour = borderColour.withAlpha (alphaStep); g.fillAll (fillColour); g.setColour (borderColour); g.drawRect (0, 0, getWidth(), getHeight(), borderWidth); }
//============================================================================== void MidiGrid::paintBarLines (Graphics& g) { Colour blackKey = findColour (MidiGrid::blackKeyColourId); Colour blackKeyBright = findColour (MidiGrid::blackKeyBrightColourId); Colour whiteKey = findColour (MidiGrid::whiteKeyColourId); Colour whiteKeyBright = findColour (MidiGrid::whiteKeyBrightColourId); Colour rowGrid = findColour (MidiGrid::backGridColourId); Colour rowGridDark = rowGrid.darker (1.0f); Colour rowGridBright = rowGrid.brighter (1.0f); // draw columns float pos_x = 0.0f; int dynamicGridSize = 1; if (barWidth < 20) dynamicGridSize = 1; else if (barWidth < 80) dynamicGridSize = divDenominator * 1; else if (barWidth < 200) dynamicGridSize = divDenominator * 2; else if (barWidth < 440) dynamicGridSize = divDenominator * 4; else if (barWidth < 920) dynamicGridSize = divDenominator * 8; else if (barWidth < 1050) dynamicGridSize = divDenominator * 16; int beatDivider = jmax (1, dynamicGridSize / divDenominator); float deltaWidth = barWidth / (float) (dynamicGridSize); for (int b = 0; (b < numBars) && (pos_x <= getWidth ()); b++) { for (int i = 0; i < dynamicGridSize; i++) { int columnIsBarStart = (i == 0); int columnIsBeatStart = (i % beatDivider != 0); if (columnIsBarStart) g.setColour (rowGridDark); else if (columnIsBeatStart) g.setColour (rowGridBright); else g.setColour (rowGrid); g.drawVerticalLine ((int) pos_x, 0, getHeight()); pos_x += deltaWidth; } } g.setColour (rowGrid); g.drawVerticalLine ((int) pos_x, 0, getHeight()); }
void IntrojucerLookAndFeel::drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour, bool isMouseOverButton, bool isButtonDown) { const bool flatOnLeft = button.isConnectedOnLeft(); const bool flatOnRight = button.isConnectedOnRight(); const bool flatOnTop = button.isConnectedOnTop(); const bool flatOnBottom = button.isConnectedOnBottom(); const float width = (float) button.getWidth(); const float height = (float) button.getHeight(); const float x = 0.5f; const float y = 0.5f; const float w = width - 1.0f; const float h = height - 1.0f; const float cornerSize = 4.0f; Colour baseColour (backgroundColour.withMultipliedSaturation (button.hasKeyboardFocus (true) ? 1.3f : 0.9f) .withMultipliedAlpha (button.isEnabled() ? 0.9f : 0.5f)); if (isButtonDown) baseColour = baseColour.contrasting (0.2f); else if (isMouseOverButton) baseColour = baseColour.contrasting (0.1f); const float mainBrightness = baseColour.getBrightness(); const float mainAlpha = baseColour.getFloatAlpha(); Path outline; outline.addRoundedRectangle (x, y, w, h, cornerSize, cornerSize, ! (flatOnLeft || flatOnTop), ! (flatOnRight || flatOnTop), ! (flatOnLeft || flatOnBottom), ! (flatOnRight || flatOnBottom)); g.setGradientFill (ColourGradient (baseColour.brighter (0.2f), 0.0f, 0.0f, baseColour.darker (0.25f), 0.0f, height, false)); g.fillPath (outline); g.setColour (Colours::white.withAlpha (0.4f * mainAlpha * mainBrightness * mainBrightness)); g.strokePath (outline, PathStrokeType (1.0f), AffineTransform::translation (0.0f, 1.0f) .scaled (1.0f, (h - 1.6f) / h)); g.setColour (Colours::black.withAlpha (0.4f * mainAlpha)); g.strokePath (outline, PathStrokeType (1.0f)); }
static void drawButtonShape (Graphics& g, const Path& outline, Colour baseColour, float height) { const float mainBrightness = baseColour.getBrightness(); const float mainAlpha = baseColour.getFloatAlpha(); g.setGradientFill (ColourGradient (baseColour.brighter (0.2f), 0.0f, 0.0f, baseColour.darker (0.25f), 0.0f, height, false)); g.fillPath (outline); g.setColour (Colours::white.withAlpha (0.4f * mainAlpha * mainBrightness * mainBrightness)); g.strokePath (outline, PathStrokeType (1.0f), AffineTransform::translation (0.0f, 1.0f) .scaled (1.0f, (height - 1.6f) / height)); g.setColour (Colours::black.withAlpha (0.4f * mainAlpha)); g.strokePath (outline, PathStrokeType (1.0f)); }
void ChannelStripComponent::paint (Graphics& g) { Colour backgroundColour = Colours::transparentBlack; g.setGradientFill(ColourGradient(backgroundColour.brighter(0.25f), 0.0f, 0.0f, backgroundColour.darker(0.25f), 0.0f, static_cast<float>(getHeight()), 0)); g.fillAll (); // clear the background g.drawLine(0.0f, 0.0f, static_cast<float>(getWidth()), static_cast<float>(getHeight())); g.setColour(Colours::steelblue); g.drawRect (getLocalBounds(), 2); // draw an outline around the component g.setColour(Colours::black); g.drawRect(getLocalBounds(), 1); // draw an outline around the component }
//============================================================================== void DrawablePad::drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour, bool isMouseOverButton, bool isButtonDown) { const int width = button.getWidth(); const int height = button.getHeight(); const float indent = 2.0f; const int cornerSize = jmin (roundFloatToInt (width * roundness), roundFloatToInt (height * roundness)); Colour bc (backgroundColour); if (isMouseOverButton) { if (isButtonDown) bc = bc.brighter(); else if (bc.getBrightness() > 0.5f) bc = bc.darker (0.1f); else bc = bc.brighter (0.1f); } g.setColour (bc); if (hex) { g.fillPath (hexpath); g.setColour (bc.contrasting().withAlpha ((isMouseOverButton) ? 0.6f : 0.4f)); g.strokePath (hexpath, PathStrokeType ((isMouseOverButton) ? 2.0f : 1.4f)); } else { Path p; p.addRoundedRectangle (indent, indent, width - indent * 2.0f, height - indent * 2.0f, (float) cornerSize); g.fillPath (p); g.setColour (bc.contrasting().withAlpha ((isMouseOverButton) ? 0.6f : 0.4f)); g.strokePath (p, PathStrokeType ((isMouseOverButton) ? 2.0f : 1.4f)); } }
void TaskContextListBoxModel::ItemComponent::paint (juce::Graphics& g) { Colour colour (Colours::lightgrey); if (getTaskContext() != nullptr) { if (getTaskContext()->getState() == TaskContext::taskCompleted) { if (getTaskContext()->getResult().wasOk()) colour = Colours::lightgreen; else colour = Colours::red.brighter(); } } g.setColour (colour); g.fillRect(getLocalBounds()); g.setColour (colour.darker(0.05f)); g.drawHorizontalLine(getHeight()-1,0.0f,(float)getWidth()); }
void drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour, bool isMouseOverButton, bool isButtonDown) override { Colour baseColour (backgroundColour.withMultipliedSaturation (button.hasKeyboardFocus (true) ? 1.3f : 0.9f) .withMultipliedAlpha (button.isEnabled() ? 0.9f : 0.5f)); if (isButtonDown || isMouseOverButton) baseColour = baseColour.contrasting (isButtonDown ? 0.2f : 0.1f); const float width = button.getWidth() - 1.0f; const float height = button.getHeight() - 1.0f; if (width > 0 && height > 0) { g.setGradientFill (ColourGradient (baseColour, 0.0f, 0.0f, baseColour.darker (0.1f), 0.0f, height, false)); g.fillRect (button.getLocalBounds()); } }
void LookAndFeel_E1::drawKeymapChangeButton (Graphics& g, int width, int height, Button& button, const String& keyDescription) { const Colour textColour (button.findColour (0x100ad01 /*KeyMappingEditorComponent::textColourId*/, true)); if (keyDescription.isNotEmpty()) { if (button.isEnabled()) { g.setColour (textColour.withAlpha (button.isDown() ? 0.4f : (button.isOver() ? 0.2f : 0.1f))); g.fillRoundedRectangle (button.getLocalBounds().toFloat(), 4.0f); g.drawRoundedRectangle (button.getLocalBounds().toFloat(), 4.0f, 1.0f); } g.setColour (textColour); g.setFont (height * 0.6f); g.drawFittedText (keyDescription, 4, 0, width - 8, height, Justification::centred, 1); } else { const float thickness = 7.0f; const float indent = 22.0f; Path p; p.addEllipse (0.0f, 0.0f, 100.0f, 100.0f); p.addRectangle (indent, 50.0f - thickness, 100.0f - indent * 2.0f, thickness * 2.0f); p.addRectangle (50.0f - thickness, indent, thickness * 2.0f, 50.0f - indent - thickness); p.addRectangle (50.0f - thickness, 50.0f + thickness, thickness * 2.0f, 50.0f - indent - thickness); p.setUsingNonZeroWinding (false); g.setColour (textColour.darker(0.1f).withAlpha (button.isDown() ? 0.7f : (button.isOver() ? 0.5f : 0.3f))); g.fillPath (p, p.getTransformToScaleToFit (2.0f, 2.0f, width - 4.0f, height - 4.0f, true)); } if (button.hasKeyboardFocus (false)) { g.setColour (textColour.withAlpha (0.4f)); g.drawRect (0, 0, width, height); } }
//============================================================================== void NonShinyLookAndFeel::drawGlassSphere (Graphics& g, const float x, const float y, const float diameter, const Colour& colour, const float outlineThickness) throw() { if (diameter <= outlineThickness) return; Path p; p.addEllipse (x, y, diameter, diameter); { ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y, Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y + diameter, false); cg.addColour (0.4, Colours::white.overlaidWith (colour)); g.setGradientFill (cg); g.fillPath (p); } g.setGradientFill (ColourGradient (Colours::white, 0, y + diameter * 0.06f, Colours::transparentWhite, 0, y + diameter * 0.3f, false)); //g.fillEllipse (x + diameter * 0.2f, y + diameter * 0.05f, diameter * 0.6f, diameter * 0.4f); ColourGradient cg (Colours::transparentBlack, x + diameter * 0.5f, y + diameter * 0.5f, Colours::black.withAlpha (0.5f * outlineThickness * colour.getFloatAlpha()), x, y + diameter * 0.5f, true); cg.addColour (0.7, Colours::transparentBlack); cg.addColour (0.8, Colours::black.withAlpha (0.1f * outlineThickness)); g.setGradientFill (cg); g.fillPath (p); g.setColour (colour.darker(10.f).withAlpha (0.5f * colour.getFloatAlpha())); g.drawEllipse (x, y, diameter, diameter, outlineThickness); }
//============================================================================== void SunriseSleeper::paint (Graphics& g) { //[UserPrePaint] Add your own custom painting code here.. //[/UserPrePaint] g.fillAll (Colours::black); //[UserPaint] Add your own custom painting code here.. for (int y=0; y<getHeight()/16; y++) { Random r (Time::getHighResolutionTicks()); for (int x=0; x<getWidth()/16; x++) { Colour c = Colour (255, r.nextInt(128), r.nextInt(54)); g.setColour (c.darker()); g.drawRect (x*16, y*16, 16, 16); g.setColour (c); g.fillRect (x*16 + 1, y*16 + 1, 16 - 2, 16 - 2); } } //[/UserPaint] }
void drawRotarySlider (Graphics& g, int x, int y, int width, int height, float sliderPos, float rotaryStartAngle, float rotaryEndAngle, Slider& slider) override { const float diameter = jmin (width, height) - 4.0f; const float radius = (diameter / 2.0f) * std::cos (float_Pi / 4.0f); const float centreX = x + width * 0.5f; const float centreY = y + height * 0.5f; const float rx = centreX - radius; const float ry = centreY - radius; const float rw = radius * 2.0f; const float angle = rotaryStartAngle + sliderPos * (rotaryEndAngle - rotaryStartAngle); const bool isMouseOver = slider.isMouseOverOrDragging() && slider.isEnabled(); const Colour baseColour (slider.isEnabled() ? slider.findColour (Slider::rotarySliderFillColourId).withAlpha (isMouseOver ? 0.8f : 1.0f) : Colour (0x80808080)); Rectangle<float> r (rx, ry, rw, rw); AffineTransform t (AffineTransform::rotation (angle, r.getCentreX(), r.getCentreY())); float x1 = r.getTopLeft().getX(), y1 = r.getTopLeft().getY(), x2 = r.getBottomLeft().getX(), y2 = r.getBottomLeft().getY(); t.transformPoints (x1, y1, x2, y2); g.setGradientFill (ColourGradient (baseColour, x1, y1, baseColour.darker (0.1f), x2, y2, false)); Path knob; knob.addRectangle (r); g.fillPath (knob, t); Path needle; Rectangle<float> r2 (r * 0.1f); needle.addRectangle (r2.withPosition (Point<float> (r.getCentreX() - (r2.getWidth() / 2.0f), r.getY()))); g.setColour (slider.findColour (Slider::rotarySliderOutlineColourId)); g.fillPath (needle, AffineTransform::rotation (angle, r.getCentreX(), r.getCentreY())); }
//============================================================================== void PizLookAndFeel::drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour, bool isMouseOverButton, bool isButtonDown) { const int width = button.getWidth(); const int height = button.getHeight(); const float indent = 2.0f; const int cornerSize = 0; Path p; p.addRoundedRectangle (indent, indent, width - indent * 2.0f, height - indent * 2.0f, (float) cornerSize); Colour bc (backgroundColour);//.withMultipliedSaturation (0.3f)); if (isMouseOverButton) { if (isButtonDown) bc = bc.brighter(); else if (bc.getBrightness() > 0.5f) bc = bc.darker (0.1f); else bc = bc.brighter (0.1f); } g.setColour (bc); g.fillPath (p); g.setColour (bc.contrasting().withAlpha ((isMouseOverButton) ? 0.6f : 0.4f)); g.strokePath (p, PathStrokeType ((isMouseOverButton) ? 2.0f : 1.4f)); }
//============================================================================== void GraphComponent::nodePaint (GraphNodeComponent* node, Graphics& g) { int width = node->getWidth(), height = node->getHeight(); bool selected = selectedNodes.isSelected (node), locked = node->isLocked(); // background Colour background; #if 0 if (selected) background = findColour (GraphComponent::nodeBackBrightColourId); else background = findColour (GraphComponent::nodeBackColourId); #endif background = node->getNodeColour (); if (selected) background = background.brighter (0.3f); #if 0 g.setColour (background); g.fillRect (0, 0, width, height); #else g.setGradientFill (ColourGradient(background, 0.0f, 0.0f, background.darker (0.3f), 0.0f, height - 1.0f, false)); g.fillAll(); #endif // plugin text if (selected) g.setColour (findColour (GraphComponent::nodeTextBrightColourId)); else g.setColour (findColour (GraphComponent::nodeTextColourId)); String textToDisplay = node->getText (); if (textToDisplay != String::empty) { g.setFont (currentFont); if (leftToRight) { int stringWidth = currentFont.getStringWidth (textToDisplay); int offX = width / 2 - (int) currentFont.getHeight () / 2; int offY = height / 2 - stringWidth / 2 ; g.drawTextAsPath (textToDisplay, AffineTransform::rotation (double_Pi / 2.0) .translated (offX, offY)); } else { g.drawText (textToDisplay, 0, 0, width, height, Justification::centred, false); } } // border Colour borderColour; if (selected) borderColour = findColour (GraphComponent::nodeBorderBrightColourId); else borderColour = findColour (GraphComponent::nodeBorderColourId); if (locked) borderColour = borderColour.overlaidWith (Colours::red.withAlpha (0.3f)); g.setColour (borderColour); g.drawRect (0, 0, width, height, 2); }
void preenfmLookAndFeel::drawTabButton (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown) { const Rectangle<int> activeArea (button.getActiveArea()); const TabbedButtonBar::Orientation o = button.getTabbedButtonBar().getOrientation(); const Colour bkg (button.getTabBackgroundColour()); if (button.getToggleState()) { g.setColour (bkg); } else { Point<int> p1, p2; switch (o) { case TabbedButtonBar::TabsAtBottom: p1 = activeArea.getBottomLeft(); p2 = activeArea.getTopLeft(); break; case TabbedButtonBar::TabsAtTop: p1 = activeArea.getTopLeft(); p2 = activeArea.getBottomLeft(); break; case TabbedButtonBar::TabsAtRight: p1 = activeArea.getTopRight(); p2 = activeArea.getTopLeft(); break; case TabbedButtonBar::TabsAtLeft: p1 = activeArea.getTopLeft(); p2 = activeArea.getTopRight(); break; default: jassertfalse; break; } g.setGradientFill (ColourGradient (bkg.brighter (0.2f), (float) p1.x, (float) p1.y, bkg.darker (0.1f), (float) p2.x, (float) p2.y, false)); } g.fillRect (activeArea); g.setColour (button.findColour (TabbedButtonBar::tabOutlineColourId)); Rectangle<int> r (activeArea); if (o != TabbedButtonBar::TabsAtBottom) g.fillRect (r.removeFromTop (1)); if (o != TabbedButtonBar::TabsAtTop) g.fillRect (r.removeFromBottom (1)); if (o != TabbedButtonBar::TabsAtRight) g.fillRect (r.removeFromLeft (1)); if (o != TabbedButtonBar::TabsAtLeft) g.fillRect (r.removeFromRight (1)); const float alpha = button.isEnabled() ? ((isMouseOver || isMouseDown) ? 1.0f : 0.8f) : 0.3f; Colour col (bkg.contrasting().withMultipliedAlpha (alpha)); if (TabbedButtonBar* bar = button.findParentComponentOfClass<TabbedButtonBar>()) { TabbedButtonBar::ColourIds colID = button.isFrontTab() ? TabbedButtonBar::frontTextColourId : TabbedButtonBar::tabTextColourId; if (bar->isColourSpecified (colID)) col = bar->findColour (colID); else if (isColourSpecified (colID)) col = findColour (colID); } const Rectangle<float> area (button.getTextArea().toFloat()); float length = area.getWidth(); float depth = area.getHeight(); if (button.getTabbedButtonBar().isVertical()) std::swap (length, depth); g.setColour (col); g.setFont (Font (depth * .5)); g.drawFittedText (button.getName().trim(), 0, 0,length, depth, Justification::centred, 1); }
void mlrVSTGUI::buildSliders(int &xPosition, int &yPosition) { // work out the correct height width const int sliderWidth = (int)(270 / (float) (numChannels + 1)); const int sliderHeight = 66; // TODO: no magic numbers! // clear any existing sliders slidersArray.clear(); slidersMuteBtnArray.clear(); // Set master volume first addAndMakeVisible(&masterGainSlider); masterGainSlider.setSliderStyle(Slider::LinearVertical); masterGainSlider.setRange(0.0, 1.0, 0.01); masterGainSlider.setValue(0.0, NotificationType::dontSendNotification); masterGainSlider.setBounds(xPosition, yPosition, sliderWidth, sliderHeight); masterGainSlider.setTextBoxStyle(Slider::NoTextBox, true, 0, 0); masterGainSlider.setColour(Slider::thumbColourId, Colours::darkgrey); masterGainSlider.setColour(Slider::backgroundColourId, (Colours::darkgrey).darker()); // and its label addAndMakeVisible(&masterSliderLabel); masterSliderLabel.setBounds(xPosition, yPosition + sliderHeight, sliderWidth, 16); masterSliderLabel.setColour(Label::backgroundColourId, Colours::black); masterSliderLabel.setColour(Label::textColourId, Colours::white); masterSliderLabel.setFont(defaultFont); xPosition += 1; // then individual channel volumes for(int i = 0; i < numChannels; ++i) { xPosition += sliderWidth; slidersArray.add(new Slider("channel " + String(i) + " vol")); addAndMakeVisible(slidersArray[i]); slidersArray[i]->setSliderStyle(Slider::LinearVertical); slidersArray[i]->addListener(this); slidersArray[i]->setRange(0.0, 1.0, 0.01); slidersArray[i]->setBounds(xPosition, yPosition, sliderWidth - 1, sliderHeight); slidersArray[i]->setValue(parent->getChannelGain(i)); Colour sliderColour = parent->getChannelColour(i); slidersArray[i]->setTextBoxStyle(Slider::NoTextBox, true, 0, 0); slidersArray[i]->setColour(Slider::thumbColourId, sliderColour); slidersArray[i]->setColour(Slider::backgroundColourId, sliderColour.darker()); // add the labels slidersMuteBtnArray.add(new ToggleButton("ch" + String(i))); addAndMakeVisible(slidersMuteBtnArray[i]); slidersMuteBtnArray[i]->setBounds(xPosition, yPosition + sliderHeight, sliderWidth - 1, 16); slidersMuteBtnArray[i]->setColour(Label::backgroundColourId, Colours::black); slidersMuteBtnArray[i]->setColour(Label::textColourId, Colours::white); slidersMuteBtnArray[i]->addListener(this); slidersMuteBtnArray[i]->setToggleState(parent->getChannelMuteStatus(i), NotificationType::dontSendNotification); } // increment yPosition for the next GUI item xPosition = PAD_AMOUNT; yPosition += sliderHeight + 3 * PAD_AMOUNT; }
//============================================================================== void NonShinyLookAndFeel::drawGlassLozenge (Graphics& g, const float x, const float y, const float width, const float height, const Colour& colour, const float outlineThickness, const float cornerSize, const bool flatOnLeft, const bool flatOnRight, const bool flatOnTop, const bool flatOnBottom) throw() { if (width <= outlineThickness || height <= outlineThickness) return; const int intX = (int) x; const int intY = (int) y; const int intW = (int) width; const int intH = (int) height; const float cs = cornerSize < 0 ? jmin (width * 0.5f, height * 0.5f) : cornerSize; const float edgeBlurRadius = height * 0.75f + (height - cs * 2.0f); const int intEdge = (int) edgeBlurRadius; Path outline; createRoundedPath (outline, x, y, width, height, cs, ! (flatOnLeft || flatOnTop), ! (flatOnRight || flatOnTop), ! (flatOnLeft || flatOnBottom), ! (flatOnRight || flatOnBottom)); { ColourGradient cg (colour.darker (0.1f), 0, y, colour.darker (0.1f), 0, y + height, false); cg.addColour (0.03, colour.withMultipliedAlpha (0.3f)); cg.addColour (0.4, colour); cg.addColour (0.97, colour.withMultipliedAlpha (0.3f)); //g.setGradientFill (cg); g.setColour(colour); g.fillPath (outline); } //ColourGradient cg (Colours::transparentBlack, x + edgeBlurRadius, y + height * 0.5f, // colour.darker (0.1f), x, y + height * 0.5f, true); //cg.addColour (jlimit (0.0, 1.0, 1.0 - (cs * 0.5f) / edgeBlurRadius), Colours::transparentBlack); //cg.addColour (jlimit (0.0, 1.0, 1.0 - (cs * 0.25f) / edgeBlurRadius), colour.darker (0.2f).withMultipliedAlpha (0.3f)); if (! (flatOnLeft || flatOnTop || flatOnBottom)) { g.saveState(); // g.setGradientFill (cg); g.setColour(colour); g.reduceClipRegion (intX, intY, intEdge, intH); g.fillPath (outline); g.restoreState(); } if (! (flatOnRight || flatOnTop || flatOnBottom)) { //cg.point1.setX (x + width - edgeBlurRadius); //cg.point2.setX (x + width); g.saveState(); //g.setGradientFill (cg); g.setColour(colour); g.reduceClipRegion (intX + intW - intEdge, intY, 2 + intEdge, intH); g.fillPath (outline); g.restoreState(); } //{ // const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f; // const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f; // Path highlight; // createRoundedPath (highlight, // x + leftIndent, // y + cs * 0.1f, // width - (leftIndent + rightIndent), // height * 0.4f, cs * 0.4f, // ! (flatOnLeft || flatOnTop), // ! (flatOnRight || flatOnTop), // ! (flatOnLeft || flatOnBottom), // ! (flatOnRight || flatOnBottom)); // g.setGradientFill (ColourGradient (colour.brighter (10.0f), 0, y + height * 0.06f, // Colours::transparentWhite, 0, y + height * 0.4f, false)); // g.fillPath (highlight); //} g.setColour (colour.darker(10.f).withMultipliedAlpha (1.5f)); g.strokePath (outline, PathStrokeType (outlineThickness)); }
void NewLookAndFeel::drawGlassLozenge (Graphics& g, const float x, const float y, const float width, const float height, const Colour& colour, const float outlineThickness, const float cornerSize, const bool flatOnLeft, const bool flatOnRight, const bool flatOnTop, const bool flatOnBottom, const bool isMouseOverButton, const bool isButtonDown) throw() { if (width <= outlineThickness || height <= outlineThickness) return; const float cs = cornerSize < 0 ? jmin (width * 0.5f, height * 0.5f) : cornerSize; Path outline; createRoundedPath (outline, x, y, width, height, cs, ! (flatOnLeft || flatOnTop), ! (flatOnRight || flatOnTop), ! (flatOnLeft || flatOnBottom), ! (flatOnRight || flatOnBottom)); { ColourGradient cg; if (isButtonDown) { cg = ColourGradient(colour, 0, y, colour.darker (0.1f), 0, y + height, false); } else { cg = ColourGradient(colour.darker(0.1f), 0, y, colour, 0, y + height, false); } g.setGradientFill (cg); g.fillPath (outline); } { const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f; const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f; Path highlight; createRoundedPath (highlight, x + leftIndent, y + cs * 0.1f, width - (leftIndent + rightIndent), height * 0.2f, cs * 0.2f, ! (flatOnLeft || flatOnTop), ! (flatOnRight || flatOnTop), ! (flatOnLeft || flatOnBottom), ! (flatOnRight || flatOnBottom)); if (!isButtonDown) { g.setGradientFill (ColourGradient (colour.brighter (2.0f), 0, y + height * 0.06f, Colours::transparentWhite, 0, y + height * 0.2f, false)); } else { g.setGradientFill (ColourGradient (colour.darker (0.3f), 0, y + height * 0.06f, Colours::transparentBlack, 0, y + height * 0.2f, false)); } g.fillPath (highlight); } { const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f; const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f; Path shadow; createRoundedPath (shadow, x + leftIndent, y + height * 0.85f + cs * 0.1f, width - (leftIndent + rightIndent), height * 0.2f, cs * 0.2f, ! (flatOnLeft || flatOnTop), ! (flatOnRight || flatOnTop), ! (flatOnLeft || flatOnBottom), ! (flatOnRight || flatOnBottom)); if (!isButtonDown) { g.setGradientFill (ColourGradient (Colours::transparentWhite, 0, y + height * 0.85f, colour.darker (0.4f), 0, y + height, false)); } g.fillPath (shadow); } g.setColour(Colour::fromRGBA(0, 0, 0, 150)); g.strokePath (outline, PathStrokeType (outlineThickness)); }
void CtrlrLuaMethodEditorTabsLF::drawTabButton (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown) { const Rectangle<int> activeArea (button.getActiveArea()); const TabbedButtonBar::Orientation o = button.getTabbedButtonBar().getOrientation(); const Colour bkg (button.getTabBackgroundColour()); if (button.getToggleState()) { g.setColour (bkg); } else { Point<int> p1, p2; switch (o) { case TabbedButtonBar::TabsAtBottom: p1 = activeArea.getBottomLeft(); p2 = activeArea.getTopLeft(); break; case TabbedButtonBar::TabsAtTop: p1 = activeArea.getTopLeft(); p2 = activeArea.getBottomLeft(); break; case TabbedButtonBar::TabsAtRight: p1 = activeArea.getTopRight(); p2 = activeArea.getTopLeft(); break; case TabbedButtonBar::TabsAtLeft: p1 = activeArea.getTopLeft(); p2 = activeArea.getTopRight(); break; default: jassertfalse; break; } g.setGradientFill (ColourGradient (bkg.brighter (0.2f), (float) p1.x, (float) p1.y, bkg.darker (0.1f), (float) p2.x, (float) p2.y, false)); } g.fillRect (activeArea); g.setColour (button.findColour (TabbedButtonBar::tabOutlineColourId)); Rectangle<int> r (activeArea); if (o != TabbedButtonBar::TabsAtBottom) g.fillRect (r.removeFromTop (1)); if (o != TabbedButtonBar::TabsAtTop) g.fillRect (r.removeFromBottom (1)); if (o != TabbedButtonBar::TabsAtRight) g.fillRect (r.removeFromLeft (1)); if (o != TabbedButtonBar::TabsAtLeft) g.fillRect (r.removeFromRight (1)); const float alpha = button.isEnabled() ? ((isMouseOver || isMouseDown) ? 1.0f : 0.8f) : 0.3f; Colour col (bkg.contrasting().withMultipliedAlpha (alpha)); if (TabbedButtonBar* bar = button.findParentComponentOfClass<TabbedButtonBar>()) { TabbedButtonBar::ColourIds colID = button.isFrontTab() ? TabbedButtonBar::frontTextColourId : TabbedButtonBar::tabTextColourId; if (bar->isColourSpecified (colID)) col = bar->findColour (colID); else if (isColourSpecified (colID)) col = findColour (colID); } const Rectangle<float> area (button.getTextArea().toFloat()); float length = area.getWidth(); float depth = area.getHeight(); if (button.getTabbedButtonBar().isVertical()) std::swap (length, depth); TextLayout textLayout; createTabTextLayout (button, length, depth, col, textLayout); AffineTransform t; switch (o) { case TabbedButtonBar::TabsAtLeft: t = t.rotated (float_Pi * -0.5f).translated (area.getX(), area.getBottom()); break; case TabbedButtonBar::TabsAtRight: t = t.rotated (float_Pi * 0.5f).translated (area.getRight(), area.getY()); break; case TabbedButtonBar::TabsAtTop: case TabbedButtonBar::TabsAtBottom: t = t.translated (area.getX(), area.getY()); break; default: jassertfalse; break; } g.addTransform (t); textLayout.draw (g, Rectangle<float> (length, depth)); }