Stencil hide shortcut

This commit is contained in:
luboslenco
2020-03-21 14:37:38 +01:00
parent 77668cd4f1
commit 3f4dca2ce4
4 changed files with 26 additions and 14 deletions
@@ -6,6 +6,7 @@
"rotate_light": "shift+middle", "rotate_light": "shift+middle",
"set_clone_source": "alt", "set_clone_source": "alt",
"stencil_transform": "ctrl", "stencil_transform": "ctrl",
"stencil_hide": "z",
"select_material": "shift+number", "select_material": "shift+number",
"cycle_layers": "ctrl+tab", "cycle_layers": "ctrl+tab",
"brush_radius": "f", "brush_radius": "f",
@@ -6,6 +6,7 @@
"rotate_light": "shift+middle", "rotate_light": "shift+middle",
"set_clone_source": "alt", "set_clone_source": "alt",
"stencil_transform": "ctrl", "stencil_transform": "ctrl",
"stencil_hide": "z",
"select_material": "shift+number", "select_material": "shift+number",
"cycle_layers": "ctrl+tab", "cycle_layers": "ctrl+tab",
"brush_radius": "f", "brush_radius": "f",
+10 -2
View File
@@ -14,7 +14,7 @@ class Operator {
public static function update() {} public static function update() {}
public static function shortcut(s: String, repeat = false): Bool { public static function shortcut(s: String, type = ShortcutStarted): Bool {
if (s == "") return false; if (s == "") return false;
var mouse = Input.getMouse(); var mouse = Input.getMouse();
var kb = Input.getKeyboard(); var kb = Input.getKeyboard();
@@ -28,7 +28,15 @@ class Operator {
s = s.substr(s.lastIndexOf("+") + 1); s = s.substr(s.lastIndexOf("+") + 1);
} }
else if (shift || ctrl || alt) return flag; else if (shift || ctrl || alt) return flag;
var key = (s == "left" || s == "right" || s == "middle") ? mouse.down(s) : repeat ? kb.repeat(s) : kb.started(s); var key = (s == "left" || s == "right" || s == "middle") ? mouse.down(s) :
type == ShortcutRepeat ? kb.repeat(s) :
type == ShortcutDown ? kb.down(s) : kb.started(s);
return flag && key; return flag && key;
} }
} }
@:enum abstract ShortcutType(Int) from Int to Int {
var ShortcutStarted = 0;
var ShortcutRepeat = 1;
var ShortcutDown = 2;
}
+14 -12
View File
@@ -552,13 +552,13 @@ class UISidebar {
lockStartedX = mouse.x; lockStartedX = mouse.x;
lockStartedY = mouse.y; lockStartedY = mouse.y;
} }
else if (Operator.shortcut(Config.keymap.brush_radius_decrease, true)) { else if (Operator.shortcut(Config.keymap.brush_radius_decrease, ShortcutRepeat)) {
brushRadius -= getRadiusIncrement(); brushRadius -= getRadiusIncrement();
brushRadius = Math.round(brushRadius * 100) / 100; brushRadius = Math.round(brushRadius * 100) / 100;
brushRadiusHandle.value = brushRadius; brushRadiusHandle.value = brushRadius;
UIHeader.inst.headerHandle.redraws = 2; UIHeader.inst.headerHandle.redraws = 2;
} }
else if (Operator.shortcut(Config.keymap.brush_radius_increase, true)) { else if (Operator.shortcut(Config.keymap.brush_radius_increase, ShortcutRepeat)) {
brushRadius += getRadiusIncrement(); brushRadius += getRadiusIncrement();
brushRadius = Math.round(brushRadius * 100) / 100; brushRadius = Math.round(brushRadius * 100) / 100;
brushRadiusHandle.value = brushRadius; brushRadiusHandle.value = brushRadius;
@@ -583,13 +583,13 @@ class UISidebar {
camHandle.position = cameraType; camHandle.position = cameraType;
ViewportUtil.updateCameraType(cameraType); ViewportUtil.updateCameraType(cameraType);
} }
else if (Operator.shortcut(Config.keymap.view_orbit_left, true)) ViewportUtil.orbit(-Math.PI / 12, 0); else if (Operator.shortcut(Config.keymap.view_orbit_left, ShortcutRepeat)) ViewportUtil.orbit(-Math.PI / 12, 0);
else if (Operator.shortcut(Config.keymap.view_orbit_right, true)) ViewportUtil.orbit(Math.PI / 12, 0); else if (Operator.shortcut(Config.keymap.view_orbit_right, ShortcutRepeat)) ViewportUtil.orbit(Math.PI / 12, 0);
else if (Operator.shortcut(Config.keymap.view_orbit_up, true)) ViewportUtil.orbit(0, -Math.PI / 12); else if (Operator.shortcut(Config.keymap.view_orbit_up, ShortcutRepeat)) ViewportUtil.orbit(0, -Math.PI / 12);
else if (Operator.shortcut(Config.keymap.view_orbit_down, true)) ViewportUtil.orbit(0, Math.PI / 12); else if (Operator.shortcut(Config.keymap.view_orbit_down, ShortcutRepeat)) ViewportUtil.orbit(0, Math.PI / 12);
else if (Operator.shortcut(Config.keymap.view_orbit_opposite)) ViewportUtil.orbit(Math.PI, 0); else if (Operator.shortcut(Config.keymap.view_orbit_opposite)) ViewportUtil.orbit(Math.PI, 0);
else if (Operator.shortcut(Config.keymap.view_zoom_in, true)) ViewportUtil.zoom(0.2); else if (Operator.shortcut(Config.keymap.view_zoom_in, ShortcutRepeat)) ViewportUtil.zoom(0.2);
else if (Operator.shortcut(Config.keymap.view_zoom_out, true)) ViewportUtil.zoom(-0.2); else if (Operator.shortcut(Config.keymap.view_zoom_out, ShortcutRepeat)) ViewportUtil.zoom(-0.2);
} }
if (brushCanLock || brushLocked) { if (brushCanLock || brushLocked) {
@@ -926,11 +926,13 @@ class UISidebar {
} }
if (brushStencilImage != null && Context.tool != ToolBake && Context.tool != ToolPicker && Context.tool != ToolColorId) { if (brushStencilImage != null && Context.tool != ToolBake && Context.tool != ToolPicker && Context.tool != ToolColorId) {
var transform = Operator.shortcut(Config.keymap.stencil_transform);
g.color = 0x88ffffff;
var r = getBrushStencilRect(); var r = getBrushStencilRect();
g.drawScaledImage(brushStencilImage, r.x, r.y, r.w, r.h); if (!Operator.shortcut(Config.keymap.stencil_hide, ShortcutDown)) {
g.color = 0xffffffff; g.color = 0x88ffffff;
g.drawScaledImage(brushStencilImage, r.x, r.y, r.w, r.h);
g.color = 0xffffffff;
}
var transform = Operator.shortcut(Config.keymap.stencil_transform);
if (transform) { if (transform) {
g.drawRect(r.x, r.y, r.w, r.h); g.drawRect(r.x, r.y, r.w, r.h);
g.drawRect(r.x - 8, r.y - 8, 16, 16); g.drawRect(r.x - 8, r.y - 8, 16, 16);