Commit Graph

109 Commits

Author SHA1 Message Date
abakkk f0b3876bac fourth point for curves
Third and fourth points are available by pressing `Ctrl` or `Enter`.
2020-06-19 17:01:16 +02:00
abakkk 4d901db080 use constants for extremum values 2020-06-19 17:01:16 +02:00
abakkk 1e4a847565 replace Mainloop by GLib 2020-06-19 17:01:16 +02:00
abakkk 879fad367c SCALE_DIRECTIONAL -> STRETCH 2020-06-19 17:01:16 +02:00
abakkk a84d71bd5e Remove unnecessary 'setDash' 2020-06-19 17:01:16 +02:00
abakkk 6f9b07b64d Reduce computing by skipping the most 'getContains' calls without notable effect 2020-06-19 17:01:16 +02:00
abakkk 5ca7a5e4a6 fix transformed center getter
Since reflection and inversion introductions, compute center only with the slides of the traslations is not correct.

* `_getCenter` -> `_getOriginalCenter`
* `_getCenterWithSlide` -> `_getTransformedCenter`
* Use pango matrices to compute the new center position since matrices from Cairo, Graphene, ..., are not available with GJS.
* Stock original center and transformed center to not compute it numerous time.
2020-06-19 17:01:16 +02:00
abakkk a33f7b8324 add isStraightLine method to elements 2020-06-19 17:01:16 +02:00
abakkk a569eed459 elementFinder -> elementGrabber 2020-06-19 17:01:16 +02:00
abakkk 22ffa69f68 scale_directional transformation
It combines former `SCALE` and `SCALE_ANGLE` transformations.
2020-06-19 16:55:18 +02:00
abakkk fa4223b7ce Introduce mirror manipulations
* Reflection (symmetry axis)
* Inversion (symmetry point)

`transformingElement` is locked after selecting it.
2020-06-19 16:54:31 +02:00
abakkk 15d3efcbd5 user.css
* Add a warning about updates.
* Add alternative color palettes.
* Change background color (pure dark gray).
2020-06-17 17:59:42 +02:00
abakkk 2658926c44 Add debug constants and helpers 2020-06-17 15:43:23 +02:00
abakkk 317f9e4176 invert fill and stroke painting
Use `cr.fillPreserve, ..., then cr.stroke` instead of `cr.copyPath, ..., cr.stroke, cr.appendPath, cr.fill`
Was there a reason for painting stroke before fill ?
Is something broken ?
2020-06-17 15:37:37 +02:00
abakkk 6a0c0e525a cr.save, cr.stroke, cr.identityMatrix
* Use `cr.save` and `cr.stroke` (Restore the context but not the path).
* Use `cr.identityMatrix` to clean context after transformations.
  Inverting transformations was not enough, in particular with combinations of scale and rotate (`SCALE_ANGLE`, `REFLECTION`, ...).
  Now all elements can be grabbed correctly.
2020-06-17 15:27:18 +02:00
abakkk c26c8cd2b5 misc dash fixes
* Use `setDash([0,0], 0)` to disable dash.
* Disable dashes when drawing the grid.
* Add `crSetDummyStroke` utility function.
2020-06-16 00:06:52 +02:00
abakkk 4907e35778 Introduce resize manipulation
* `SCALE_PRESERVE` (preserve ratio)
* `SCALE` (vertical, horizontal or both)

There is a third transformation, `SCALE_ANGLE`, that is not used because it causes problems to the `elementFinder`. Probably a bug of Cairo.inStroke that do no consider scales.
2020-06-15 22:13:03 +02:00
abakkk 443d1f8662 Introduce move manipulation
* 'Shapes' -> 'Tools' ('Shapes' + 'Manipulations')
* 'TextState' -> 'TextStates'
* Rotation centers are now computed dynamically (when building Cairo or SVG paths).
* Text rotation center is now located at the beginning of the text.
* Text elements gain a 'lineIndex' attribute to retrieve the rotation center of the first line.
2020-06-15 21:09:30 +02:00
abakkk 9f4e8a25d0 refactor the code before introducing new tools
All geometric stuff is delegate to elements.
Use general and reusable transformations.
2020-06-12 03:45:51 +02:00
abakkk 9fc08f8bce dashed line: compute dash attributes from line width (by default) 2020-06-08 22:27:58 +02:00
abakkk 04894a9031 add "file-rule" drawing element attribute 2020-06-08 22:25:26 +02:00
abakkk b4eb418c89 key label translations
Get key label translations by using Gtk.
2020-06-08 14:30:47 +02:00
abakkk 95f54f0576 fix undefined 'state' property
```
JS WARNING: [/home/.../draw.js 997]: reference to undefined property "state"
```

