| @@ -2270,6 +2270,14 @@ public: | |||||
| renderImage (sourceImage, trans, nullptr); | renderImage (sourceImage, trans, nullptr); | ||||
| } | } | ||||
| static bool isOnlyTranslationAllowingError (const AffineTransform& t) | |||||
| { | |||||
| return (std::abs (t.mat01) < 0.002) | |||||
| && (std::abs (t.mat10) < 0.002) | |||||
| && (std::abs (t.mat00 - 1.0f) < 0.002) | |||||
| && (std::abs (t.mat11 - 1.0f) < 0.002); | |||||
| } | |||||
| void renderImage (const Image& sourceImage, const AffineTransform& trans, | void renderImage (const Image& sourceImage, const AffineTransform& trans, | ||||
| const BaseRegionType* const tiledFillClipRegion) | const BaseRegionType* const tiledFillClipRegion) | ||||
| { | { | ||||
| @@ -2277,7 +2285,7 @@ public: | |||||
| const int alpha = fillType.colour.getAlpha(); | const int alpha = fillType.colour.getAlpha(); | ||||
| if (t.isOnlyTranslation()) | |||||
| if (isOnlyTranslationAllowingError (t)) | |||||
| { | { | ||||
| // If our translation doesn't involve any distortion, just use a simple blit.. | // If our translation doesn't involve any distortion, just use a simple blit.. | ||||
| int tx = (int) (t.getTranslationX() * 256.0f); | int tx = (int) (t.getTranslationX() * 256.0f); | ||||
| @@ -2023,7 +2023,8 @@ void Component::paintEntireComponent (Graphics& g, const bool ignoreAlphaLevel) | |||||
| scaledBounds.getWidth(), scaledBounds.getHeight(), ! flags.opaqueFlag); | scaledBounds.getWidth(), scaledBounds.getHeight(), ! flags.opaqueFlag); | ||||
| { | { | ||||
| Graphics g2 (effectImage); | Graphics g2 (effectImage); | ||||
| g2.addTransform (AffineTransform::scale (scale)); | |||||
| g2.addTransform (AffineTransform::scale (scaledBounds.getWidth() / (float) getWidth(), | |||||
| scaledBounds.getHeight() / (float) getHeight())); | |||||
| paintComponentAndChildren (g2); | paintComponentAndChildren (g2); | ||||
| } | } | ||||
| @@ -2058,7 +2059,7 @@ void Component::setPaintingIsUnclipped (const bool shouldPaintWithoutClipping) n | |||||
| //============================================================================== | //============================================================================== | ||||
| Image Component::createComponentSnapshot (const Rectangle<int>& areaToGrab, | Image Component::createComponentSnapshot (const Rectangle<int>& areaToGrab, | ||||
| const bool clipImageToComponentBounds) | |||||
| bool clipImageToComponentBounds, float scaleFactor) | |||||
| { | { | ||||
| Rectangle<int> r (areaToGrab); | Rectangle<int> r (areaToGrab); | ||||
| @@ -2068,14 +2069,21 @@ Image Component::createComponentSnapshot (const Rectangle<int>& areaToGrab, | |||||
| if (r.isEmpty()) | if (r.isEmpty()) | ||||
| return Image(); | return Image(); | ||||
| Image componentImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, | |||||
| r.getWidth(), r.getHeight(), true); | |||||
| const int w = roundToInt (scaleFactor * r.getWidth()); | |||||
| const int h = roundToInt (scaleFactor * r.getHeight()); | |||||
| Graphics imageContext (componentImage); | |||||
| imageContext.setOrigin (-r.getPosition()); | |||||
| paintEntireComponent (imageContext, true); | |||||
| Image image (flags.opaqueFlag ? Image::RGB : Image::ARGB, w, h, true); | |||||
| return componentImage; | |||||
| Graphics g (image); | |||||
| if (w != getWidth() || h != getHeight()) | |||||
| g.addTransform (AffineTransform::scale (w / (float) r.getWidth(), | |||||
| h / (float) r.getHeight())); | |||||
| g.setOrigin (-r.getPosition()); | |||||
| paintEntireComponent (g, true); | |||||
| return image; | |||||
| } | } | ||||
| void Component::setComponentEffect (ImageEffectFilter* const newEffect) | void Component::setComponentEffect (ImageEffectFilter* const newEffect) | ||||
| @@ -1010,7 +1010,8 @@ public: | |||||
| @see paintEntireComponent | @see paintEntireComponent | ||||
| */ | */ | ||||
| Image createComponentSnapshot (const Rectangle<int>& areaToGrab, | Image createComponentSnapshot (const Rectangle<int>& areaToGrab, | ||||
| bool clipImageToComponentBounds = true); | |||||
| bool clipImageToComponentBounds = true, | |||||
| float scaleFactor = 1.0f); | |||||
| /** Draws this component and all its subcomponents onto the specified graphics | /** Draws this component and all its subcomponents onto the specified graphics | ||||
| context. | context. | ||||
| @@ -136,7 +136,6 @@ public: | |||||
| { | { | ||||
| public: | public: | ||||
| ProxyComponent (Component& c) | ProxyComponent (Component& c) | ||||
| : image (c.createComponentSnapshot (c.getLocalBounds())) | |||||
| { | { | ||||
| setBounds (c.getBounds()); | setBounds (c.getBounds()); | ||||
| setTransform (c.getTransform()); | setTransform (c.getTransform()); | ||||
| @@ -150,6 +149,8 @@ public: | |||||
| else | else | ||||
| jassertfalse; // seem to be trying to animate a component that's not visible.. | jassertfalse; // seem to be trying to animate a component that's not visible.. | ||||
| image = c.createComponentSnapshot (c.getLocalBounds(), false, getDesktopScaleFactor()); | |||||
| setVisible (true); | setVisible (true); | ||||
| toBehind (&c); | toBehind (&c); | ||||
| } | } | ||||
| @@ -556,15 +556,12 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| void drawSelection (Graphics& g, const Range<int> selected) const | |||||
| void addSelection (RectangleList<float>& area, const Range<int> selected) const | |||||
| { | { | ||||
| const int startX = roundToInt (indexToX (selected.getStart())); | |||||
| const int endX = roundToInt (indexToX (selected.getEnd())); | |||||
| const float startX = indexToX (selected.getStart()); | |||||
| const float endX = indexToX (selected.getEnd()); | |||||
| const int y = roundToInt (lineY); | |||||
| const int nextY = roundToInt (lineY + lineHeight); | |||||
| g.fillRect (startX, y, endX - startX, nextY - y); | |||||
| area.add (startX, lineY, endX - startX, lineHeight); | |||||
| } | } | ||||
| void drawUnderline (Graphics& g, const Range<int> underline, const Colour colour) const | void drawUnderline (Graphics& g, const Range<int> underline, const Colour colour) const | ||||
| @@ -1617,20 +1614,23 @@ void TextEditor::drawContent (Graphics& g) | |||||
| if (! selection.isEmpty()) | if (! selection.isEmpty()) | ||||
| { | { | ||||
| g.setColour (findColour (highlightColourId).withMultipliedAlpha (hasKeyboardFocus (true) ? 1.0f : 0.5f)); | |||||
| selectedTextColour = findColour (highlightedTextColourId); | |||||
| Iterator i2 (i); | Iterator i2 (i); | ||||
| RectangleList<float> selectionArea; | |||||
| while (i2.next() && i2.lineY < clip.getBottom()) | while (i2.next() && i2.lineY < clip.getBottom()) | ||||
| { | { | ||||
| if (i2.lineY + i2.lineHeight >= clip.getY() | if (i2.lineY + i2.lineHeight >= clip.getY() | ||||
| && selection.intersects (Range<int> (i2.indexInText, i2.indexInText + i2.atom->numChars))) | && selection.intersects (Range<int> (i2.indexInText, i2.indexInText + i2.atom->numChars))) | ||||
| { | { | ||||
| i2.drawSelection (g, selection); | |||||
| i2.addSelection (selectionArea, selection); | |||||
| } | } | ||||
| } | } | ||||
| g.setColour (findColour (highlightColourId).withMultipliedAlpha (hasKeyboardFocus (true) ? 1.0f : 0.5f)); | |||||
| g.fillRectList (selectionArea); | |||||
| selectedTextColour = findColour (highlightedTextColourId); | |||||
| } | } | ||||
| const UniformTextSection* lastSection = nullptr; | const UniformTextSection* lastSection = nullptr; | ||||
| @@ -83,8 +83,8 @@ public: | |||||
| void getHighlightArea (RectangleList<float>& area, float x, int y, int lineH, float characterWidth) const | void getHighlightArea (RectangleList<float>& area, float x, int y, int lineH, float characterWidth) const | ||||
| { | { | ||||
| if (highlightColumnStart < highlightColumnEnd) | if (highlightColumnStart < highlightColumnEnd) | ||||
| area.addWithoutMerging (Rectangle<float> (x + highlightColumnStart * characterWidth, (float) y, | |||||
| (highlightColumnEnd - highlightColumnStart) * characterWidth, (float) lineH)); | |||||
| area.add (Rectangle<float> (x + highlightColumnStart * characterWidth - 1.0f, y - 0.5f, | |||||
| (highlightColumnEnd - highlightColumnStart) * characterWidth + 1.5f, lineH + 1.0f)); | |||||
| } | } | ||||
| void draw (CodeEditorComponent& owner, Graphics& g, const Font& fontToUse, | void draw (CodeEditorComponent& owner, Graphics& g, const Font& fontToUse, | ||||
| @@ -272,8 +272,8 @@ OpenGLTextureFromImage::OpenGLTextureFromImage (const Image& image) | |||||
| texture->loadImage (image); | texture->loadImage (image); | ||||
| textureID = texture->getTextureID(); | textureID = texture->getTextureID(); | ||||
| fullWidthProportion = imageWidth / (float) texture->getWidth(); | |||||
| fullHeightProportion = imageHeight / (float) texture->getHeight(); | |||||
| fullWidthProportion = (imageWidth - 0.5f) / texture->getWidth(); | |||||
| fullHeightProportion = (imageHeight - 0.5f) / texture->getHeight(); | |||||
| } | } | ||||
| JUCE_CHECK_OPENGL_ERROR | JUCE_CHECK_OPENGL_ERROR | ||||