Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointer subtool 'Scaling edit tool behavior' #1680

Merged
merged 6 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions icons/fontra-icons.ufo/glyphs/contents.plist
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
<string>pointeradd.glif</string>
<key>pointeraddquad</key>
<string>pointeraddquad.glif</string>
<key>pointerscale</key>
<string>pointerscale.glif</string>
<key>q</key>
<string>q.glif</string>
<key>r</key>
Expand Down
74 changes: 74 additions & 0 deletions icons/fontra-icons.ufo/glyphs/pointerscale.glif
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="pointerscale" format="2">
<advance width="1000"/>
<guideline x="857" y="500" angle="90" identifier="h6zVhlqYKu"/>
<guideline x="320" y="680" angle="0" identifier="fM9U3RNcIq"/>
<guideline x="581" y="-77" angle="0" identifier="xIUWeV7Fve"/>
<outline>
<contour>
<point x="531" y="14"/>
<point x="541" y="16"/>
<point x="547" y="23" type="curve" smooth="yes"/>
<point x="635" y="111" type="line"/>
<point x="696" y="-37" type="line" smooth="yes"/>
<point x="705" y="-60"/>
<point x="732" y="-72"/>
<point x="756" y="-62" type="curve" smooth="yes"/>
<point x="778" y="-53"/>
<point x="789" y="-26"/>
<point x="780" y="-2" type="curve" smooth="yes"/>
<point x="720" y="147" type="line"/>
<point x="842" y="147" type="line" smooth="yes"/>
<point x="851" y="147"/>
<point x="860" y="152"/>
<point x="863" y="160" type="curve" smooth="yes"/>
<point x="867" y="170"/>
<point x="865" y="179"/>
<point x="858" y="187" type="curve" smooth="yes"/>
<point x="547" y="501" type="line" smooth="yes"/>
<point x="541" y="507"/>
<point x="531" y="509"/>
<point x="521" y="505" type="curve" smooth="yes"/>
<point x="513" y="501"/>
<point x="508" y="494"/>
<point x="508" y="484" type="curve" smooth="yes"/>
<point x="508" y="39" type="line" smooth="yes"/>
<point x="508" y="30"/>
<point x="514" y="22"/>
<point x="523" y="18" type="curve" smooth="yes"/>
</contour>
<contour>
<point x="176" y="194" type="line"/>
<point x="211" y="476"/>
<point x="381" y="625"/>
<point x="682" y="625" type="curve" smooth="yes"/>
<point x="704" y="625"/>
<point x="714" y="640"/>
<point x="714" y="654" type="curve" smooth="yes"/>
<point x="714" y="668"/>
<point x="704" y="683"/>
<point x="682" y="683" type="curve" smooth="yes"/>
<point x="318" y="683"/>
<point x="115" y="468"/>
<point x="115" y="84" type="curve" smooth="yes"/>
<point x="115" y="65"/>
<point x="131" y="56"/>
<point x="145" y="56" type="curve" smooth="yes"/>
<point x="160" y="56"/>
<point x="175" y="65"/>
<point x="175" y="84" type="curve" smooth="yes"/>
<point x="175" y="251"/>
<point x="287" y="352"/>
<point x="426" y="352" type="curve" smooth="yes"/>
<point x="448" y="352"/>
<point x="458" y="366"/>
<point x="458" y="381" type="curve" smooth="yes"/>
<point x="458" y="396"/>
<point x="448" y="410"/>
<point x="426" y="410" type="curve" smooth="yes"/>
<point x="299" y="410"/>
<point x="190" y="330"/>
<point x="150" y="199" type="curve"/>
</contour>
</outline>
</glyph>
13 changes: 13 additions & 0 deletions icons/fontra-icons.ufo/lib.plist
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@
<string>alignright</string>
<string>reference</string>
<string>ruler</string>
<string>_cursor-rotate-hotspot-0-0</string>
<string>_cursor-rotate-temp</string>
<string>cursor-rotate-bottom-center</string>
<string>cursor-rotate-bottom-left</string>
<string>cursor-rotate-bottom-right</string>
<string>cursor-rotate-middle-left</string>
<string>cursor-rotate-middle-right</string>
<string>cursor-rotate-top-center</string>
<string>cursor-rotate-top-left</string>
<string>cursor-rotate-top-right</string>
<string>pointeraddquad</string>
<string>pointerscale</string>
<string>skew</string>
</array>
</dict>
</plist>
1 change: 1 addition & 0 deletions src/fontra/client/images/pointerscale.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/fontra/client/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"editor.pen-tool-cubic": "Pen Tool (cubic)",
"editor.pen-tool-quad": "Pen Tool (quadratic)",
"editor.pointer-tool": "Pointer Tool",
"editor.pointer-tool-scale": "Pointer Tool (Scaling edit tool behavior)",
"editor.power-ruler-tool": "Power Ruler Tool",
"editor.shape-tool": "Shape Tool",
"editor.shape-tool-ellipse": "Shape Tool Ellipse",
Expand Down
1 change: 1 addition & 0 deletions src/fontra/client/lang/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"editor.pen-tool-cubic": "Pen Tool (cubic)",
"editor.pen-tool-quad": "Pen Tool (quadratic)",
"editor.pointer-tool": "指针工具",
"editor.pointer-tool-scale": "指针工具 (Scaling edit tool behavior)",
"editor.power-ruler-tool": "Power 测量尺工具",
"editor.shape-tool": "Shape Tool",
"editor.shape-tool-ellipse": "椭圆工具",
Expand Down
19 changes: 19 additions & 0 deletions src/fontra/views/editor/edit-tools-pointer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const transformHandleMargin = 6;
const transformHandleSize = 8;
const rotationHandleSizeFactor = 1.2;

