From 28cf22dbad7c3a79234a324fdd2fd352a11eff2d Mon Sep 17 00:00:00 2001 From: Bart Brouns Date: Thu, 12 Dec 2024 18:08:14 +0100 Subject: [PATCH] more wip drawing ActionTrigger as Element --- src/editor.rs | 83 +++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index 75d85a8..342403f 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -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( - // ¶ms.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( + ¶ms.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, @@ -1485,27 +1486,26 @@ impl ActionTrigger { // } #[allow(clippy::match_same_arms)] fn get_action_class( - // params: &Arc, - // is_learning: Arc, + params: &Arc, + is_learning: Arc, learned_notes: Arc, - // last_played_notes: Arc, - // enabled_actions: Arc, + last_played_notes: Arc, + enabled_actions: Arc, 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", @@ -1514,8 +1514,7 @@ impl ActionTrigger { (_, _, true, _, _) => "muted", (_, _, _, true, _) => "live", _ => "default", // Default: paint with background color - }; - 1 + } } }