From 01ec6dc63d74c00cfa52c100b44378b13fc636ff Mon Sep 17 00:00:00 2001 From: Benjamin Klum Date: Wed, 23 Oct 2024 06:56:39 +0200 Subject: [PATCH] Fix build warnings --- main/src/domain/accelerator.rs | 5 +- .../infrastructure/plugin/backbone_shell.rs | 74 ++--- main/src/infrastructure/test/mod.rs | 5 +- main/src/infrastructure/ui/help.rs | 1 - main/src/infrastructure/ui/mapping_panel.rs | 273 ++++++++---------- swell-ui/src/units.rs | 6 +- 6 files changed, 158 insertions(+), 206 deletions(-) diff --git a/main/src/domain/accelerator.rs b/main/src/domain/accelerator.rs index 687c637ac..82a35233c 100644 --- a/main/src/domain/accelerator.rs +++ b/main/src/domain/accelerator.rs @@ -5,7 +5,10 @@ use crate::domain::{ use helgoboss_learn::AbstractTimestamp; use reaper_high::Reaper; use reaper_low::raw; -use reaper_medium::{AccelMsg, AccelMsgKind, AcceleratorBehavior, TranslateAccel, TranslateAccelArgs, TranslateAccelResult, AcceleratorKeyCode, virt_keys}; +use reaper_medium::{ + virt_keys, AccelMsg, AccelMsgKind, AcceleratorBehavior, TranslateAccel, TranslateAccelArgs, + TranslateAccelResult, +}; use swell_ui::{SharedView, View, Window}; pub trait HelgoboxWindowSnitch { diff --git a/main/src/infrastructure/plugin/backbone_shell.rs b/main/src/infrastructure/plugin/backbone_shell.rs index 71b0e2914..f84dadc2d 100644 --- a/main/src/infrastructure/plugin/backbone_shell.rs +++ b/main/src/infrastructure/plugin/backbone_shell.rs @@ -72,16 +72,15 @@ use helgobox_api::runtime::{AutoAddedControllerEvent, GlobalInfoEvent}; use itertools::Itertools; use once_cell::sync::Lazy; use reaper_high::{ - ChangeEvent, CrashInfo, Fx, GroupingBehavior, Guid, MiddlewareControlSurface, Project, Reaper, - Track, + ChangeEvent, CrashInfo, Fx, Guid, MiddlewareControlSurface, Project, Reaper, Track, }; use reaper_low::{raw, PluginContext, Swell}; use reaper_macros::reaper_extension_plugin; use reaper_medium::{ - reaper_str, AccelMsg, AcceleratorPosition, ActionValueChange, CommandId, GangBehavior, Hmenu, - HookCustomMenu, HookPostCommand, HookPostCommand2, Hwnd, HwndInfo, HwndInfoType, - InputMonitoringMode, MenuHookFlag, MidiInputDeviceId, MidiOutputDeviceId, ReaProject, - ReaperStr, RecordingInput, RegistrationHandle, SectionContext, ToolbarIconMap, WindowContext, + reaper_str, AccelMsg, AcceleratorPosition, ActionValueChange, CommandId, Hmenu, HookCustomMenu, + HookPostCommand, HookPostCommand2, Hwnd, HwndInfo, HwndInfoType, MenuHookFlag, + MidiInputDeviceId, MidiOutputDeviceId, ReaProject, ReaperStr, RegistrationHandle, + SectionContext, ToolbarIconMap, WindowContext, }; use reaper_rx::{ActionRxHookPostCommand, ActionRxHookPostCommand2}; use rxrust::prelude::*; @@ -553,30 +552,6 @@ impl BackboneShell { TEMP_DIR.as_ref() } - /// Creates a new track in the given project and adds a new Helgobox instance to it. - pub async fn create_new_instance_in_project( - project: Project, - track_name: &str, - ) -> anyhow::Result { - let track = project.insert_track_at(0)?; - track.set_name(track_name); - track.set_recording_input(Some(RecordingInput::Midi { - device_id: None, - channel: None, - })); - track.arm( - false, - GangBehavior::DenyGang, - GroupingBehavior::PreventGrouping, - ); - track.set_input_monitoring_mode( - InputMonitoringMode::Normal, - GangBehavior::DenyGang, - GroupingBehavior::PreventGrouping, - ); - Self::create_new_instance_on_track(&track).await - } - /// Creates a new Helgobox instance on the given track. pub async fn create_new_instance_on_track(track: &Track) -> anyhow::Result { let fx = track @@ -1416,13 +1391,6 @@ impl BackboneShell { f(&self.unit_infos.borrow()) } - pub fn find_session_by_containing_fx(&self, fx: &Fx) -> Option { - self.find_session(|session| { - let session = session.borrow(); - session.processor_context().containing_fx() == fx - }) - } - pub fn register_instance(&self, instance_shell: &SharedInstanceShell) { debug!("Registering new instance..."); let instance = Rc::downgrade(instance_shell.instance()); @@ -3002,16 +2970,13 @@ pub struct NewInstanceOutcome { #[cfg(feature = "playtime")] mod playtime_impl { use crate::infrastructure::data::LicenseManager; - use crate::infrastructure::plugin::helgobox_plugin::HELGOBOX_UNIQUE_VST_PLUGIN_ADD_STRING; - use crate::infrastructure::plugin::BackboneShell; + use crate::infrastructure::plugin::{BackboneShell, NewInstanceOutcome}; use anyhow::Context; - use base::future_util::millis; use base::metrics_util::{record_duration, record_occurrence}; - use base::Global; use camino::Utf8PathBuf; use playtime_api::persistence::PlaytimeSettings; use playtime_clip_engine::PlaytimeEngine; - use reaper_high::{GroupingBehavior, Reaper}; + use reaper_high::{GroupingBehavior, Project, Reaper}; use reaper_medium::{GangBehavior, InputMonitoringMode, RecordingInput}; use std::fs; @@ -3032,10 +2997,33 @@ mod playtime_impl { async fn add_and_show_playtime() -> anyhow::Result<()> { let project = Reaper::get().current_project(); - BackboneShell::create_new_instance_in_project(project, "Playtime").await?; + create_new_instance_in_project(project, "Playtime").await?; enable_playtime_for_first_helgobox_instance_and_show_it()?; Ok(()) } + /// Creates a new track in the given project and adds a new Helgobox instance to it. + pub async fn create_new_instance_in_project( + project: Project, + track_name: &str, + ) -> anyhow::Result { + let track = project.insert_track_at(0)?; + track.set_name(track_name); + track.set_recording_input(Some(RecordingInput::Midi { + device_id: None, + channel: None, + })); + track.arm( + false, + GangBehavior::DenyGang, + GroupingBehavior::PreventGrouping, + ); + track.set_input_monitoring_mode( + InputMonitoringMode::Normal, + GangBehavior::DenyGang, + GroupingBehavior::PreventGrouping, + ); + BackboneShell::create_new_instance_on_track(&track).await + } pub fn init_clip_engine(license_manager: &LicenseManager) { #[derive(Debug)] diff --git a/main/src/infrastructure/test/mod.rs b/main/src/infrastructure/test/mod.rs index 79b1b632e..e3e9e3460 100644 --- a/main/src/infrastructure/test/mod.rs +++ b/main/src/infrastructure/test/mod.rs @@ -1,5 +1,4 @@ use crate::domain::{FinalSourceFeedbackValue, PLUGIN_PARAMETER_COUNT}; -use crate::infrastructure::plugin::helgobox_plugin::HELGOBOX_UNIQUE_VST_PLUGIN_ADD_STRING; use crate::infrastructure::plugin::{BackboneShell, NewInstanceOutcome, SET_STATE_PARAM_NAME}; use approx::assert_abs_diff_eq; use base::future_util::millis; @@ -7,7 +6,7 @@ use base::{Global, SenderToNormalThread}; use helgoboss_learn::{MidiSourceValue, BASE_EPSILON, FEEDBACK_EPSILON}; use helgoboss_midi::test_util::*; use helgoboss_midi::{DataEntryByteOrder, ParameterNumberMessage, RawShortMessage, ShortMessage}; -use reaper_high::{Fx, FxParameter, Reaper, Track}; +use reaper_high::{FxParameter, Reaper, Track}; use reaper_medium::{Db, ReaperPanValue, StuffMidiMessageTarget}; use std::ffi::CString; use std::future::Future; @@ -1457,7 +1456,7 @@ mod macos_impl { use std::fs; use std::path::PathBuf; use swell_ui::View; - use xcap::image::{imageops, DynamicImage, RgbaImage}; + use xcap::image::{imageops, DynamicImage}; pub async fn take_screenshots() { // Given diff --git a/main/src/infrastructure/ui/help.rs b/main/src/infrastructure/ui/help.rs index 59620547b..5c4c7a800 100644 --- a/main/src/infrastructure/ui/help.rs +++ b/main/src/infrastructure/ui/help.rs @@ -1,4 +1,3 @@ -use crate::infrastructure::ui::help::SourceTopic::{Category, Learn, Type}; use derive_more::Display; use helgoboss_learn::ModeParameter; use include_dir::{include_dir, Dir}; diff --git a/main/src/infrastructure/ui/mapping_panel.rs b/main/src/infrastructure/ui/mapping_panel.rs index ebd26ce24..29e5d24a5 100644 --- a/main/src/infrastructure/ui/mapping_panel.rs +++ b/main/src/infrastructure/ui/mapping_panel.rs @@ -1,4 +1,3 @@ -use anyhow::Context; use derive_more::Display; use helgoboss_midi::{Channel, ShortMessageType, U7}; use itertools::Itertools; @@ -20,12 +19,11 @@ use std::{cmp, iter}; use strum::IntoEnumIterator; use helgoboss_learn::{ - check_mode_applicability, format_percentage_without_unit, AbsoluteMode, AbsoluteValue, - ButtonUsage, ControlValue, DetailedSourceCharacter, DiscreteIncrement, DisplayType, - EncoderUsage, FeedbackType, FireMode, GroupInteraction, Interval, - MackieSevenSegmentDisplayScope, MidiClockTransportMessage, ModeApplicabilityCheckInput, - ModeParameter, OscTypeTag, OutOfRangeBehavior, PercentIo, RgbColor, SourceCharacter, - TakeoverMode, Target, UnitValue, ValueSequence, VirtualColor, DEFAULT_OSC_ARG_VALUE_RANGE, + format_percentage_without_unit, AbsoluteMode, AbsoluteValue, ButtonUsage, ControlValue, + DiscreteIncrement, DisplayType, EncoderUsage, FeedbackType, FireMode, GroupInteraction, + Interval, MackieSevenSegmentDisplayScope, MidiClockTransportMessage, ModeParameter, OscTypeTag, + OutOfRangeBehavior, PercentIo, RgbColor, SourceCharacter, TakeoverMode, Target, UnitValue, + ValueSequence, VirtualColor, DEFAULT_OSC_ARG_VALUE_RANGE, }; use helgobox_api::persistence::{ ActionScope, Axis, BrowseTracksMode, FxDescriptor, FxToolAction, LearnableTargetKind, @@ -36,8 +34,8 @@ use helgobox_api::persistence::{ TrackToolAction, VirtualControlElementCharacter, }; use swell_ui::{ - DeviceContext, DialogUnits, Pixels, Point, SharedView, SwellStringArg, View, ViewContext, - WeakView, Window, + DeviceContext, DialogUnits, Point, SharedView, SwellStringArg, View, ViewContext, WeakView, + Window, }; use crate::application::{ @@ -77,7 +75,7 @@ use crate::infrastructure::ui::help::{ ConceptTopic, HelpTopic, HelpTopicDescription, MappingTopic, SourceTopic, TargetTopic, }; use crate::infrastructure::ui::menus::{get_midi_input_device_list_label, get_param_name}; -use crate::infrastructure::ui::ui_element_container::{UiElement, UiElementContainer}; +use crate::infrastructure::ui::ui_element_container::UiElementContainer; use crate::infrastructure::ui::util::colors::ColorPair; use crate::infrastructure::ui::util::{ close_child_panel_if_open, colors, compartment_parameter_dropdown_contents, @@ -197,17 +195,17 @@ impl MappingPanel { use SessionProp::*; match affected { One(InCompartment(compartment, One(InMapping(mapping_id, affected)))) - if Some(QualifiedMappingId::new(*compartment, *mapping_id)) - == self.qualified_mapping_id() => - { - // At this point we know already it's a prop change for *our* mapping. - // Mark as programmatic invocation. - let panel_clone = self.clone(); - panel_clone.set_invoked_programmatically(true); - scopeguard::defer! { panel_clone.set_invoked_programmatically(false); } - // If the reaction can't be displayed anymore because the mapping is not filled anymore, - // so what. - let _ = self.clone().read(|view| match affected { + if Some(QualifiedMappingId::new(*compartment, *mapping_id)) + == self.qualified_mapping_id() => + { + // At this point we know already it's a prop change for *our* mapping. + // Mark as programmatic invocation. + let panel_clone = self.clone(); + panel_clone.set_invoked_programmatically(true); + scopeguard::defer! { panel_clone.set_invoked_programmatically(false); } + // If the reaction can't be displayed anymore because the mapping is not filled anymore, + // so what. + let _ = self.clone().read(|view| match affected { Multiple => { view.invalidate_all_controls(); } @@ -635,7 +633,7 @@ impl MappingPanel { } } }); - } + } _ => {} } } @@ -694,7 +692,7 @@ impl MappingPanel { control_element_type, &HashMap::default(), ) - .ok_or("nothing picked")?; + .ok_or("nothing picked")?; let element_id = text.parse().unwrap_or_default(); self.change_mapping(MappingCommand::ChangeTarget( TargetCommand::SetControlElementId(element_id), @@ -839,7 +837,7 @@ impl MappingPanel { control_element_type, &grouped_mappings, ) - .ok_or("nothing picked")?; + .ok_or("nothing picked")?; let control_element_id = text.parse().unwrap_or_default(); self.change_mapping(MappingCommand::ChangeSource( SourceCommand::SetControlElementId(control_element_id), @@ -1533,7 +1531,7 @@ impl MappingPanel { current_id.compartment, false, ) - .collect(); + .collect(); let current_index = mappings .iter() .position(|m| m.borrow().id() == current_id.id) @@ -1589,7 +1587,7 @@ impl MappingPanel { p.invalidate_all_controls(); p.register_listeners(); }) - .expect("mapping must be filled at this point"); + .expect("mapping must be filled at this point"); } fn session(&self) -> SharedUnitModel { @@ -1709,7 +1707,7 @@ impl MappingPanel { indicator.disable(); } - fn party_is_over(&self) -> impl LocalObservable<'static, Item=(), Err=()> + 'static { + fn party_is_over(&self) -> impl LocalObservable<'static, Item = (), Err = ()> + 'static { self.view .closed() .merge(self.party_is_over_subject.borrow().clone()) @@ -1717,7 +1715,7 @@ impl MappingPanel { fn when( self: &SharedView, - event: impl LocalObservable<'static, Item=I, Err=()> + 'static, + event: impl LocalObservable<'static, Item = I, Err = ()> + 'static, reaction: impl Fn(&ImmutableMappingPanel, I) + 'static + Copy, ) { when(event.take_until(self.party_is_over())) @@ -2633,11 +2631,6 @@ impl<'a> MutableMappingPanel<'a> { } fn update_mode_feedback_transformation(&mut self) { - let mode_parameter = if self.mapping.mode_model.feedback_type().is_textual() { - ModeParameter::TextualFeedbackExpression - } else { - ModeParameter::FeedbackTransformation - }; let control_id = root::ID_MODE_EEL_FEEDBACK_TRANSFORMATION_EDIT_CONTROL; let value = self .view @@ -2680,9 +2673,7 @@ impl<'a> MutableMappingPanel<'a> { self.update_mode_step_from_slider( slider, ModeCommand::SetMinStepFactor, - ModeParameter::StepFactorMin, ModeCommand::SetMinStepSize, - ModeParameter::StepSizeMin, ) } @@ -2690,9 +2681,7 @@ impl<'a> MutableMappingPanel<'a> { self.update_mode_step_from_slider( slider, ModeCommand::SetMaxStepFactor, - ModeParameter::StepFactorMax, ModeCommand::SetMaxStepSize, - ModeParameter::StepSizeMax, ) } @@ -2700,18 +2689,14 @@ impl<'a> MutableMappingPanel<'a> { &mut self, slider: Window, factor_command: impl FnOnce(DiscreteIncrement) -> ModeCommand, - factor_param: ModeParameter, size_command: impl FnOnce(UnitValue) -> ModeCommand, - size_param: ModeParameter, ) { - let mode_param = if self.mapping_uses_step_factors() { + if self.mapping_uses_step_factors() { let value = slider.slider_discrete_increment(); self.change_mapping(MappingCommand::ChangeMode(factor_command(value))); - factor_param } else { let value = slider.slider_unit_value(); self.change_mapping(MappingCommand::ChangeMode(size_command(value))); - size_param }; } @@ -4048,29 +4033,6 @@ impl<'a> ImmutableMappingPanel<'a> { Some(()) } - fn get_control_and_feedback_hint( - &self, - source_character: DetailedSourceCharacter, - mode_parameter: ModeParameter, - ) -> (Option<&str>, Option<&str>) { - let base_input = ModeApplicabilityCheckInput { - source_character, - ..self.mapping.base_mode_applicability_check_input() - }; - let control = ModeApplicabilityCheckInput { - is_feedback: false, - ..base_input - }; - let feedback = ModeApplicabilityCheckInput { - is_feedback: true, - ..base_input - }; - ( - check_mode_applicability(mode_parameter, control).hint(), - check_mode_applicability(mode_parameter, feedback).hint(), - ) - } - fn clear_help(&self) { self.view .require_control(root::ID_MAPPING_HELP_LEFT_SUBJECT_LABEL) @@ -4395,9 +4357,9 @@ impl<'a> ImmutableMappingPanel<'a> { } t if t.supports_midi_message_number() || t.supports_parameter_number_message_number() => - { - Some(t.number_label()) - } + { + Some(t.number_label()) + } _ => None, } } @@ -4526,9 +4488,9 @@ impl<'a> ImmutableMappingPanel<'a> { self.source.midi_source_type(), MidiSourceType::Raw | MidiSourceType::Script ) => - { - Some("...") - } + { + Some("...") + } Osc => Some("..."), _ => None, }; @@ -4975,19 +4937,19 @@ impl<'a> ImmutableMappingPanel<'a> { ); } ReaperTargetType::GoToBookmark - if self.target.bookmark_anchor_type() == BookmarkAnchorType::Id => - { - combo.show(); - let project = self.target_with_context().project(); - let bookmark_type = self.target.bookmark_type(); - let bookmarks = bookmark_combo_box_entries(project, bookmark_type); - combo.fill_combo_box_with_data_vec(bookmarks.collect()); - select_bookmark_in_combo_box( - combo, - self.target.bookmark_anchor_type(), - self.target.bookmark_ref(), - ); - } + if self.target.bookmark_anchor_type() == BookmarkAnchorType::Id => + { + combo.show(); + let project = self.target_with_context().project(); + let bookmark_type = self.target.bookmark_type(); + let bookmarks = bookmark_combo_box_entries(project, bookmark_type); + combo.fill_combo_box_with_data_vec(bookmarks.collect()); + select_bookmark_in_combo_box( + combo, + self.target.bookmark_anchor_type(), + self.target.bookmark_ref(), + ); + } ReaperTargetType::BrowseGroup => { combo.show(); let compartment = self.mapping.compartment(); @@ -5177,12 +5139,12 @@ impl<'a> ImmutableMappingPanel<'a> { control.set_text(text); } ReaperTargetType::GoToBookmark - if self.target.bookmark_anchor_type() == BookmarkAnchorType::Index => - { - control.show(); - let text = (self.target.bookmark_ref() + 1).to_string(); - control.set_text(text); - } + if self.target.bookmark_anchor_type() == BookmarkAnchorType::Index => + { + control.show(); + let text = (self.target.bookmark_ref() + 1).to_string(); + control.set_text(text); + } _ if self.mapping.target_model.supports_mapping_snapshot_id() => { control.show(); let text = self @@ -5269,11 +5231,11 @@ impl<'a> ImmutableMappingPanel<'a> { TargetCategory::Reaper => match self.reaper_target_type() { ReaperTargetType::ModifyMapping => Some("Pick!"), ReaperTargetType::SendMidi - if self.mapping.target_model.send_midi_destination_type() - == SendMidiDestinationType::InputDevice => - { - Some("Pick!") - } + if self.mapping.target_model.send_midi_destination_type() + == SendMidiDestinationType::InputDevice => + { + Some("Pick!") + } _ => None, }, TargetCategory::Virtual => None, @@ -5496,11 +5458,11 @@ impl<'a> ImmutableMappingPanel<'a> { ReaperTargetType::LoadMappingSnapshot => Some("Default"), ReaperTargetType::ModifyMapping => Some("Unit"), ReaperTargetType::SendMidi - if self.mapping.target_model.send_midi_destination_type() - == SendMidiDestinationType::InputDevice => - { - Some("Device") - } + if self.mapping.target_model.send_midi_destination_type() + == SendMidiDestinationType::InputDevice => + { + Some("Device") + } ReaperTargetType::PlaytimeColumnAction => Some("Column"), ReaperTargetType::PlaytimeRowAction => Some("Row"), ReaperTargetType::PlaytimeSlotManagementAction @@ -5571,17 +5533,17 @@ impl<'a> ImmutableMappingPanel<'a> { let text = match self.target_category() { TargetCategory::Reaper => match self.reaper_target_type() { ReaperTargetType::SendMidi - if self.mapping.target_model.send_midi_destination_type() - == SendMidiDestinationType::InputDevice => - { - let text = if let Some(dev_id) = self.target.midi_input_device() { - let dev = Reaper::get().midi_input_device_by_id(dev_id); - get_midi_input_device_list_label(dev) - } else { - SAME_AS_INPUT_DEV.to_string() - }; - Some(text) - } + if self.mapping.target_model.send_midi_destination_type() + == SendMidiDestinationType::InputDevice => + { + let text = if let Some(dev_id) = self.target.midi_input_device() { + let dev = Reaper::get().midi_input_device_by_id(dev_id); + get_midi_input_device_list_label(dev) + } else { + SAME_AS_INPUT_DEV.to_string() + }; + Some(text) + } ReaperTargetType::ModifyMapping => match self.target.mapping_ref() { MappingRefModel::OwnMapping { .. } => Some("".to_string()), MappingRefModel::ForeignMapping { session_id, .. } => { @@ -5893,22 +5855,22 @@ impl<'a> ImmutableMappingPanel<'a> { } t if t.supports_fx_parameter() && self.target.param_type() == VirtualFxParameterType::ById => - { - combo.show(); - let fx = get_relevant_target_fx(self.mapping, self.session); - if let Some(fx) = fx { - combo.fill_combo_box_indexed(fx_parameter_combo_box_entries(&fx)); - let param_index = self.target.param_index(); - combo - .select_combo_box_item_by_index_checked(param_index as _) - .unwrap_or_else(|_| { - let label = get_fx_param_label(None, param_index); - combo.select_new_combo_box_item(label.into_owned()); - }); - } else { - combo.select_only_combo_box_item(""); - } + { + combo.show(); + let fx = get_relevant_target_fx(self.mapping, self.session); + if let Some(fx) = fx { + combo.fill_combo_box_indexed(fx_parameter_combo_box_entries(&fx)); + let param_index = self.target.param_index(); + combo + .select_combo_box_item_by_index_checked(param_index as _) + .unwrap_or_else(|_| { + let label = get_fx_param_label(None, param_index); + combo.select_new_combo_box_item(label.into_owned()); + }); + } else { + combo.select_only_combo_box_item(""); } + } t if t.supports_track_exclusivity() => { combo.show(); combo.fill_combo_box_indexed(TrackExclusivity::iter()); @@ -6450,10 +6412,10 @@ impl<'a> ImmutableMappingPanel<'a> { { let step_min_is_relevant = real_target.is_some() && (is_relevant(ModeParameter::StepSizeMin) - || is_relevant(ModeParameter::StepFactorMin)); + || is_relevant(ModeParameter::StepFactorMin)); let step_max_is_relevant = real_target.is_some() && (is_relevant(ModeParameter::StepSizeMax) - || is_relevant(ModeParameter::StepFactorMax)); + || is_relevant(ModeParameter::StepFactorMax)); self.enable_if( step_min_is_relevant || step_max_is_relevant, &[root::ID_SETTINGS_STEP_SIZE_LABEL_TEXT], @@ -7027,7 +6989,8 @@ impl View for MappingPanel { .borrow_mut() .fill_with_window_children(window); let dyn_self: Rc = self.clone(); - self.mapping_header_panel.set_parent_view(Rc::downgrade(&dyn_self)); + self.mapping_header_panel + .set_parent_view(Rc::downgrade(&dyn_self)); true } @@ -7441,7 +7404,7 @@ impl WindowExt for Window { } fn group_mappings_by_virtual_control_element<'a>( - mappings: impl Iterator, + mappings: impl Iterator, ) -> NonCryptoHashMap> { let key_fn = |m: &SharedMapping| { let m = m.borrow(); @@ -7553,7 +7516,7 @@ fn get_text_right_to_step_size_edit_control( } } -fn track_combo_box_entries(project: Project) -> impl ExactSizeIterator { +fn track_combo_box_entries(project: Project) -> impl ExactSizeIterator { let mut current_folder_level: i32 = 0; project.tracks().enumerate().map(move |(i, track)| { let indentation = ".".repeat(current_folder_level.unsigned_abs() as usize * 4); @@ -7565,7 +7528,7 @@ fn track_combo_box_entries(project: Project) -> impl ExactSizeIterator impl ExactSizeIterator + '_ { +fn fx_combo_box_entries(chain: &FxChain) -> impl ExactSizeIterator + '_ { chain .fxs() .enumerate() @@ -7589,7 +7552,7 @@ fn send_combo_box_entries(track: &Track, route_type: TrackRouteType) -> Vec impl ExactSizeIterator + '_ { +fn fx_parameter_combo_box_entries(fx: &Fx) -> impl ExactSizeIterator + '_ { fx.parameters() .map(|param| get_fx_param_label(Some(¶m), param.index()).to_string()) } @@ -7597,7 +7560,7 @@ fn fx_parameter_combo_box_entries(fx: &Fx) -> impl ExactSizeIterator impl Iterator { +) -> impl Iterator { project .bookmarks() .map(|b| (b, b.basic_info())) @@ -7685,28 +7648,28 @@ fn invalidate_target_line_4_expression_result( TargetCategory::Reaper => match target.target_type() { t if t.supports_fx_parameter() && target.param_type() == VirtualFxParameterType::Dynamic => - { - target - .with_context(context, compartment) - .first_fx() - .ok() - .and_then(|fx| { - target - .virtual_fx_parameter() - .and_then(|p| { - p.calculated_fx_parameter_index(context, compartment, &fx) - }) - .map(|i| i.to_string()) - }) - } + { + target + .with_context(context, compartment) + .first_fx() + .ok() + .and_then(|fx| { + target + .virtual_fx_parameter() + .and_then(|p| { + p.calculated_fx_parameter_index(context, compartment, &fx) + }) + .map(|i| i.to_string()) + }) + } t if t.supports_send() && target.route_selector_type() == TrackRouteSelectorType::Dynamic => - { - target - .track_route_selector() - .and_then(|p| p.calculated_route_index(context, compartment)) - .map(|i| i.to_string()) - } + { + target + .track_route_selector() + .and_then(|p| p.calculated_route_index(context, compartment)) + .map(|i| i.to_string()) + } _ => None, }, TargetCategory::Virtual => None, @@ -7783,7 +7746,7 @@ fn get_osc_arg_index_from_combo(combo: Window) -> Option { } } -fn osc_arg_indexes() -> impl Iterator { +fn osc_arg_indexes() -> impl Iterator { iter::once((-1isize, "-".to_string())).chain((0..9).map(|i| (i as isize, (i + 1).to_string()))) } diff --git a/swell-ui/src/units.rs b/swell-ui/src/units.rs index fa6d220ed..b7202b2c0 100644 --- a/swell-ui/src/units.rs +++ b/swell-ui/src/units.rs @@ -279,8 +279,8 @@ impl From for Rect { Self { left: value.left, top: value.top, - width: (value.right - value.left).abs() as _, - height: (value.bottom - value.top).abs() as _, + width: (value.right - value.left).unsigned_abs(), + height: (value.bottom - value.top).unsigned_abs(), } } } @@ -294,4 +294,4 @@ impl From for raw::RECT { bottom: value.bottom(), } } -} \ No newline at end of file +}