export class PointerTools {
identifier = "pointer-tools";
subTools = [PointerTool, PointerToolScale];
}

export class PointerTool extends BaseTool {
iconPath = "/images/pointer.svg";
identifier = "pointer-tool";
Expand Down Expand Up @@ -759,6 +764,20 @@ registerVisualizationLayerDefinition({
},
});

export class PointerToolScale extends PointerTool {
iconPath = "/images/pointerscale.svg";
identifier = "pointer-tool-scale";

activate() {
this.setCursor();
this.sceneController.experimentalFeatures.scalingEditBehavior = true;
}

deactivate() {
this.sceneController.experimentalFeatures.scalingEditBehavior = false;
}
}

function getTransformHandles(transformBounds, margin) {
const { width, height } = rectSize(transformBounds);

Expand Down
12 changes: 10 additions & 2 deletions src/fontra/views/editor/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,19 @@ body {
display: inline-grid;
}

.tool-button:first-child {
.tool-button:first-child,
.subtool-button:first-child {
border-radius: 0.65em 0 0 0.65em;
}

.tool-button:last-child {
.tool-button:first-child:has(
.subtool-button:nth-child(2)[style*="visibility: visible;"]
) {
border-radius: 0.65em 0 0 0;
}

.tool-button:last-child,
.subtool-button:last-child {
border-radius: 0 0.65em 0.65em 0;
}

Expand Down
4 changes: 2 additions & 2 deletions src/fontra/views/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import { CJKDesignFrame } from "./cjk-design-frame.js";
import { HandTool } from "./edit-tools-hand.js";
import { KnifeTool } from "./edit-tools-knife.js";
import { PenTool } from "./edit-tools-pen.js";
import { PointerTool } from "./edit-tools-pointer.js";
import { PointerTools } from "./edit-tools-pointer.js";
import { PowerRulerTool } from "./edit-tools-power-ruler.js";
import { ShapeTool } from "./edit-tools-shape.js";
import { SceneController } from "./scene-controller.js";
Expand Down Expand Up @@ -978,7 +978,7 @@ export class EditorController {
this.tools = {};
this.topLevelTools = {};
const editToolClasses = [
PointerTool,
PointerTools,
PenTool,
KnifeTool,
ShapeTool,
Expand Down