openshot-audio  0.1.2
juce_GraphicsContext.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_GRAPHICSCONTEXT_H_INCLUDED
26 #define JUCE_GRAPHICSCONTEXT_H_INCLUDED
27 
28 
29 //==============================================================================
43 {
44 public:
45  //==============================================================================
55  explicit Graphics (const Image& imageToDrawOnto);
56 
58  ~Graphics();
59 
60  //==============================================================================
71  void setColour (Colour newColour);
72 
82  void setOpacity (float newOpacity);
83 
86  void setGradientFill (const ColourGradient& gradient);
87 
92  void setTiledImageFill (const Image& imageToUse,
93  int anchorX, int anchorY,
94  float opacity);
95 
99  void setFillType (const FillType& newFill);
100 
101  //==============================================================================
109  void setFont (const Font& newFont);
110 
116  void setFont (float newFontHeight);
117 
119  Font getCurrentFont() const;
120 
133  void drawSingleLineText (const String& text,
134  int startX, int baselineY,
135  Justification justification = Justification::left) const;
136 
145  void drawMultiLineText (const String& text,
146  int startX, int baselineY,
147  int maximumLineWidth) const;
148 
158  void drawText (const String& text,
159  int x, int y, int width, int height,
160  Justification justificationType,
161  bool useEllipsesIfTooBig = true) const;
162 
172  void drawText (const String& text,
173  const Rectangle<int>& area,
174  Justification justificationType,
175  bool useEllipsesIfTooBig = true) const;
176 
186  void drawText (const String& text,
187  const Rectangle<float>& area,
188  Justification justificationType,
189  bool useEllipsesIfTooBig = true) const;
190 
210  void drawFittedText (const String& text,
211  int x, int y, int width, int height,
212  Justification justificationFlags,
213  int maximumNumberOfLines,
214  float minimumHorizontalScale = 0.0f) const;
215 
235  void drawFittedText (const String& text,
236  const Rectangle<int>& area,
237  Justification justificationFlags,
238  int maximumNumberOfLines,
239  float minimumHorizontalScale = 0.0f) const;
240 
241  //==============================================================================
247  void fillAll() const;
248 
254  void fillAll (Colour colourToUse) const;
255 
256  //==============================================================================
260  void fillRect (const Rectangle<int>& rectangle) const;
261 
265  void fillRect (const Rectangle<float>& rectangle) const;
266 
270  void fillRect (int x, int y, int width, int height) const;
271 
275  void fillRect (float x, float y, float width, float height) const;
276 
282  void fillRectList (const RectangleList<float>& rectangles) const;
283 
289  void fillRectList (const RectangleList<int>& rectangles) const;
290 
294  void fillRoundedRectangle (float x, float y, float width, float height,
295  float cornerSize) const;
296 
300  void fillRoundedRectangle (const Rectangle<float>& rectangle,
301  float cornerSize) const;
302 
304  void fillCheckerBoard (const Rectangle<int>& area,
305  int checkWidth, int checkHeight,
306  Colour colour1, Colour colour2) const;
307 
312  void drawRect (int x, int y, int width, int height, int lineThickness = 1) const;
313 
318  void drawRect (float x, float y, float width, float height, float lineThickness = 1.0f) const;
319 
324  void drawRect (const Rectangle<int>& rectangle, int lineThickness = 1) const;
325 
330  void drawRect (Rectangle<float> rectangle, float lineThickness = 1.0f) const;
331 
335  void drawRoundedRectangle (float x, float y, float width, float height,
336  float cornerSize, float lineThickness) const;
337 
341  void drawRoundedRectangle (const Rectangle<float>& rectangle,
342  float cornerSize, float lineThickness) const;
343 
348  void setPixel (int x, int y) const;
349 
350  //==============================================================================
355  void fillEllipse (float x, float y, float width, float height) const;
356 
361  void fillEllipse (const Rectangle<float>& area) const;
362 
366  void drawEllipse (float x, float y, float width, float height,
367  float lineThickness) const;
368 
372  void drawEllipse (const Rectangle<float>& area, float lineThickness) const;
373 
374  //==============================================================================
380  void drawLine (float startX, float startY, float endX, float endY) const;
381 
387  void drawLine (float startX, float startY, float endX, float endY, float lineThickness) const;
388 
394  void drawLine (const Line<float>& line) const;
395 
401  void drawLine (const Line<float>& line, float lineThickness) const;
402 
414  void drawDashedLine (const Line<float>& line,
415  const float* dashLengths, int numDashLengths,
416  float lineThickness = 1.0f,
417  int dashIndexToStartFrom = 0) const;
418 
426  void drawVerticalLine (int x, float top, float bottom) const;
427 
435  void drawHorizontalLine (int y, float left, float right) const;
436 
437  //==============================================================================
439  void fillPath (const Path& path,
440  const AffineTransform& transform = AffineTransform::identity) const;
441 
443  void strokePath (const Path& path,
444  const PathStrokeType& strokeType,
445  const AffineTransform& transform = AffineTransform::identity) const;
446 
454  void drawArrow (const Line<float>& line,
455  float lineThickness,
456  float arrowheadWidth,
457  float arrowheadLength) const;
458 
459 
460  //==============================================================================
466  {
467  lowResamplingQuality = 0,
468  mediumResamplingQuality = 1,
469  highResamplingQuality = 2
470  };
471 
476  void setImageResamplingQuality (const ResamplingQuality newQuality);
477 
489  void drawImageAt (const Image& imageToDraw, int topLeftX, int topLeftY,
490  bool fillAlphaChannelWithCurrentBrush = false) const;
491 
517  void drawImage (const Image& imageToDraw,
518  int destX, int destY, int destWidth, int destHeight,
519  int sourceX, int sourceY, int sourceWidth, int sourceHeight,
520  bool fillAlphaChannelWithCurrentBrush = false) const;
521 
539  void drawImageTransformed (const Image& imageToDraw,
540  const AffineTransform& transform,
541  bool fillAlphaChannelWithCurrentBrush = false) const;
542 
564  void drawImageWithin (const Image& imageToDraw,
565  int destX, int destY, int destWidth, int destHeight,
566  RectanglePlacement placementWithinTarget,
567  bool fillAlphaChannelWithCurrentBrush = false) const;
568 
569 
570  //==============================================================================
574  Rectangle<int> getClipBounds() const;
575 
582  bool clipRegionIntersects (const Rectangle<int>& area) const;
583 
589  bool reduceClipRegion (int x, int y, int width, int height);
590 
596  bool reduceClipRegion (const Rectangle<int>& area);
597 
603  bool reduceClipRegion (const RectangleList<int>& clipRegion);
604 
610  bool reduceClipRegion (const Path& path, const AffineTransform& transform = AffineTransform::identity);
611 
623  bool reduceClipRegion (const Image& image, const AffineTransform& transform);
624 
626  void excludeClipRegion (const Rectangle<int>& rectangleToExclude);
627 
629  bool isClipEmpty() const;
630 
631  //==============================================================================
636  void saveState();
637 
641  void restoreState();
642 
648  {
649  public:
651  ~ScopedSaveState();
652 
653  private:
654  Graphics& context;
656  };
657 
658  //==============================================================================
669  void beginTransparencyLayer (float layerOpacity);
670 
674  void endTransparencyLayer();
675 
686  void setOrigin (Point<int> newOrigin);
687 
698  void setOrigin (int newOriginX, int newOriginY);
699 
708  void addTransform (const AffineTransform& transform);
709 
711  void resetToDefaultState();
712 
714  bool isVectorDevice() const;
715 
716  //==============================================================================
722 
725 
726 private:
727  //==============================================================================
728  LowLevelGraphicsContext& context;
730 
731  bool saveStatePending;
732  void saveStateIfPending();
733 
735 };
736 
737 
738 #endif // JUCE_GRAPHICSCONTEXT_H_INCLUDED
ResamplingQuality
Definition: juce_GraphicsContext.h:465
Definition: juce_Font.h:39
Definition: juce_GraphicsContext.h:647
Definition: juce_Line.h:44
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_RectangleList.h:40
Definition: juce_Justification.h:38
Definition: juce_Point.h:39
Definition: juce_String.h:43
Definition: juce_ColourGradient.h:35
Definition: juce_PathStrokeType.h:39
#define JUCE_API
Definition: juce_StandardHeader.h:139
static const AffineTransform identity
Definition: juce_AffineTransform.h:78
#define const
Definition: juce_Justification.h:110
Definition: juce_Rectangle.h:36
Definition: juce_RectanglePlacement.h:37
float minimumHorizontalScale
Definition: juce_Font.cpp:33
Definition: juce_Path.h:62
Definition: juce_Colour.h:35
png_const_structrp png_const_inforp int png_fixed_point * width
Definition: juce_PNGLoader.cpp:2339
Definition: juce_FillType.h:38
#define JUCE_DECLARE_NON_COPYABLE(className)
Definition: juce_PlatformDefs.h:191
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_GraphicsContext.h:42
Definition: juce_Image.h:54
Definition: juce_LowLevelGraphicsContext.h:43
LowLevelGraphicsContext & getInternalContext() const noexcept
Definition: juce_GraphicsContext.h:724
Definition: juce_AffineTransform.h:40