//============================================================================== 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 MiscPreferences::paintListBoxItem(int rowNumber, Graphics &g, int width, int height, bool rowIsSelected) { if(rowIsSelected) { Colour tempCol = backgroundColour.contrasting(); if(tempCol.brighter(0.5f) == Colours::white) tempCol = backgroundColour; g.setColour(tempCol.withAlpha(0.2f)); g.fillRect(0, 0, width, 25); } Font *f = fonts[rowNumber]; if(f != 0) { f->setHeight(height * 0.7f); f->setBold(false); f->setItalic(false); g.setFont(*f); g.setColour(Colours::black); g.drawText(f->getTypefaceName(), 4, 0, (width-4), height, Justification::centredLeft, true); } }
void MidiKeyboardComponent::drawBlackNote (int /*midiNoteNumber*/, Graphics& g, int x, int y, int w, int h, bool isDown, bool isOver, const Colour& noteFillColour) { Colour c (noteFillColour); if (isDown) c = c.overlaidWith (findColour (keyDownOverlayColourId)); if (isOver) c = c.overlaidWith (findColour (mouseOverKeyOverlayColourId)); g.setColour (c); g.fillRect (x, y, w, h); if (isDown) { g.setColour (noteFillColour); g.drawRect (x, y, w, h); } else { const int xIndent = jmax (1, jmin (w, h) / 8); g.setColour (c.brighter()); if (orientation == horizontalKeyboard) g.fillRect (x + xIndent, y, w - xIndent * 2, 7 * h / 8); else if (orientation == verticalKeyboardFacingLeft) g.fillRect (x + w / 8, y + xIndent, w - w / 8, h - xIndent * 2); else if (orientation == verticalKeyboardFacingRight) g.fillRect (x, y + xIndent, 7 * w / 8, h - xIndent * 2); } }
//------------------------------------------------------------------------------ void StartupPreferences::paintListBoxItem(int rowNumber, Graphics &g, int width, int height, bool rowIsSelected) { String tempstr; if(rowIsSelected) { Colour tempCol = backgroundColour.contrasting(); if(tempCol.brighter(0.5f) == Colours::white) tempCol = backgroundColour; g.setColour(tempCol.withAlpha(0.2f)); g.fillRect(0, 0, width, 25); } g.setColour(Colours::black); g.drawText(startup[rowNumber]->name, 5, 0, (width-10), 18, Justification::left, true); }
//------------------------------------------------------------------------------ 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 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 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 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 UploadWindow::paint(Graphics& g) { g.fillAll(Colours::black); Colour border = Colours::wheat; juce::Rectangle<int> rc(0, 0, getWidth(), getHeight()); for (int i = 0; i < 4; i++) { g.setColour(i == 0 ? Colours::black : border); g.drawRect(rc.getX(), rc.getY(), rc.getWidth(), rc.getHeight()); rc.reduce(1, 1); border = border.brighter(0.4f); } ColourGradient gf(Colours::red, 0, getHeight()/2.0f, Colours::darkred, float(getWidth()), getHeight()/2.0f, false); FillType ft(gf); int cx = getWidth() / 2; int cy = getHeight() / 2; const float r = 12.0f; for (int i = 3; i >= 0; i--) { if (i % 2 != 0) g.setFillType(ft); else g.setColour(Colours::white); g.fillEllipse(cx - (r * i), cy - (r * i), (r * i) * 2, (r * i) * 2); } g.setFillType(Colours::transparentWhite); if (smugMug.isUploading()) { int64 n = smugMug.getTotalbytesUploaded(); int64 d = smugMug.getTotalBytesToUpload(); double percent = (d == 0) ? 0 : (double(n)/double(d)*100); GlyphArrangement glyphs; glyphs.addLineOfText(Font(25.0f, Font::bold), String(percent, 1) + ("%"), 0, 0); Path p; glyphs.createPath(p); juce::Rectangle<float> bounds = p.getBounds(); float cx = getWidth() / 2.0f - bounds.getWidth() / 2.0f - bounds.getX(); float cy = getHeight() / 2.0f - bounds.getHeight() / 2.0f - bounds.getY(); AffineTransform trans = AffineTransform::translation(cx, cy); g.setColour(Colours::black); g.fillPath(p, trans); g.setColour(Colours::white); g.strokePath(p, PathStrokeType(1), trans); } }
//============================================================================== 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 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 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 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)); }
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 }
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 drawRoundThumb (Graphics& g, const float x, const float y, const float diameter, const Colour& colour, float outlineThickness) { const Rectangle<float> a (x, y, diameter, diameter); const float halfThickness = outlineThickness * 0.5f; Path p; p.addEllipse (x + halfThickness, y + halfThickness, diameter - outlineThickness, diameter - outlineThickness); const DropShadow ds (Colours::black, 1, Point<int> (0, 0)); ds.drawForPath (g, p); g.setColour (colour); g.fillPath (p); g.setColour (colour.brighter()); g.strokePath (p, PathStrokeType (outlineThickness)); }
void MainContentComponent::sliderValueChanged(Slider* slider) { if (&brightnessSlider == slider) { if (origImage.isValid() && procImage.isValid()) { const float amount = (float)brightnessSlider.getValue(); float pixchange; if (amount == 0.f) { procImage = origImage.createCopy(); imageComponent.setImage(procImage); } else { pixchange = (amount>0)?amount:(-amount); for (int v=0; v<origImage.getHeight(); ++v) { for (int h=0; h<origImage.getWidth(); ++h) { Logger* log = Logger::getCurrentLogger(); log->writeToLog(String(amount)); Colour col = origImage.getPixelAt(h, v); procImage.setPixelAt(h, v, col.brighter(amount)); } } } imageComponent.repaint(); } } }
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 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); }
const AttributedString CtrlrLuaMethodEditor::getDisplayString(const ValueTree &item) const { AttributedString str; if (item.getType () == Ids::luaMethod) { Colour text; if ((bool)item.getProperty(Ids::luaMethodValid) == false) text = Colours::red; else text = Colours::black; str.append (item.getProperty(Ids::luaMethodName).toString()+"\n", Font(12.0f, Font::plain), text); if ((int)item.getProperty(Ids::luaMethodSource) == CtrlrLuaMethod::codeInFile) { str.append (File::descriptionOfSizeInBytes (File(item.getProperty(Ids::luaMethodSourcePath).toString()).getSize()), Font(10.0f, Font::italic), text.brighter(0.2f)); } else { str.append (File::descriptionOfSizeInBytes (item.getProperty(Ids::luaMethodCode).toString().length()), Font(10.0f, Font::italic), text.brighter(0.2f)); } str.setJustification (Justification::left); } if (item.getType() == Ids::luaMethodGroup) { str.append (item.getProperty(Ids::name), Font(14.0f, Font::plain), Colours::black); str.append (" ["+String(item.getNumChildren())+"]", Font(10.0f, Font::italic), Colours::darkgrey); str.setJustification (Justification::left); } if (item.getType() == Ids::luaManagerMethods) { str.append ("LUA", Font(14.0f, Font::bold), Colours::black); str.setJustification (Justification::left); } return (str); }
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)); }
//============================================================================== 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); }