Scroom 0.14-48-ga0fee447
Loading...
Searching...
No Matches
cairo-helpers.cc File Reference
#include <iostream>
#include <boost/assign/list_of.hpp>
#include <scroom/cairo-helpers.hh>
Include dependency graph for cairo-helpers.cc:

Namespaces

namespace  Colors
 

Functions

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

Variables

const Color Colors::IN_BOUNDS (1, 1, 1)
 

Function Documentation

◆ drawOutOfBoundsWithBackground()

void drawOutOfBoundsWithBackground ( cairo_t *  cr,
Rectangle< double > const &  requestedPresentationArea,
Rectangle< double > const &  actualPresentationArea,
double  pixelSize 
)
80{
81 drawRectangle(cr, Colors::OUT_OF_BOUNDS, pixelSize * (requestedPresentationArea.moveTo(0, 0)));
82 drawRectangle(cr, Colors::IN_BOUNDS, pixelSize * (actualPresentationArea - requestedPresentationArea.getTopLeft()));
83}
void drawRectangle(cairo_t *cr, Color const &c, Rectangle< double > const &viewArea)
Definition cairo-helpers.cc:62
xy_type getTopLeft() const
Definition rectangle.hh:133
Rectangle moveTo(xy_type const &other) const
Definition rectangle.hh:67
const Color OUT_OF_BOUNDS
const Color IN_BOUNDS(1, 1, 1)
cairo_t * cr
Definition transformpresentation_test.cc:72

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,
Rectangle< double > const &  requestedPresentationArea,
Rectangle< double > const &  actualPresentationArea,
double  pixelSize 
)
92{
93 drawOutOfBoundsWithoutBackground(cr, requestedPresentationArea, actualPresentationArea, pixelSize);
94 drawRectangle(cr, background, pixelSize * (actualPresentationArea - requestedPresentationArea.getTopLeft()));
95}
void drawOutOfBoundsWithoutBackground(cairo_t *cr, Rectangle< double > const &requestedPresentationArea, Rectangle< double > const &actualPresentationArea, double pixelSize)
Definition cairo-helpers.cc:97
Here is the call graph for this function:

◆ drawOutOfBoundsWithoutBackground()

void drawOutOfBoundsWithoutBackground ( cairo_t *  cr,
Rectangle< double > const &  requestedPresentationArea,
Rectangle< double > const &  actualPresentationArea,
double  pixelSize 
)
103{
104 std::list<Rectangle<double>> const border =
105 boost::assign::list_of(requestedPresentationArea
106 .leftOf(actualPresentationArea.getLeft()))(requestedPresentationArea
107 .rightOf(actualPresentationArea
108 .getRight()))(requestedPresentationArea
109 .above(actualPresentationArea
110 .getTop()))(
111 requestedPresentationArea.below(actualPresentationArea.getBottom())
112 );
113
114 for(const Rectangle<double>& r: border)
115 {
116 if(!r.isEmpty())
117 {
118 drawRectangle(cr, Colors::OUT_OF_BOUNDS, pixelSize * (r - requestedPresentationArea.getTopLeft()));
119 }
120 }
121}
Definition rectangle.hh:29
Rectangle< value_type > below(value_type v) const
Definition rectangle.hh:158
bool isEmpty() const
Definition rectangle.hh:141
Rectangle< value_type > rightOf(value_type v) const
Definition rectangle.hh:148
value_type getLeft() const
Definition rectangle.hh:110
value_type getBottom() const
Definition rectangle.hh:112
Scroom::Utils::Rectangle< double > const r
Definition transformpresentation_test.cc:65

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,
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}
void setClip(cairo_t *cr, double x, double y, double width, double height)
Definition cairo-helpers.cc:47
Semaphore c(0)

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,
Rectangle< double > const &  viewArea 
)
38{
39 cairo_save(cr);
40
41 c.setColor(cr);
42 drawRectangleContour(cr, viewArea);
43
44 cairo_restore(cr);
45}
void drawRectangleContour(cairo_t *cr, Rectangle< double > const &viewArea)
Definition cairo-helpers.cc:31
Here is the call graph for this function:

◆ drawRectangleContour() [2/2]

void drawRectangleContour ( cairo_t *  cr,
Rectangle< double > const &  viewArea 
)
32{
33 traceRectangleContour(cr, viewArea);
34 cairo_stroke(cr);
35}
void traceRectangleContour(cairo_t *cr, Rectangle< double > const &viewArea)
Definition cairo-helpers.cc:22

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 Rectangle< double > &  area 
)
58{
59 setClip(cr, area.getLeft(), area.getTop(), area.getWidth(), area.getHeight());
60}
value_type getTop() const
Definition rectangle.hh:108
value_type getWidth() const
Definition rectangle.hh:121
value_type getHeight() const
Definition rectangle.hh:123
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,
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}
value_type height() const
Definition rectangle.hh:131
value_type y() const
Definition rectangle.hh:127
value_type x() const
Definition rectangle.hh:125
value_type width() const
Definition rectangle.hh:129

Referenced by drawRectangleContour().

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