Feat: begin sample explorer overhaul
All checks were successful
Deploy Website / deploy (push) Has been skipped
All checks were successful
Deploy Website / deploy (push) Has been skipped
This commit is contained in:
@@ -211,6 +211,21 @@ fn handle_scroll(ctx: &mut InputContext, col: u16, row: u16, term: Rect, up: boo
|
||||
return;
|
||||
}
|
||||
|
||||
// Scroll over side panel area
|
||||
if ctx.app.panel.visible && ctx.app.panel.side.is_some() {
|
||||
let (_main_area, side_area) = panel_split(body);
|
||||
if contains(side_area, col, row) {
|
||||
if let Some(crate::state::SidePanel::SampleBrowser(state)) = &mut ctx.app.panel.side {
|
||||
if up {
|
||||
state.move_up();
|
||||
} else {
|
||||
state.move_down();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
match ctx.app.page {
|
||||
Page::Main => {
|
||||
if up {
|
||||
@@ -356,25 +371,60 @@ fn handle_footer_click(ctx: &mut InputContext, col: u16, row: u16, footer: Rect)
|
||||
|
||||
// --- Body ---
|
||||
|
||||
fn handle_body_click(ctx: &mut InputContext, col: u16, row: u16, body: Rect, kind: ClickKind) {
|
||||
// Account for side panel splitting
|
||||
let page_area = if ctx.app.panel.visible && ctx.app.panel.side.is_some() {
|
||||
if body.width >= 120 {
|
||||
let panel_width = body.width * 35 / 100;
|
||||
let [main, _side] =
|
||||
Layout::horizontal([Constraint::Fill(1), Constraint::Length(panel_width)])
|
||||
.areas(body);
|
||||
main
|
||||
} else {
|
||||
let panel_height = body.height * 40 / 100;
|
||||
let [main, _side] =
|
||||
Layout::vertical([Constraint::Fill(1), Constraint::Length(panel_height)])
|
||||
.areas(body);
|
||||
main
|
||||
}
|
||||
fn panel_split(body: Rect) -> (Rect, Rect) {
|
||||
if body.width >= 120 {
|
||||
let panel_width = body.width * 35 / 100;
|
||||
let [main, side] =
|
||||
Layout::horizontal([Constraint::Fill(1), Constraint::Length(panel_width)])
|
||||
.areas(body);
|
||||
(main, side)
|
||||
} else {
|
||||
body
|
||||
};
|
||||
let panel_height = body.height * 40 / 100;
|
||||
let [main, side] =
|
||||
Layout::vertical([Constraint::Fill(1), Constraint::Length(panel_height)])
|
||||
.areas(body);
|
||||
(main, side)
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_body_click(ctx: &mut InputContext, col: u16, row: u16, body: Rect, kind: ClickKind) {
|
||||
use crate::state::PanelFocus;
|
||||
|
||||
if ctx.app.panel.visible && ctx.app.panel.side.is_some() {
|
||||
let (main_area, side_area) = panel_split(body);
|
||||
|
||||
if contains(side_area, col, row) {
|
||||
ctx.app.panel.focus = PanelFocus::Side;
|
||||
return;
|
||||
}
|
||||
|
||||
// Click on main area: defocus panel
|
||||
if contains(main_area, col, row) {
|
||||
if kind == ClickKind::Double {
|
||||
ctx.dispatch(AppCommand::ClosePanel);
|
||||
} else {
|
||||
ctx.app.panel.focus = PanelFocus::Main;
|
||||
}
|
||||
}
|
||||
|
||||
// Fall through to page-specific handler with main_area
|
||||
if !contains(main_area, col, row) {
|
||||
return;
|
||||
}
|
||||
|
||||
match ctx.app.page {
|
||||
Page::Main => handle_main_click(ctx, col, row, main_area, kind),
|
||||
Page::Patterns => handle_patterns_click(ctx, col, row, main_area, kind),
|
||||
Page::Help => handle_help_click(ctx, col, row, main_area),
|
||||
Page::Dict => handle_dict_click(ctx, col, row, main_area),
|
||||
Page::Options => handle_options_click(ctx, col, row, main_area),
|
||||
Page::Engine => handle_engine_click(ctx, col, row, main_area, kind),
|
||||
Page::Script => handle_script_click(ctx, col, row, main_area),
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let page_area = body;
|
||||
|
||||
if !contains(page_area, col, row) {
|
||||
return;
|
||||
|
||||
@@ -41,7 +41,7 @@ pub(super) fn handle_panel_input(ctx: &mut InputContext, key: KeyEvent) -> Input
|
||||
}
|
||||
KeyCode::Down => {
|
||||
for _ in 0..10 {
|
||||
state.move_down(30);
|
||||
state.move_down();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
@@ -49,7 +49,7 @@ pub(super) fn handle_panel_input(ctx: &mut InputContext, key: KeyEvent) -> Input
|
||||
} else {
|
||||
match key.code {
|
||||
KeyCode::Up | KeyCode::Char('k') => state.move_up(),
|
||||
KeyCode::Down | KeyCode::Char('j') => state.move_down(30),
|
||||
KeyCode::Down | KeyCode::Char('j') => state.move_down(),
|
||||
KeyCode::PageUp => {
|
||||
for _ in 0..20 {
|
||||
state.move_up();
|
||||
@@ -57,7 +57,7 @@ pub(super) fn handle_panel_input(ctx: &mut InputContext, key: KeyEvent) -> Input
|
||||
}
|
||||
KeyCode::PageDown => {
|
||||
for _ in 0..20 {
|
||||
state.move_down(30);
|
||||
state.move_down();
|
||||
}
|
||||
}
|
||||
KeyCode::Enter | KeyCode::Right => {
|
||||
@@ -71,6 +71,10 @@ pub(super) fn handle_panel_input(ctx: &mut InputContext, key: KeyEvent) -> Input
|
||||
.audio_tx
|
||||
.load()
|
||||
.send(AudioCommand::Evaluate { cmd, time: None });
|
||||
ctx.dispatch(AppCommand::SetStatus(format!(
|
||||
"\u{25B8} {}/{}",
|
||||
folder, entry.label
|
||||
)));
|
||||
}
|
||||
_ => state.toggle_expand(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user