//============================================================================== 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 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 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 preenfmLookAndFeel::drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour, bool isMouseOverButton, bool isButtonDown) { if (!button.isEnabled()) { return; } 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 bool flatOnLeft = button.isConnectedOnLeft(); const bool flatOnRight = button.isConnectedOnRight(); const bool flatOnTop = button.isConnectedOnTop(); const bool flatOnBottom = button.isConnectedOnBottom(); const float width = button.getWidth() - 1.0f; const float height = button.getHeight() - 1.0f; if (width > 0 && height > 0) { const float cornerSize = 4.0f; Path outline; outline.addRoundedRectangle (0.5f, 0.5f, width, height, cornerSize, cornerSize, ! (flatOnLeft || flatOnTop), ! (flatOnRight || flatOnTop), ! (flatOnLeft || flatOnBottom), ! (flatOnRight || flatOnBottom)); const float mainBrightness = baseColour.getBrightness(); const float mainAlpha = baseColour.getFloatAlpha(); g.setColour (baseColour); g.fillPath (outline); g.setColour (Colours::black.withAlpha (0.4f * mainAlpha)); g.strokePath (outline, PathStrokeType (1.0f)); } }
//============================================================================== 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 SoundplaneTouchGraphView::renderTouchBarGraphs() { if (!mpModel) return; if (!isShowing()) return; int viewW = getBackingLayerWidth(); int viewH = getBackingLayerHeight(); const MLSignal& currentTouch = mpModel->getTouchFrame(); const MLSignal& touchHistory = mpModel->getTouchHistory(); const int frames = mpModel->getFloatProperty("max_touches"); if (!frames) return; const Colour c = findColour(MLLookAndFeel::backgroundColor); float p = c.getBrightness(); int margin = viewH / 30; int numSize = margin*2; int left = margin*2 + numSize; int right = viewW - margin; int top = margin; int bottom = viewH - margin; int frameWidth = right - left; int frameOffset = (bottom - top)/frames; int frameHeight = frameOffset - margin; MLRect frameSize(0, 0, frameWidth, frameHeight); MLGL::orthoView(viewW, viewH); for(int j=0; j<frames; ++j) { // draw frames p = 0.9f; glColor4f(p, p, p, 1.0f); MLRect fr = frameSize.translated(Vec2(left, margin + j*frameOffset)); MLGL::fillRect(fr); p = 0.6f; glColor4f(p, p, p, 1.0f); MLGL::strokeRect(fr); // draw touch activity indicators at left glColor4fv(MLGL::getIndicatorColor(j)); MLRect r(0, 0, numSize, numSize); MLRect tr = r.translated(Vec2(margin, margin + j*frameOffset + (frameHeight - numSize)/2)); int age = currentTouch(4, j); if (age > 0) MLGL::fillRect(tr); else MLGL::strokeRect(tr); // draw history MLRange frameXRange(fr.left(), fr.right()); frameXRange.convertTo(MLRange(0, (float)kSoundplaneHistorySize)); MLRange frameYRange(0, 1); frameYRange.convertTo(MLRange(fr.bottom(), fr.top())); glBegin(GL_LINES); for(int i=fr.left() + 1; i<fr.right()-1; ++i) { int time = frameXRange(i); float force = touchHistory(2, j, time); // float d = touchHistory(3, j, time); // int age = touchHistory(4, j, time); float y = frameYRange.convert(force); // float drawY = (age > 0) ? y : 0.; // y = frameYRange.convert(d); // draw line glVertex2f(i, fr.bottom()); glVertex2f(i, y); } glEnd(); } }
// the colors for different MLDial parts are generated algorithmically. void MLMultiSlider::setFillColor (const Colour& c) { float g = c.getFloatGreen(); float b = (1.f - g); // thumb fill setColour(fillColor, c); // bright line setColour(indicatorColor, Colour(c.getHue(), jmax(c.getSaturation() - (b*0.05), 0.), jmin((c.getBrightness() + b*2.f), 1.f), 1.f)); MLLookAndFeel* myLookAndFeel = (&(getRootViewResources(this).mLookAndFeel)); // track background plain setColour(trackEmptyDarkColor, myLookAndFeel->findColour(MLLookAndFeel::darkestFillColor)); // dial fill selected setColour(trackFullLightColor, findColour(fillColor).overlaidWith(findColour(indicatorColor).withAlpha(0.15f))); // track fill setColour(trackFullDarkColor, c.overlaidWith(Colours::black.withAlpha(0.17f)).withMultipliedSaturation(1.5f)); lookAndFeelChanged(); }