The state property is undefined if the element is loaded from json file.
2020-06-07 21:53:08 +02:00
abakkk d0177aa8eb Fix null line-width when drawing
It may be usefull to select null line width in combination with fill.
However user cannot see what he's drawing.

So add a dummy stroke while drawing.
2020-06-07 20:37:13 +02:00
abakkk 2c632c3d3a use `line` svg element for straight lines 2020-06-07 20:16:28 +02:00
abakkk 5b7d1eedf4 new polyline shape
Mark vertices with `Enter` and finish drawing by releasing clic, like other shapes.
2020-06-07 20:05:30 +02:00
abakkk b69c4ccf97 new polygon shape
Mark vertices with `Enter` and finish drawing by releasing clic, like other shapes.
2020-06-07 18:57:11 +02:00
abakkk 755b3d79c9 text: start a new line with Enter key
Finish writing with click or `Escape` key.

close #30
2020-06-07 17:01:36 +02:00
abakkk c087e359d9 hide help on `Escape` key pressed
Press the key again to leave drawing mode.
2020-06-05 22:52:02 +02:00
abakkk c5721f9752 no separator on small monitor 2020-06-05 22:45:11 +02:00
abakkk 360ac081ce Add grid overlay 2020-06-05 15:58:58 +02:00
abakkk 11a00a25d0 Fix font-color label color
Foreground color markup is not displayed since 3.36, use style instead but the transparency is lost.

close #31
2020-06-01 20:27:05 +02:00
abakkk a4456762b5 not to populate helper widget before the first showing
Does not fix anything, just a marginal gain.
2020-06-01 17:37:08 +02:00
abakkk b45c86a5af escape empty media-keys settings in the helper
close #28
2020-06-01 17:36:43 +02:00
abakkk 508d7dca3a fix helper OSD display 2020-03-13 17:09:57 +01:00
abakkk 6286834473 GS 3.36 compatibility
* Clutter.Escape -> Clutter.KEY_Escape
* container.add(child) -> actor.add_child(child)
* container.add(child, { expand: true }) -> child.x_expand = true && actor.add_child(child)
* slider.onKeyPressEvent does not exist anymore (Slider use vfunc instead)
2020-03-13 17:09:57 +01:00
abakkk 0ae23a5d10 "Open user.css" -> "Edit style" 2020-03-04 14:23:49 +01:00
abakkk 289b280f67 remove Monospace in openDrawing item styles 2020-03-04 08:51:36 +01:00
abakkk 06f59dbea3 json files
* Do not use fileInfo.get_modification_date_time for compatibility reason.
* Inverse 'Open drawing' list order: recent first.
* Overwrite identical contents when the save operation is queried by the user.
2020-03-03 13:48:31 +01:00
abakkk 8580902bf5 fix commit 5e8cb0ea1 (close menu when showing helper) 2020-03-02 16:42:46 +01:00
abakkk d19c3e25ea cleanup 2020-03-02 16:32:50 +01:00
abakkk 0dd7859d4f minor, syntax 2020-03-01 17:33:41 +01:00
abakkk 34c7c8f575 let user customize square area size
Fixes issue #22
2020-03-01 16:56:49 +01:00
abakkk 1e03967fbf introduce space key modifier
Pointer movement is ignored when the `space` key is held.

To ensure [Screenshot Tool](https://extensions.gnome.org/extension/1112/screenshot-tool/) extension compatibility, we need a way to let the third extension select the screenshot area with pointer but without leaving drawing mode and without drawing.

As a side effect, it allows to insert straight line segments in free drawing (after releasing the key).

Fixes issue #20
2020-03-01 13:25:48 +01:00
abakkk 5e8cb0ea1f close menu when showing helper 2020-03-01 11:35:33 +01:00
abakkk c9bde10ff0 cursor -> textCursor
Not to be confused with pointer cursor.
2020-02-09 17:56:40 +01:00
abakkk cc7e208c35 minor, imports ByteArray module in header 2020-02-09 17:45:28 +01:00
abakkk 528a62fa57 minor, menuCloseFunction
Fixes 'TypeError: this.saveDrawingSubMenu is undefined'
2020-02-09 16:43:21 +01:00
abakkk e0ce5e0096 do not override peristent.json with an empty drawing when changing persistency setting 2020-01-10 13:01:26 +01:00
abakkk aa0a984878 define 'persistent-file-name' and 'svg-file-name' in metadata
instead of 'DEFAULT-FILE-NAME' const
2020-01-10 12:32:28 +01:00