[background] Add Dotted with margins

wilder/main
Jacopo De Simoi 2 years ago
parent 95072ec5e6
commit 2b136414f0
  1. 7
      src/core/control/pagetype/PageTypeHandler.cpp
  2. 2
      src/core/model/PageType.h
  3. 41
      src/core/view/background/DottedBackgroundPainter.cpp
  4. 3
      src/core/view/background/DottedBackgroundPainter.h
  5. 3
      src/core/view/background/MainBackgroundPainter.cpp
  6. 7
      ui/pagetemplates.ini

@ -22,7 +22,9 @@ PageTypeHandler::PageTypeHandler(GladeSearchpath* gladeSearchPath) {
addPageTypeInfo(_("Ruled with vertical line"), PageTypeFormat::Lined, "");
addPageTypeInfo(_("Staves"), PageTypeFormat::Staves, "");
addPageTypeInfo(_("Graph"), PageTypeFormat::Graph, "");
addPageTypeInfo(_("Dotted"), PageTypeFormat::Dotted, "");
addPageTypeInfo(_("Dotted with margins"), PageTypeFormat::DottedMargin, "");
addPageTypeInfo(_("Isometric Dotted"), PageTypeFormat::IsoDotted, "");
addPageTypeInfo(_("Isometric Graph"), PageTypeFormat::IsoGraph, "");
}
@ -111,6 +113,9 @@ auto PageTypeHandler::getPageTypeFormatForString(const string& format) -> PageTy
if (format == "dotted") {
return PageTypeFormat::Dotted;
}
if (format == "dottedmargin") {
return PageTypeFormat::DottedMargin;
}
if (format == "isodotted") {
return PageTypeFormat::IsoDotted;
}
@ -143,6 +148,8 @@ auto PageTypeHandler::getStringForPageTypeFormat(const PageTypeFormat& format) -
return "graph";
case PageTypeFormat::Dotted:
return "dotted";
case PageTypeFormat::DottedMargin:
return "dottedmargin";
case PageTypeFormat::IsoDotted:
return "isodotted";
case PageTypeFormat::IsoGraph:

@ -15,7 +15,7 @@
#include <vector>
enum class PageTypeFormat { Plain, Ruled, Lined, Staves, Graph, Dotted, IsoDotted, IsoGraph, Pdf, Image, Copy };
enum class PageTypeFormat { Plain, Ruled, Lined, Staves, Graph, Dotted, DottedMargin, IsoDotted, IsoGraph, Pdf, Image, Copy };
class PageType {
public:

@ -2,13 +2,14 @@
#include "util/Util.h"
DottedBackgroundPainter::DottedBackgroundPainter() = default;
DottedBackgroundPainter::DottedBackgroundPainter(bool margins): margins(margins) {}
DottedBackgroundPainter::~DottedBackgroundPainter() = default;
void DottedBackgroundPainter::resetConfig() {
this->defaultForegroundColor1 = 0x303030U;
this->defaultAlternativeForegroundColor1 = 0x434343U;
this->defaultForegroundColor1 = 0x4A4A4AU;
this->defaultAlternativeForegroundColor1 = 0x262626U;//303030U;
this->defaultForegroundColor2 = 0xB58900U;
this->lineWidth = 0.2;
this->drawRaster1 = 10;
}
@ -19,15 +20,30 @@ void DottedBackgroundPainter::paint() {
}
void DottedBackgroundPainter::paintBackgroundDotted() {
Util::cairo_set_source_rgbi(cr, this->foregroundColor1);
auto pos = [dr1 = drawRaster1](int i) { return dr1 + i * dr1; };
int left_margin=1;
int right_margin=40;
if (margins) {
Util::cairo_set_source_rgbi(cr, this->defaultAlternativeForegroundColor1);
cairo_rectangle(cr, 0, 0, pos(left_margin), height);
cairo_rectangle(cr, pos(right_margin), 0, width, height);
cairo_fill(cr);
}
Util::cairo_set_source_rgbi(cr, this->defaultForegroundColor1);
cairo_set_line_width(cr, lineWidth * lineWidthFactor);
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
double delta=5*lineWidth*lineWidthFactor;
auto pos = [dr1 = drawRaster1](int i) { return dr1 + i * dr1; };
for (int x = 0; pos(x) < width; ++x) {
if (!margins || ((x != left_margin) && (x != right_margin)))
for (int y = 0; pos(y) < height; ++y) {
cairo_move_to(cr, pos(x)-delta, pos(y));
cairo_line_to(cr, pos(x)+delta, pos(y));
@ -35,6 +51,19 @@ void DottedBackgroundPainter::paintBackgroundDotted() {
cairo_line_to(cr, pos(x), pos(y)+delta);
}
}
cairo_stroke(cr);
if (margins) {
Util::cairo_set_source_rgbi(cr, this->defaultForegroundColor1);
cairo_move_to(cr, pos(left_margin), 0);
cairo_line_to(cr, pos(left_margin), height);
cairo_move_to(cr, pos(right_margin), 0);
cairo_line_to(cr, pos(right_margin), height);
cairo_stroke(cr);
}
}

@ -19,7 +19,7 @@
class DottedBackgroundPainter: public BaseBackgroundPainter {
public:
DottedBackgroundPainter();
DottedBackgroundPainter(bool margins);
virtual ~DottedBackgroundPainter();
public:
@ -32,4 +32,5 @@ public:
virtual void resetConfig();
private:
bool margins;
};

@ -15,7 +15,8 @@ MainBackgroundPainter::MainBackgroundPainter() {
painter[PageTypeFormat::Lined] = new LineBackgroundPainter(true);
painter[PageTypeFormat::Staves] = new StavesBackgroundPainter();
painter[PageTypeFormat::Graph] = new GraphBackgroundPainter();
painter[PageTypeFormat::Dotted] = new DottedBackgroundPainter();
painter[PageTypeFormat::Dotted] = new DottedBackgroundPainter(false);
painter[PageTypeFormat::DottedMargin] = new DottedBackgroundPainter(true);
painter[PageTypeFormat::IsoDotted] = new IsometricBackgroundPainter(false);
painter[PageTypeFormat::IsoGraph] = new IsometricBackgroundPainter(true);
}

@ -30,6 +30,12 @@ name=Dotted
name[de]=Gepunktet
format=dotted
[predefinedDottedMargin]
name=Dotted with Margin
name[de]=Gepunktet
format=dottedmargin
[predefinedIsoDotted]
name=Isometric Dotted
name[de]=Isometrisch Gepunktet
@ -45,4 +51,3 @@ name=Graph with border
name[de]=Kariert mit Rand
format=graph
config=m1=40,rm=1

Loading…
Cancel
Save