void drawMouseOverCorners (Graphics& g, int w, int h) { RectangleList r (Rectangle<int> (0, 0, w, h)); r.subtract (Rectangle<int> (1, 1, w - 2, h - 2)); const int size = jmin (w / 3, h / 3, 12); r.subtract (Rectangle<int> (size, 0, w - size - size, h)); r.subtract (Rectangle<int> (0, size, w, h - size - size)); g.setColour (Colours::darkgrey); for (int i = r.getNumRectangles(); --i >= 0;) g.fillRect (r.getRectangle (i)); }
void paintComponent() { // you mustn't set your own cached image object when attaching a GL context! jassert (get (component) == this); updateViewportSize (false); if (! ensureFrameBufferSize()) return; RectangleList invalid (viewportArea); invalid.subtract (validArea); validArea = viewportArea; if (! invalid.isEmpty()) { clearRegionInFrameBuffer (invalid, (float) scale); { ScopedPointer<LowLevelGraphicsContext> g (createOpenGLGraphicsContext (context, cachedImageFrameBuffer)); g->addTransform (AffineTransform::scale ((float) scale)); g->clipToRectangleList (invalid); paintOwner (*g); JUCE_CHECK_OPENGL_ERROR } if (! context.isActive()) context.makeActive(); }
//============================================================================== void RectangleList::add (const Rectangle<int>& rect) { if (! rect.isEmpty()) { if (rects.size() == 0) { rects.add (rect); } else { bool anyOverlaps = false; int i; for (i = rects.size(); --i >= 0;) { Rectangle<int>& ourRect = rects.getReference (i); if (rect.intersects (ourRect)) { if (rect.contains (ourRect)) rects.remove (i); else if (! ourRect.reduceIfPartlyContainedIn (rect)) anyOverlaps = true; } } if (anyOverlaps && rects.size() > 0) { RectangleList r (rect); for (i = rects.size(); --i >= 0;) { const Rectangle<int>& ourRect = rects.getReference (i); if (rect.intersects (ourRect)) { r.subtract (ourRect); if (r.rects.size() == 0) return; } } for (i = r.getNumRectangles(); --i >= 0;) rects.add (r.rects.getReference (i)); } else { rects.add (rect); } } } }
void TabbedComponent::paint (Graphics& g) { g.fillAll (findColour (backgroundColourId)); Rectangle<int> content (getLocalBounds()); BorderSize<int> outline (outlineThickness); TabbedComponentHelpers::getTabArea (content, outline, getOrientation(), tabDepth); g.reduceClipRegion (content); g.fillAll (tabs->getTabBackgroundColour (getCurrentTabIndex())); if (outlineThickness > 0) { RectangleList rl (content); rl.subtract (outline.subtractedFrom (content)); g.reduceClipRegion (rl); g.fillAll (findColour (outlineColourId)); } }
void drawCurrentImage (Graphics& g, Rectangle<int> area) { if (imageNeedsFlipping) { const ScopedLock sl (imageSwapLock); std::swap (loadingImage, activeImage); imageNeedsFlipping = false; } Rectangle<int> centred (RectanglePlacement (RectanglePlacement::centred) .appliedTo (Rectangle<int> (width, height), area)); RectangleList<int> borders (area); borders.subtract (centred); g.setColour (Colours::black); g.fillRectList (borders); g.drawImage (activeImage, centred.getX(), centred.getY(), centred.getWidth(), centred.getHeight(), 0, 0, width, height); }
bool RectangleList::containsRectangle (const Rectangle<int>& rectangleToCheck) const { if (rects.size() > 1) { RectangleList r (rectangleToCheck); for (int i = rects.size(); --i >= 0;) { r.subtract (rects.getReference (i)); if (r.rects.size() == 0) return true; } } else if (rects.size() > 0) { return rects.getReference (0).contains (rectangleToCheck); } return false; }
void paintComponent() { if (needsUpdate) { MessageManagerLock mm (this); if (! mm.lockWasGained()) return; needsUpdate = false; // you mustn't set your own cached image object when attaching a GL context! jassert (get (component) == this); const Rectangle<int> bounds (component.getLocalBounds()); if (! ensureFrameBufferSize (bounds.getWidth(), bounds.getHeight())) return; RectangleList invalid (bounds); invalid.subtract (validArea); validArea = bounds; if (! invalid.isEmpty()) { clearRegionInFrameBuffer (invalid); { ScopedPointer<LowLevelGraphicsContext> g (createOpenGLGraphicsContext (context, cachedImageFrameBuffer)); g->clipToRectangleList (invalid); paintOwner (*g); JUCE_CHECK_OPENGL_ERROR } if (! context.isActive()) context.makeActive(); } JUCE_CHECK_OPENGL_ERROR }
void CtrlrCustomButtonInternal::drawTextBoxText(Graphics &g, const Rectangle<int> &frameRect, const Rectangle<int> &totalAreaToDraw) { RectangleList<int> list; list.add (totalAreaToDraw); list.subtract (frameRect); Rectangle<int> destination = list.getBounds(); const int destinationWidth = (int)owner.getProperty(::Ids::uiImageButtonTextWidth) ? (int)owner.getProperty(::Ids::uiImageButtonTextWidth) : destination.getWidth(); const int destinatioHeight = (int)owner.getProperty(::Ids::uiImageButtonTextHeight) ? (int)owner.getProperty(::Ids::uiImageButtonTextHeight) : destination.getHeight(); destination.setSize (destinationWidth, destinatioHeight); g.setColour (VAR2COLOUR(owner.getProperty(::Ids::uiImageButtonTextColour))); g.setFont (owner.getOwner().getOwnerPanel().getCtrlrManagerOwner().getFontManager().getFontFromString(owner.getProperty(::Ids::uiButtonTextFont))); g.drawFittedText (getButtonText(), destination.getX(), destination.getY(), destination.getWidth(), destination.getHeight(), justificationFromProperty (owner.getProperty(::Ids::uiButtonTextJustification)), 2); }
bool OpenGLComponent::performRender() { const ScopedLock sl (contextLock); #if JUCE_LINUX updateContext(); #endif if (context != nullptr) { if (! makeCurrentRenderingTarget()) return false; if (needToUpdateViewport) { needToUpdateViewport = false; glViewport (0, 0, getWidth(), getHeight()); } renderOpenGL(); if (needToRepaint && (flags & allowSubComponents) != 0) { needToRepaint = false; contextLock.exit(); // (MM must be locked before the context lock) MessageManagerLock mmLock (renderThread); contextLock.enter(); if (! mmLock.lockWasGained()) return false; // you mustn't set your own cached image object for an OpenGLComponent! jassert (dynamic_cast<OpenGLCachedComponentImage*> (getCachedComponentImage()) == cachedImage); const Rectangle<int> bounds (getLocalBounds()); OpenGLFrameBuffer& frameBuffer = cachedImage->getFrameBuffer (bounds.getWidth(), bounds.getHeight()); { RectangleList invalid (bounds); invalid.subtract (cachedImage->validArea); cachedImage->validArea = bounds; if (! invalid.isEmpty()) { jassert (getCurrentContext() != nullptr); { OpenGLGraphicsContext g (*getCurrentContext(), frameBuffer); g.clipToRectangleList (invalid); g.setFill (Colours::transparentBlack); g.fillRect (bounds, true); g.setFill (Colours::black); paintSelf (g); } makeCurrentRenderingTarget(); } } glEnable (GL_TEXTURE_2D); context->extensions.glActiveTexture (GL_TEXTURE0); glBindTexture (GL_TEXTURE_2D, frameBuffer.getTextureID()); context->copyTexture (bounds, Rectangle<int> (bounds.getWidth(), bounds.getHeight())); glBindTexture (GL_TEXTURE_2D, 0); } swapBuffers(); } return true; }