Skip to content

Commit

Permalink
Add canvas panning tool to palette
Browse files Browse the repository at this point in the history
  • Loading branch information
thenickdude committed Jul 14, 2021
1 parent 39a0592 commit 76f7dc5
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 17 deletions.
2 changes: 2 additions & 0 deletions js/ChickenPaint.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ export default function ChickenPaint(options) {
CPRectSelection: new ModeChangeAction(ChickenPaint.M_RECT_SELECTION),
CPMoveTool: new ModeChangeAction(ChickenPaint.M_MOVE_TOOL),
CPRotateCanvas: new ModeChangeAction(ChickenPaint.M_ROTATE_CANVAS),
CPPanCanvas: new ModeChangeAction(ChickenPaint.M_PAN_CANVAS),
CPColorPicker: new ModeChangeAction(ChickenPaint.M_COLOR_PICKER),

// Layer transform
Expand Down Expand Up @@ -1401,6 +1402,7 @@ ChickenPaint.M_ROTATE_CANVAS = 4;
ChickenPaint.M_COLOR_PICKER = 5;
ChickenPaint.M_GRADIENTFILL = 6;
ChickenPaint.M_TRANSFORM = 7;
ChickenPaint.M_PAN_CANVAS = 8;

//
// Definition of all the standard tools available
Expand Down
17 changes: 11 additions & 6 deletions js/gui/CPCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ export default function CPCanvas(controller) {
CPColorPickerMode.prototype = Object.create(CPMode.prototype);
CPColorPickerMode.prototype.constructor = CPColorPickerMode;

function CPPanMode() {
function CPPanCanvasMode() {
var
panningX, panningY,
panningOffset,
Expand Down Expand Up @@ -909,7 +909,8 @@ export default function CPCanvas(controller) {
this.mouseDown = function(e, button, pressure) {
if (this.capture) {
return true;
} else if (button == BUTTON_WHEEL || key.isPressed("space") && button == BUTTON_PRIMARY) {
} else if (button == BUTTON_WHEEL || key.isPressed("space") && button == BUTTON_PRIMARY
|| !this.transient && button == BUTTON_PRIMARY) {
this.capture = true;
panningButton = button;
panningX = e.pageX;
Expand Down Expand Up @@ -952,8 +953,8 @@ export default function CPCanvas(controller) {
};
}

CPPanMode.prototype = Object.create(CPMode.prototype);
CPPanMode.prototype.constructor = CPFloodFillMode;
CPPanCanvasMode.prototype = Object.create(CPMode.prototype);
CPPanCanvasMode.prototype.constructor = CPPanCanvasMode;

function CPFloodFillMode() {
}
Expand Down Expand Up @@ -2493,7 +2494,11 @@ export default function CPCanvas(controller) {
case ChickenPaint.M_ROTATE_CANVAS:
newMode = rotateCanvasMode;
break;


case ChickenPaint.M_PAN_CANVAS:
newMode = panMode;
break;

case ChickenPaint.M_COLOR_PICKER:
newMode = colorPickerMode;
break;
Expand Down Expand Up @@ -2530,7 +2535,7 @@ export default function CPCanvas(controller) {

defaultMode = new CPDefaultMode();
colorPickerMode = new CPColorPickerMode();
panMode = new CPPanMode();
panMode = new CPPanCanvasMode();
rotateCanvasMode = new CPRotateCanvasMode();
floodFillMode = new CPFloodFillMode();
gradientFillMode = new CPGradientFillMode();
Expand Down
28 changes: 17 additions & 11 deletions js/gui/CPToolPalette.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ export default function CPToolPalette(cpController) {
mode: ChickenPaint.M_COLOR_PICKER
},
{
className: "chickenpaint-tool-rotate-canvas",
command: "CPRotateCanvas",
commandDoubleClick: "CPResetCanvasRotation",
toolTip: "Rotate canvas",
mode: ChickenPaint.M_ROTATE_CANVAS
className: "chickenpaint-tool-blur",
command: "CPBlur",
toolTip: "Blur",
mode: ChickenPaint.M_DRAW,
tool: ChickenPaint.T_BLUR
},
{
className: "chickenpaint-tool-pencil",
Expand Down Expand Up @@ -152,12 +152,18 @@ export default function CPToolPalette(cpController) {
tool: ChickenPaint.T_BURN
},
{
className: "chickenpaint-tool-blur",
command: "CPBlur",
toolTip: "Blur",
mode: ChickenPaint.M_DRAW,
tool: ChickenPaint.T_BLUR
}
className: "chickenpaint-tool-rotate-canvas",
command: "CPRotateCanvas",
commandDoubleClick: "CPResetCanvasRotation",
toolTip: "Rotate canvas",
mode: ChickenPaint.M_ROTATE_CANVAS
},
{
className: "chickenpaint-tool-pan-canvas",
command: "CPPanCanvas",
toolTip: "Grab canvas",
mode: ChickenPaint.M_PAN_CANVAS
},
],
listElem = document.createElement("ul");

Expand Down
1 change: 1 addition & 0 deletions js/languages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
"Gradient fill": "グラデーション",
"Color picker": "スポイト",
"Rotate canvas": "キャンバスの回転",
"Grab canvas": "キャンバスの位置",
"Pencil": "鉛筆",
"Pen": "ペン",
"Airbrush": "エアブラシ",
Expand Down
3 changes: 3 additions & 0 deletions resources/css/chickenpaint.scss
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@
.chickenpaint-tool-rotate-canvas .chickenpaint-toolbar-button-icon {
background-position:0 -928px;
}
.chickenpaint-tool-pan-canvas .chickenpaint-toolbar-button-icon {
background-position:0 -672px;
}
.chickenpaint-tool-pencil .chickenpaint-toolbar-button-icon {
background-position:0 -160px;
}
Expand Down
Binary file modified resources/gfx/icons-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/gfx/icons-2x.psd
Binary file not shown.
Binary file modified resources/gfx/icons-ja-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/gfx/icons-ja-2x.psd
Binary file not shown.
Binary file modified resources/gfx/icons-ja.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/gfx/icons-ja.psd
Binary file not shown.
Binary file modified resources/gfx/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/gfx/icons.psd
Binary file not shown.
Binary file removed resources/gfx/iconstext.psd
Binary file not shown.
Binary file removed resources/gfx/smallicons.png
Binary file not shown.
Binary file removed resources/gfx/smallicons.psd
Binary file not shown.

0 comments on commit 76f7dc5

Please sign in to comment.