summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2023-09-27 18:44:36 +0200
committerMitya Selivanov <automainint@guattari.tech>2023-09-27 18:44:36 +0200
commitb4576c67fd332a2c90353563c512544f0ddc8978 (patch)
tree0355740135acacb1f47115a315280acca6c1a7c3
parent4f00e27741c73efb0e962d0f0a2de15003b5e1cd (diff)
downloadsaw-b4576c67fd332a2c90353563c512544f0ddc8978.zip
Composing: changing track size and position
-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;
}
}