summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/saw/main.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/source/saw/main.c b/source/saw/main.c
index 0720960..fdcda68 100644
--- a/source/saw/main.c
+++ b/source/saw/main.c
@@ -290,8 +290,25 @@ static void saw_ui_compose(i64 x0, i64 y0, i64 width, i64 height) {
saw_compose.rolls[i] = -1;
roll->enabled = 0;
} else {
- if (saw_lbutton_click)
- saw_current_roll = saw_compose.rolls[i];
+ if (saw_lbutton_click) {
+ if (saw_current_roll == saw_compose.rolls[i]) {
+ i64 cell = ((saw_mouse_x - saw_compose.offset_x) *
+ grid_rate) /
+ grid_scale;
+ i64 c0 = (roll->frame * grid_rate) / SAW_SAMPLE_RATE;
+ i64 c1 = c0 + (roll->size * grid_rate) / roll->rate;
+ saw_compose.grid_input = 1;
+ saw_compose.grid_roll = saw_current_roll;
+ if (cell - c0 > c1 - cell) {
+ saw_compose.grid_cell = c0;
+ roll->size = ((cell - c0 + 1) * roll->rate) / grid_rate;
+ } else {
+ saw_compose.grid_cell = c1 - 1;
+ roll->size = ((c1 - cell + 1) * roll->rate) / grid_rate;
+ }
+ } else
+ saw_current_roll = saw_compose.rolls[i];
+ }
hover_any = 1;
}
}