|
Scroom 0.14-49-gb7ae7a6d
|
#include <ruler.hh>

Public Types | |
| enum | Orientation { HORIZONTAL , VERTICAL } |
| using | Ptr = std::shared_ptr< Ruler > |
Public Member Functions | |
| ~Ruler () | |
| Ruler (const Ruler &)=delete | |
| Ruler (Ruler &&)=delete | |
| Ruler | operator= (const Ruler &)=delete |
| Ruler | operator= (Ruler &&)=delete |
| void | setRange (double lower, double upper) |
Static Public Member Functions | |
| static Ptr | create (Orientation orientation, GtkWidget *drawArea) |
Private Member Functions | |
| Ruler (RulerDrawStrategy::Ptr strategy, GtkWidget *drawingArea) | |
| void | draw (GtkWidget *widget, cairo_t *cr) |
| void | updateAllocatedSize (int newWidth, int newHeight) |
| void | updateMajorTickInterval () |
| void | drawTicks (cairo_t *cr, double lower, double upper, double lineLength) |
| void | drawSingleTick (cairo_t *cr, double linePosition, double lineLength, bool drawLabel, const std::string &label) |
| void | drawSubTicks (cairo_t *cr, double lower, double upper, int depth, double lineLength) |
Static Private Member Functions | |
| static gboolean | drawCallback (GtkWidget *widget, cairo_t *cr, gpointer data) |
| static void | sizeAllocateCallback (GtkWidget *widget, GdkRectangle *allocation, gpointer data) |
Private Attributes | |
| GtkWidget * | drawingArea {} |
| double | lowerLimit {DEFAULT_LOWER} |
| double | upperLimit {DEFAULT_UPPER} |
| int | width {} |
| int | height {} |
| int | majorInterval {1} |
| int | majorTickSpacing {} |
| RulerDrawStrategy::Ptr | drawStrategy |
| GdkRGBA | lineColor {0, 0, 0, 1} |
Static Private Attributes | |
| static constexpr double | DEFAULT_LOWER {0} |
| static constexpr double | DEFAULT_UPPER {10} |
| static constexpr std::array< int, 2 > | SUBTICK_SEGMENTS {5, 2} |
| static constexpr int | MIN_SPACE_SUBTICKS {5} |
| static constexpr double | FONT_SIZE {11} |
| static constexpr double | LABEL_OFFSET {4} |
| static constexpr double | LABEL_ALIGN {0.7} |
| static constexpr double | LINE_MULTIPLIER {0.6} |
| static constexpr double | LINE_WIDTH {1} |
| static constexpr double | MAJOR_TICK_LENGTH {0.8} |
This class draws a ruler to a GtkDrawingArea. It is intended as a replacement for the old GTK2 ruler widget and is written to mimic that widget's behavior as close as possible.
| using Ruler::Ptr = std::shared_ptr<Ruler> |
| enum Ruler::Orientation |
| Enumerator | |
|---|---|
| HORIZONTAL | |
| VERTICAL | |
| Ruler::~Ruler | ( | ) |
|
delete |
|
delete |
|
private |
Creates a Ruler.
| rulerOrientation | The rulerOrientation of the ruler. |
| drawingArea | The GtkDrawingArea to draw the ruler to. |

|
static |
Creates a ruler.
| orientation | The orientation of the ruler. |
| drawArea | The GtkDrawingArea to draw the ruler to. |
Referenced by View::View().


|
private |
Draws the ruler to the given Cairo context.
| widget | The widget that received the draw signal. |
| cr | Cairo context to draw to. |
Referenced by drawCallback().


|
staticprivate |
A callback to be connected to a GtkDrawingArea's "draw" signal. Draws the ruler to the drawing area.
| widget | The widget that received the signal. |
| cr | Cairo context to draw to. |
| data | Pointer to a ruler instance. |
Referenced by Ruler().


|
private |
Draws a single tick, taking into account the ruler's orientation.
| cr | Cairo context to draw to. |
| linePosition | The position of the line along the ruler. |
| lineLength | Length of the line in pixels. |
| drawLabel | True if a label should be drawn to the right/top of the line. |
| label | The label to draw if drawLabel is true. |
Referenced by drawSubTicks(), and drawTicks().

|
private |
Draws the smaller ticks in between the major ticks from left-to-right / bottom-to-top.
| cr | Cairo context to draw to. |
| lower | The lower limit of the range in draw space. |
| upper | The upper limit of the range in draw space. |
| depth | The depth of this recursive function. Functions as an index into the ruler's SUBTICK_SEGMENTS array. |
| lineLength | Length of the lines in pixels. |
Referenced by drawSubTicks(), and drawTicks().


|
private |
Draws the tick marks of the ruler for a given subset of the range from left-to-right / bottom-to-top.
| cr | Cairo context to draw to. |
| lower | The lower limit of the range to draw. |
| upper | The upper limit of the range to draw. |
| lineLength | Length of the lines in pixels. |
Referenced by draw().


| void Ruler::setRange | ( | double | lower, |
| double | upper | ||
| ) |
Sets the range for the ruler to display.
| lower | Lower limit of the ruler range. Must be strictly less than upper. |
| upper | Upper limit of the ruler range. Must be strictly greater than lower. |

|
staticprivate |
A callback to be connected to a GtkDrawingArea's "size-allocate" signal. Updates the internal state of the ruler when the size of the ruler changes.
| widget | The widget that received the signal. |
| allocation | The region which has been allocated to the widget. |
| data | Pointer to a ruler instance. |
Referenced by Ruler().

|
private |
Updates the stored allocated size of the ruler.
| newWidth | The newWidth of the ruler in pixels. |
| newHeight | The newHeight of the ruler in pixels. |

|
private |
Calculates an appropriate interval between major ticks, given the current range and dimensions.
Referenced by Ruler(), setRange(), and updateAllocatedSize().


|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
Referenced by create(), Ruler(), setRange(), and ~Ruler().
|
private |
Referenced by draw(), drawSingleTick(), drawSubTicks(), drawTicks(), Ruler(), updateAllocatedSize(), and updateMajorTickInterval().
|
staticconstexprprivate |
Referenced by drawSingleTick().
|
private |
Referenced by draw(), Ruler(), sizeAllocateCallback(), and updateAllocatedSize().
|
staticconstexprprivate |
Alignment of tick label along the tick line as a fraction of line height.
Referenced by drawSingleTick().
|
staticconstexprprivate |
|
staticconstexprprivate |
The length of a tick one "level" down, as a fraction of the line length of the ticks one level up.
Referenced by drawSubTicks(), and drawTicks().
|
staticconstexprprivate |
Referenced by draw(), and drawSingleTick().
|
private |
Referenced by draw().
|
private |
Referenced by draw(), drawTicks(), setRange(), and updateMajorTickInterval().
|
staticconstexprprivate |
|
private |
The chosen interval between major ticks.
Referenced by draw(), drawTicks(), and updateMajorTickInterval().
|
private |
The space between major ticks when drawn.
Referenced by drawTicks(), and updateMajorTickInterval().
|
staticconstexprprivate |
|
staticconstexprprivate |
Each space between major ticks is split into 5 smaller segments and those segments are split into 2. (Assuming there's enough space.)
Referenced by drawSubTicks().
|
private |
Referenced by draw(), drawTicks(), setRange(), and updateMajorTickInterval().
|
private |
Referenced by draw(), Ruler(), sizeAllocateCallback(), and updateAllocatedSize().