let user customize square area size

Fixes issue #22
This commit is contained in:
abakkk 2020-03-01 15:03:09 +01:00
parent 1e03967fbf
commit 34c7c8f575
2 changed files with 21 additions and 11 deletions

View File

@ -11,16 +11,21 @@
* 0 : butt, 1 : round, 2 : square
*
* dash:
* dash-array-on is the length of dashes (no dashes if 0, you can put 0.1 to get dots or square according to line-cap)
* dash-array-off is the length of gaps (no dashes if 0)
* dash-array-on is the length of dashes (no dashes if 0, you can put 0.1 to get dots or square according to line-cap).
* dash-array-off is the length of gaps (no dashes if 0).
*
* square area:
* Drawing in a square area is convenient when using the extension as a vector graphics editor. By default,
* when toggling 'Square drawing area', the area is sized to 75% of monitor size. You can fix and customize this size
* by uncommenting square-area-width and square-area-height lines.
*
* font:
* only one family : no comma separated list of families like "font1, font2, ..., Sans-Serif"
* font family can be any font installed, or a generic family name (Serif, Sans-Serif, Monospace, Cursive, Fantasy)
* font weight and font style : no upper case when string
* weight <= 500 (or lighter, normal, medium) is rendered as normal
* weight > 500 (or bolder, bold) is rendered as bold
* oblique and italic style support depends on the font family and seem to be rendered identically
* Only one family : no comma separated list of families like "font1, font2, ..., Sans-Serif".
* Font family can be any font installed, or a generic family name (Serif, Sans-Serif, Monospace, Cursive, Fantasy).
* Font weight and font style : no upper case when string.
* Weight <= 500 (or lighter, normal, medium) is rendered as normal.
* Weight > 500 (or bolder, bold) is rendered as bold.
* Oblique and italic style supports depend on the font family and seem to be rendered identically.
*
*/
@ -41,6 +46,8 @@
-drawing-color8: rgba(130, 130, 130, 0.3);
-drawing-color9: rgb(0, 0, 0);
-drawing-background-color: #2e3436;
/*-drawing-square-area-width: 512px;*/
/*-drawing-square-area-height: 512px;*/
font-family: Cantarell;
font-weight: normal;
font-style: normal;

View File

@ -164,6 +164,8 @@ var DrawingArea = new Lang.Class({
this.fontFamily = font.get_family();
this.currentFontWeight = font.get_weight();
this.currentFontStyle = font.get_style();
this.squareAreaWidth = themeNode.get_length('-drawing-square-area-width');
this.squareAreaHeight = themeNode.get_length('-drawing-square-area-height');
} catch(e) {
logError(e);
}
@ -505,9 +507,10 @@ var DrawingArea = new Lang.Class({
toggleSquareArea: function() {
this.isSquareArea = !this.isSquareArea;
if (this.isSquareArea) {
let squareWidth = Math.min(this.monitor.width, this.monitor.height) * 3 / 4;
this.set_position(Math.floor(this.monitor.width / 2 - squareWidth / 2), Math.floor(this.monitor.height / 2 - squareWidth / 2));
this.set_size(squareWidth, squareWidth);
let width = this.squareAreaWidth || this.squareAreaHeight || Math.min(this.monitor.width, this.monitor.height) * 3 / 4;
let height = this.squareAreaHeight || this.squareAreaWidth || Math.min(this.monitor.width, this.monitor.height) * 3 / 4;
this.set_position(Math.floor(this.monitor.width / 2 - width / 2), Math.floor(this.monitor.height / 2 - height / 2));
this.set_size(width, height);
this.add_style_class_name('draw-on-your-screen-square-area');
} else {
this.set_position(0, 0);