Skip to content

Commit

Permalink
VK: unselect scale group on second tap
Browse files Browse the repository at this point in the history
  • Loading branch information
woesss committed Dec 25, 2023
1 parent f168152 commit 63969e1
Showing 1 changed file with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -824,12 +824,8 @@ public int getLayoutEditMode() {

public void setLayoutEditMode(int mode) {
layoutEditMode = mode;
int group = -1;
if (mode == LAYOUT_SCALES) {
editedIndex = 0;
group = 0;
}
highlightGroup(group);
editedIndex = -1;
highlightGroup(-1);
handler.removeCallbacks(this);
visible = true;
overlayView.postInvalidate();
Expand Down Expand Up @@ -939,15 +935,21 @@ public boolean pointerPressed(int pointer, float x, float y) {
}
}
}
if (index >= 0) {
if (editedIndex == index) {
editedIndex = -1;
highlightGroup(-1);
overlayView.postInvalidate();
} else if (index >= 0) {
editedIndex = index;
highlightGroup(index);
overlayView.postInvalidate();
}
if (editedIndex >= 0) {
prevScaleX = keyScales[editedIndex * 2];
prevScaleY = keyScales[editedIndex * 2 + 1];
}
offsetX = x;
offsetY = y;
prevScaleX = keyScales[editedIndex * 2];
prevScaleY = keyScales[editedIndex * 2 + 1];
}
}
return false;
Expand Down Expand Up @@ -996,10 +998,16 @@ public boolean pointerDragged(int pointer, float x, float y) {
}
}
case LAYOUT_SCALES -> {
if (editedIndex == -1) {
break;
}
float dx = x - offsetX;
float dy = offsetY - y;
int index = this.editedIndex * 2;
int index = editedIndex * 2;
float scale = prevScaleX + dx / Math.min(screen.centerX(), screen.centerY());
if (scale <= 0.0f) {
scale = Float.MIN_VALUE;
}
if (Math.abs(1 - scale) <= SCALE_SNAP_RADIUS) {
scale = 1;
} else {
Expand All @@ -1012,6 +1020,9 @@ public boolean pointerDragged(int pointer, float x, float y) {
}
keyScales[index++] = scale;
scale = prevScaleY + dy / Math.min(screen.centerX(), screen.centerY());
if (scale <= 0.0f) {
scale = Float.MIN_VALUE;
}
if (Math.abs(1 - scale) <= SCALE_SNAP_RADIUS) {
scale = 1;
} else {
Expand All @@ -1023,7 +1034,7 @@ public boolean pointerDragged(int pointer, float x, float y) {
}
}
keyScales[index] = scale;
resizeKeyGroup(this.editedIndex);
resizeKeyGroup(editedIndex);
snapKeys();
overlayView.postInvalidate();
}
Expand Down

0 comments on commit 63969e1

Please sign in to comment.