Skip to content

Commit

Permalink
more wip drawing ActionTrigger as Element
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed Dec 12, 2024
1 parent 108a1bf commit 28cf22d
Showing 1 changed file with 41 additions and 42 deletions.
83 changes: 41 additions & 42 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1279,34 +1279,35 @@ impl ActionTrigger {
own_index,
}
.build(cx, move |cx| {
let class_nr = (
params,
is_learning,
learned_notes,
last_played_notes,
enabled_actions,
)
.map(
move |(
Element::new(cx)
.class("trigger-element")
.class(
(
params,
is_learning,
learned_notes,
last_played_notes,
enabled_actions,
)| {
Self::get_action_class(
// &params.get(cx),
// is_learning.get(cx),
learned_notes.get(cx),
// last_played_notes.get(cx),
// enabled_actions.get(cx),
own_index,
)
},
);
Element::new(cx)
.class("trigger-element")
.class("default")
)
.map(
move |(
params,
is_learning,
learned_notes,
last_played_notes,
enabled_actions,
)| {
Self::get_action_class(
&params.get(cx),
is_learning.get(cx),
learned_notes.get(cx),
last_played_notes.get(cx),
enabled_actions.get(cx),
own_index,
)
},
),
)
.hoverable(true);
Label::new(
cx,
Expand Down Expand Up @@ -1485,27 +1486,26 @@ impl ActionTrigger {
// }
#[allow(clippy::match_same_arms)]
fn get_action_class(
// params: &Arc<Del2Params>,
// is_learning: Arc<AtomicBool>,
params: &Arc<Del2Params>,
is_learning: Arc<AtomicBool>,
learned_notes: Arc<AtomicByteArray>,
// last_played_notes: Arc<LastPlayedNotes>,
// enabled_actions: Arc<AtomicBoolArray>,
last_played_notes: Arc<LastPlayedNotes>,
enabled_actions: Arc<AtomicBoolArray>,
own_index: usize,
) -> u8 {
// let is_learning =
// is_learning.load(Ordering::SeqCst) && learned_notes.load(own_index) == LEARNING;
// let is_playing = last_played_notes.is_playing(learned_notes.load(own_index));
// let is_enabled = enabled_actions.load(own_index);
) -> &str {
let is_learning =
is_learning.load(Ordering::SeqCst) && learned_notes.load(own_index) == LEARNING;
let is_playing = last_played_notes.is_playing(learned_notes.load(own_index));
let is_enabled = enabled_actions.load(own_index);

// Determine the paint color based on the state
let class = match (
true, true, true, true,
true,
// is_learning,
// params.global.mute_is_toggle.value(),
// is_enabled,
// is_playing,
// own_index == CLEAR_TAPS,
match (
// true,true,true,true,true,
is_learning,
params.global.mute_is_toggle.value(),
is_enabled,
is_playing,
own_index == CLEAR_TAPS,
) {
(true, _, _, _, _) => "learning",
(_, _, _, true, true) => "muted",
Expand All @@ -1514,8 +1514,7 @@ impl ActionTrigger {
(_, _, true, _, _) => "muted",
(_, _, _, true, _) => "live",
_ => "default", // Default: paint with background color
};
1
}
}
}

Expand Down

0 comments on commit 28cf22d

Please sign in to comment.