Skip to content

Commit

Permalink
wip Arc<AtomicBool> -> bool
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed Dec 9, 2024
1 parent c6532ff commit 6203280
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
17 changes: 8 additions & 9 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct Data {
pub last_learned_notes: Arc<AtomicByteArray>,
pub last_played_notes: Arc<LastPlayedNotes>,
pub enabled_actions: Arc<AtomicBoolArray>,
pub show_full_parameters: Arc<AtomicBool>,
pub show_full_parameters: bool,
}

impl Model for Data {}
Expand Down Expand Up @@ -78,8 +78,7 @@ pub fn create(editor_data: Data, editor_state: Arc<ViziaState>) -> Option<Box<dy
;
Label::new(cx, "DEL2").class("plugin-name");
});
let show_parameters =
Data::show_full_parameters.map(|params| params.load(Ordering::SeqCst));
let show_parameters = Data::show_full_parameters;

Binding::new(cx, show_parameters, |cx, show_parameters| {
if show_parameters.get(cx) {
Expand Down Expand Up @@ -1699,15 +1698,15 @@ impl View for ActionTrigger {
///////////////////////////////////////////////////////////////////////////////

pub struct CollapseButton {
show_full_parameters: Arc<AtomicBool>,
show_full_parameters: bool,
}
impl CollapseButton {
pub fn new<ShowFullParametersL>(
cx: &mut Context,
show_full_parameters: ShowFullParametersL,
) -> Handle<Self>
where
ShowFullParametersL: Lens<Target = Arc<AtomicBool>>,
ShowFullParametersL: Lens<Target = bool>,
{
Self {
show_full_parameters: show_full_parameters.get(cx),
Expand All @@ -1717,7 +1716,7 @@ impl CollapseButton {
cx,
show_full_parameters.map(|show_full_parameters| {
// ▲ ▼ ◀ ▶
if show_full_parameters.load(Ordering::SeqCst) {
if *show_full_parameters {
String::from("▴")
} else {
String::from("▸")
Expand All @@ -1735,10 +1734,10 @@ impl View for CollapseButton {
WindowEvent::MouseDown(MouseButton::Left)
| WindowEvent::MouseDoubleClick(MouseButton::Left)
| WindowEvent::MouseTripleClick(MouseButton::Left) => {
if self.show_full_parameters.load(Ordering::SeqCst) {
self.show_full_parameters.store(false, Ordering::SeqCst)
if self.show_full_parameters {
self.show_full_parameters = false;
} else {
self.show_full_parameters.store(true, Ordering::SeqCst)
self.show_full_parameters = true;
}
meta.consume();
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub struct Del2 {
counting_state: CountingState,
should_update_filter: Arc<AtomicBool>,
enabled_actions: Arc<AtomicBoolArray>,
show_full_parameters: Arc<AtomicBool>,
show_full_parameters: bool,
running_delay_tempo: f32,
first_process_after_reset: bool,
}
Expand Down Expand Up @@ -532,7 +532,7 @@ impl Default for Del2 {
counting_state: CountingState::TimeOut,
should_update_filter,
enabled_actions,
show_full_parameters: Arc::new(AtomicBool::new(true)),
show_full_parameters: true,
running_delay_tempo: DEFAULT_TEMPO,
first_process_after_reset: true,
}
Expand Down

0 comments on commit 6203280

Please sign in to comment.