Scroom  0.14
cairo-helpers.hh File Reference
#include <list>
#include <gdk/gdk.h>
#include <cairo.h>
#include <scroom/color.hh>
#include <scroom/rectangle.hh>
Include dependency graph for cairo-helpers.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 Colors
 

Functions

void traceRectangleContour (cairo_t *cr, Scroom::Utils::Rectangle< double > const &viewArea)
 
void drawRectangleContour (cairo_t *cr, Scroom::Utils::Rectangle< double > const &viewArea)
 
void drawRectangleContour (cairo_t *cr, Color const &c, Scroom::Utils::Rectangle< double > const &viewArea)
 
void setClip (cairo_t *cr, double x, double y, double width, double height)
 
void setClip (cairo_t *cr, const Scroom::Utils::Rectangle< double > &area)
 
void drawRectangle (cairo_t *cr, Color const &c, Scroom::Utils::Rectangle< double > const &viewArea)
 
void drawOutOfBoundsWithBackground (cairo_t *cr, Scroom::Utils::Rectangle< double > const &requestedPresentationArea, Scroom::Utils::Rectangle< double > const &actualPresentationArea, double pixelSize)
 
void drawOutOfBoundsWithBackgroundColor (cairo_t *cr, const Color &background, Scroom::Utils::Rectangle< double > const &requestedPresentationArea, Scroom::Utils::Rectangle< double > const &actualPresentationArea, double pixelSize)
 
void drawOutOfBoundsWithoutBackground (cairo_t *cr, Scroom::Utils::Rectangle< double > const &requestedPresentationArea, Scroom::Utils::Rectangle< double > const &actualPresentationArea, double pixelSize)
 
double pixelSizeFromZoom (int zoom)
 

Variables

const Color Colors::OUT_OF_BOUNDS
 

Function Documentation

◆ drawOutOfBoundsWithBackground()

void drawOutOfBoundsWithBackground ( cairo_t *  cr,
Scroom::Utils::Rectangle< double > const &  requestedPresentationArea,
Scroom::Utils::Rectangle< double > const &  actualPresentationArea,
double  pixelSize 
)
78 {
79  drawRectangle(cr, Colors::OUT_OF_BOUNDS, pixelSize * (requestedPresentationArea.moveTo(0, 0)));
80  drawRectangle(cr, Colors::IN_BOUNDS, pixelSize * (actualPresentationArea - requestedPresentationArea.getTopLeft()));
81 }

Referenced by ExamplePresentation::redraw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawOutOfBoundsWithBackgroundColor()

void drawOutOfBoundsWithBackgroundColor ( cairo_t *  cr,
const Color background,
Scroom::Utils::Rectangle< double > const &  requestedPresentationArea,
Scroom::Utils::Rectangle< double > const &  actualPresentationArea,
double  pixelSize 
)
88 {
89  drawOutOfBoundsWithoutBackground(cr, requestedPresentationArea, actualPresentationArea, pixelSize);
90  drawRectangle(cr, background, pixelSize * (actualPresentationArea - requestedPresentationArea.getTopLeft()));
91 }
Here is the call graph for this function:

◆ drawOutOfBoundsWithoutBackground()

void drawOutOfBoundsWithoutBackground ( cairo_t *  cr,
Scroom::Utils::Rectangle< double > const &  requestedPresentationArea,
Scroom::Utils::Rectangle< double > const &  actualPresentationArea,
double  pixelSize 
)
97 {
98  std::list<Rectangle<double>> const border =
99  boost::assign::list_of(requestedPresentationArea.leftOf(actualPresentationArea.getLeft()))(requestedPresentationArea.rightOf(
100  actualPresentationArea.getRight()))(requestedPresentationArea.above(actualPresentationArea.getTop()))(
101  requestedPresentationArea.below(actualPresentationArea.getBottom()));
102 
103  for(const Rectangle<double>& r: border)
104  {
105  if(!r.isEmpty())
106  {
107  drawRectangle(cr, Colors::OUT_OF_BOUNDS, pixelSize * (r - requestedPresentationArea.getTopLeft()));
108  }
109  }
110 }

Referenced by drawOutOfBoundsWithBackgroundColor(), and anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::redraw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawRectangle()

void drawRectangle ( cairo_t *  cr,
Color const &  c,
Scroom::Utils::Rectangle< double > const &  viewArea 
)
63 {
64  cairo_save(cr);
65 
66  c.setColor(cr);
67  setClip(cr, viewArea);
68 
69  cairo_paint(cr);
70 
71  cairo_restore(cr);
72 }

Referenced by drawOutOfBoundsWithBackground(), drawOutOfBoundsWithBackgroundColor(), drawOutOfBoundsWithoutBackground(), and CommonOperations::drawState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawRectangleContour() [1/2]

void drawRectangleContour ( cairo_t *  cr,
Color const &  c,
Scroom::Utils::Rectangle< double > const &  viewArea 
)
38 {
39  cairo_save(cr);
40 
41  c.setColor(cr);
42  drawRectangleContour(cr, viewArea);
43 
44  cairo_restore(cr);
45 }
Here is the call graph for this function:

◆ drawRectangleContour() [2/2]

void drawRectangleContour ( cairo_t *  cr,
Scroom::Utils::Rectangle< double > const &  viewArea 
)
32 {
33  traceRectangleContour(cr, viewArea);
34  cairo_stroke(cr);
35 }

Referenced by drawRectangleContour(), and TiledBitmap::drawTile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pixelSizeFromZoom()

◆ setClip() [1/2]

void setClip ( cairo_t *  cr,
const Scroom::Utils::Rectangle< double > &  area 
)
58 {
59  setClip(cr, area.getLeft(), area.getTop(), area.getWidth(), area.getHeight());
60 }
Here is the call graph for this function:

◆ setClip() [2/2]

void setClip ( cairo_t *  cr,
double  x,
double  y,
double  width,
double  height 
)
48 {
49  cairo_move_to(cr, x, y);
50  cairo_line_to(cr, x + width, y);
51  cairo_line_to(cr, x + width, y + height);
52  cairo_line_to(cr, x, y + height);
53  cairo_line_to(cr, x, y);
54  cairo_clip(cr);
55 }

Referenced by CommonOperations::draw(), drawRectangle(), and setClip().

Here is the caller graph for this function:

◆ traceRectangleContour()

void traceRectangleContour ( cairo_t *  cr,
Scroom::Utils::Rectangle< double > const &  viewArea 
)
23 {
24  cairo_move_to(cr, viewArea.x(), viewArea.y());
25  cairo_line_to(cr, viewArea.x() + viewArea.width(), viewArea.y());
26  cairo_line_to(cr, viewArea.x() + viewArea.width(), viewArea.y() + viewArea.height());
27  cairo_line_to(cr, viewArea.x(), viewArea.y() + viewArea.height());
28  cairo_line_to(cr, viewArea.x(), viewArea.y());
29 }

Referenced by drawRectangleContour().

Here is the call graph for this function:
Here is the caller graph for this function:
Colors::OUT_OF_BOUNDS
const Color OUT_OF_BOUNDS
Scroom::Utils::Rectangle::getTopLeft
xy_type getTopLeft() const
Definition: rectangle.hh:133
Scroom::Utils::Rectangle::x
value_type x() const
Definition: rectangle.hh:125
Scroom::Utils::Rectangle::rightOf
Rectangle< value_type > rightOf(value_type v) const
Definition: rectangle.hh:148
Scroom::Utils::Rectangle::width
value_type width() const
Definition: rectangle.hh:129
drawOutOfBoundsWithoutBackground
void drawOutOfBoundsWithoutBackground(cairo_t *cr, Rectangle< double > const &requestedPresentationArea, Rectangle< double > const &actualPresentationArea, double pixelSize)
Definition: cairo-helpers.cc:93
drawRectangleContour
void drawRectangleContour(cairo_t *cr, Rectangle< double > const &viewArea)
Definition: cairo-helpers.cc:31
Scroom::Utils::Rectangle::getBottom
value_type getBottom() const
Definition: rectangle.hh:112
Scroom::Utils::Rectangle::getHeight
value_type getHeight() const
Definition: rectangle.hh:123
Colors::IN_BOUNDS
const Color IN_BOUNDS(1, 1, 1)
drawRectangle
void drawRectangle(cairo_t *cr, Color const &c, Rectangle< double > const &viewArea)
Definition: cairo-helpers.cc:62
Scroom::Utils::Rectangle::moveTo
Rectangle moveTo(xy_type const &other) const
Definition: rectangle.hh:67
Scroom::Utils::Rectangle::below
Rectangle< value_type > below(value_type v) const
Definition: rectangle.hh:158
Scroom::Utils::Rectangle::getWidth
value_type getWidth() const
Definition: rectangle.hh:121
Scroom::Utils::Rectangle::getRight
value_type getRight() const
Definition: rectangle.hh:114
Scroom::Utils::Rectangle::getLeft
value_type getLeft() const
Definition: rectangle.hh:110
Scroom::Utils::Rectangle::height
value_type height() const
Definition: rectangle.hh:131
Scroom::Utils::Rectangle::above
Rectangle< value_type > above(value_type v) const
Definition: rectangle.hh:153
traceRectangleContour
void traceRectangleContour(cairo_t *cr, Rectangle< double > const &viewArea)
Definition: cairo-helpers.cc:22
setClip
void setClip(cairo_t *cr, double x, double y, double width, double height)
Definition: cairo-helpers.cc:47
Scroom::Utils::Rectangle::y
value_type y() const
Definition: rectangle.hh:127
Scroom::Utils::Rectangle
Definition: rectangle.hh:22
Scroom::Utils::Rectangle::getTop
value_type getTop() const
Definition: rectangle.hh:108
Scroom::Utils::Rectangle::leftOf
Rectangle< value_type > leftOf(value_type v) const
Definition: rectangle.hh:143