Skip to content

Commit

Permalink
toggle effects panel
Browse files Browse the repository at this point in the history
  • Loading branch information
subalterngames committed Dec 31, 2023
1 parent d77fdcc commit 24ed973
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
7 changes: 4 additions & 3 deletions data/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ check_for_updates = 1
# You can optionally set the sensitivity, the number of frames until the app registers a repeat event:
# {"keys": ["PageUp"], "dt": 10}
# If you don't set the dt value, key presses are detected only on press, not on held.
#
# For a list of key codes, see: <cacophony directory>/data/keycodes.txt

# Text-to-speech.
StatusTTS = {"keys": ["F1"]}
Expand All @@ -72,6 +70,9 @@ StopTTS = {"keys": ["F5"]}
# Enable links panel.
EnableLinksPanel = {"keys": ["F9"]}

# Toggle effects panel.
ToggleEffectsPanel = {"keys": ["CapsLock"]}

# Files.
NewFile = {"keys": ["N"], "mods": ["LeftControl"]}
OpenFile = {"keys": ["O"], "mods": ["LeftControl"]}
Expand Down Expand Up @@ -337,7 +338,7 @@ quick_zoom = 4
# In precise mode, increment by this factor. This must be an integer.
precise_zoom = 1

[EFFECT]
[EFFECTS]
# The input sensitivity for Pitch Bend. A higher value means that input will be faster at the cost of accuracy.
pitch_bend_sensitivity = 10

Expand Down
1 change: 1 addition & 0 deletions data/text.csv
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ APP_TTS_3,\0 and \1 to cycle panels.
APP_TTS_4,\0 or \1 to undo or redo.
APP_TTS_5,\0 to ask me to stop talking.
APP_TTS_6,\0 to open a panel with helpful website links.
APP_TTS_7,\0 to show or hide the effects panel.
FILE_TTS_0,\0 for new music.
FILE_TTS_1,\0 to open a file.
FILE_TTS_2,\0 to save. \1 to save as.
Expand Down
2 changes: 2 additions & 0 deletions input/src/input_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub enum InputEvent {
StopTTS,
// Enable links panel.
EnableLinksPanel,
// Toggle effects panel.
ToggleEffectsPanel,
// Undo-redo.
Undo,
Redo,
Expand Down
3 changes: 1 addition & 2 deletions input/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,13 @@ pub const KEYS: [KeyCode; 121] = [
];

/// The keycodes for the mods.
pub(crate) const MODS: [KeyCode; 7] = [
pub(crate) const MODS: [KeyCode; 6] = [
KeyCode::LeftControl,
KeyCode::RightControl,
KeyCode::LeftAlt,
KeyCode::RightAlt,
KeyCode::LeftShift,
KeyCode::RightShift,
KeyCode::CapsLock,
];

pub(crate) const ALPHANUMERIC_INPUT_MODS: [KeyCode; 2] = [KeyCode::Backspace, KeyCode::CapsLock];
18 changes: 17 additions & 1 deletion io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use audio::export::ExportState;
use audio::Conn;
use common::{InputState, Music, PanelType, Paths, PathsState, State};
use common::{Index, InputState, Music, PanelType, Paths, PathsState, State};
use edit::edit_file;
use effects_panel::EffectsPanel;
use hashbrown::HashMap;
Expand Down Expand Up @@ -140,6 +140,9 @@ impl IO {
tooltips
.get_tooltip("APP_TTS_6", &[InputEvent::EnableLinksPanel], input, text)
.clone(),
tooltips
.get_tooltip("APP_TTS_7", &[InputEvent::ToggleEffectsPanel], input, text)
.clone(),
];
tts.insert(InputEvent::AppTTS, app_tts);
// File TTS.
Expand Down Expand Up @@ -402,6 +405,19 @@ impl IO {
self.links_panel.enable(state);
return false;
}
// Show or hide the effects panel.
if input.happened(&InputEvent::ToggleEffectsPanel) {
let s0 = state.clone();
if state.panels.contains(&PanelType::Effects) {
state.panels.retain(|p| *p != PanelType::Effects);
state.focus = Index::new(state.panels.len() - 1, state.panels.len());
} else {
state.panels.push(PanelType::Effects);
state.focus = Index::new(state.focus.get(), state.panels.len());
}
self.undo.push(Snapshot::from_states(s0, state));
return false;
}
// Get the focused panel.
let panel = self.get_panel(&state.panels[state.focus.get()]);
// Update the focuses panel and potentially get a screenshot.
Expand Down
4 changes: 1 addition & 3 deletions render/src/effects_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ impl EffectsPanel {
// Get the panel.
let size = [
get_effects_panel_width(text),
get_piano_roll_panel_size(config)[1]
- PIANO_ROLL_PANEL_TOP_BAR_HEIGHT
- PIANO_ROLL_PANEL_VOLUME_HEIGHT,
get_piano_roll_panel_size(config)[1] - PIANO_ROLL_PANEL_VOLUME_HEIGHT,
];
let position = [
get_window_grid_size(config)[0] - size[0],
Expand Down
8 changes: 4 additions & 4 deletions render/src/effects_panel/effect_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl EffectField {
VALUE_WIDTH,
),
]),
4,
3,
),
EffectType::PolyphonicKeyPressure { key: _, value: _ } => (
EffectFieldValues::Two([
Expand All @@ -63,17 +63,17 @@ impl EffectField {
VALUE_WIDTH,
),
]),
4,
3,
),
_ => (
EffectFieldValues::One(List::new([x, *y + 1], VALUE_WIDTH)),
3,
2,
),
};
// Get the background rectangle.
let rect = Rectangle::new([x, *y], [width, dy]);
// Increment the y value.
*y += dy;
*y += dy + 1;
Self {
label,
values,
Expand Down

0 comments on commit 24ed973

Please sign in to comment.