Skip to content

Commit

Permalink
Apply reviewer suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandlo committed Dec 27, 2022
1 parent e18afff commit a15d10b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/core/view/CompassView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ using namespace xoj::view;

constexpr double LINE_WIDTH = .02;
constexpr double FONT_SIZE = .2;
constexpr const char* FONT_FAMILY = "Arial";

CompassView::CompassView(const Compass* compass, Repaintable* parent, ZoomControl* zoomControl):
GeometryToolView(compass, parent, zoomControl) {
Expand All @@ -32,6 +33,9 @@ CompassView::~CompassView() noexcept { this->unregisterFromPool(); };
void CompassView::on(FlagDirtyRegionRequest, const Range& rg) { this->parent->flagDirtyRegion(rg); }

void CompassView::on(UpdateValuesRequest, double h, double rot, cairo_matrix_t m) {
if (h <= 0.) {
g_warning("Non-positive compass height: %f", h);
}
height = h;
rotation = rot;
matrix = m;
Expand All @@ -52,7 +56,7 @@ void CompassView::drawGeometryTool(cairo_t* cr) const {

cairo_set_line_width(cr, LINE_WIDTH);
cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_select_font_face(cr, "Arial", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_select_font_face(cr, FONT_FAMILY, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, FONT_SIZE);

cairo_set_source_rgb(cr, 1, 0, 0); // red
Expand All @@ -69,7 +73,7 @@ void CompassView::drawDisplays(cairo_t* cr) const {
xoj::util::CairoSaveGuard saveGuard(cr);
cairo_transform(cr, &matrix);
cairo_set_line_width(cr, LINE_WIDTH);
cairo_select_font_face(cr, "Arial", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_select_font_face(cr, FONT_FAMILY, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, FONT_SIZE);

cairo_set_source_rgb(cr, 0, .5, .5); // turquoise
Expand Down
8 changes: 6 additions & 2 deletions src/core/view/SetsquareView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ constexpr int MIN_VMARK_LARGE = 5;
constexpr int OFFSET_FROM_SEMICIRCLE = 2.;
constexpr double ZERO_MARK_TICK = .5;
constexpr int SKIPPED_HMARKS = 8;
constexpr const char* FONT_FAMILY = "Arial";

SetsquareView::SetsquareView(const Setsquare* setsquare, Repaintable* parent, ZoomControl* zoomControl):
GeometryToolView(setsquare, parent, zoomControl) {
Expand All @@ -45,6 +46,9 @@ SetsquareView::~SetsquareView() noexcept { this->unregisterFromPool(); };
void SetsquareView::on(FlagDirtyRegionRequest, const Range& rg) { this->parent->flagDirtyRegion(rg); }

void SetsquareView::on(UpdateValuesRequest, double h, double rot, cairo_matrix_t m) {
if (h <= 0.) {
g_warning("Non-positive setsquare height: %f", h);
}
height = h;
rotation = rot;
matrix = m;
Expand Down Expand Up @@ -75,7 +79,7 @@ void SetsquareView::drawGeometryTool(cairo_t* cr) const {

cairo_set_line_width(cr, LINE_WIDTH);
cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_select_font_face(cr, "Arial", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_select_font_face(cr, FONT_FAMILY, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, FONT_SIZE);

// clip to slightly enlarged setsquare for performance reasons
Expand Down Expand Up @@ -103,7 +107,7 @@ void SetsquareView::drawDisplays(cairo_t* cr) const {
xoj::util::CairoSaveGuard saveGuard(cr);
cairo_transform(cr, &matrix);
cairo_set_line_width(cr, LINE_WIDTH);
cairo_select_font_face(cr, "Arial", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_select_font_face(cr, FONT_FAMILY, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, FONT_SIZE);

cairo_set_source_rgb(cr, .0, .5, .5); // turquoise
Expand Down

0 comments on commit a15d10b

Please sign in to comment.