Skip to content

Commit

Permalink
#160 Finish revising target line 2 (e.g. track) structure
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Mar 8, 2021
1 parent b58a1d2 commit ec0c218
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 10 deletions.
1 change: 1 addition & 0 deletions main/src/infrastructure/ui/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub mod root {
pub const ID_MAIN_PANEL_VERSION_TEXT: u32 = 40000;
pub const ID_MAPPING_ROW_REMOVE_BUTTON: u32 = 40000;
pub const ID_MESSAGE_TEXT: u32 = 40000;
pub const ID_TARGET_LINE_2_EDIT_CONTROL: u32 = 40000;
pub const ID_YAML_EDIT_INFO_TEXT: u32 = 40000;
pub const IDM_BUTTONS: u32 = 40001;
pub const IDM_SERVER_START: u32 = 40001;
Expand Down
84 changes: 76 additions & 8 deletions main/src/infrastructure/ui/mapping_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,18 @@ impl<'a> MutableMappingPanel<'a> {
t if t.supports_track() => {
let project = self.session.context().project_or_current_project();
let i = combo.selected_combo_box_item_index();
let guid = project.track_by_index(i as _).map(|t| *t.guid());
self.mapping.target_model.track_id.set(guid);
if let Some(track) = project.track_by_index(i as _) {
self.mapping.target_model.track_id.set(Some(*track.guid()));
// We also set index and name so that we can easily switch between types.
self.mapping
.target_model
.track_index
.set_without_notification(i as _);
self.mapping
.target_model
.track_name
.set_without_notification(track.name().unwrap().into_string());
}
}
_ => {}
},
Expand All @@ -1098,6 +1108,33 @@ impl<'a> MutableMappingPanel<'a> {
}
}

fn handle_target_line_2_edit_control_change(&mut self) {
let control = self
.view
.require_control(root::ID_TARGET_LINE_2_EDIT_CONTROL);
match self.target_category() {
TargetCategory::Reaper => match self.reaper_target_type() {
t if t.supports_track() => match self.mapping.target_model.track_type.get() {
VirtualTrackType::ByName => {
let name = control.text().unwrap_or_default();
self.mapping.target_model.track_name.set(name);
}
VirtualTrackType::ByIndex => {
let index = control
.text()
.unwrap_or_default()
.parse()
.unwrap_or_default();
self.mapping.target_model.track_index.set(index);
}
_ => {}
},
_ => {}
},
TargetCategory::Virtual => {}
}
}

fn target_category(&self) -> TargetCategory {
self.mapping.target_model.category.get()
}
Expand Down Expand Up @@ -1775,11 +1812,40 @@ impl<'a> ImmutableMappingPanel<'a> {
}
}

fn invalidate_target_line_2_edit_control(&self) {
let control = self
.view
.require_control(root::ID_TARGET_LINE_2_EDIT_CONTROL);
match self.target_category() {
TargetCategory::Reaper => match self.reaper_target_type() {
t if t.supports_track() => {
let text = match self.target.track_type.get() {
VirtualTrackType::ByIndex => self.target.track_index.get().to_string(),
VirtualTrackType::ByName => self.target.track_name.get_ref().clone(),
_ => {
control.hide();
return;
}
};
control.set_text_if_not_focused(text);
control.show();
}
_ => {
control.hide();
}
},
TargetCategory::Virtual => {
control.hide();
}
}
}

fn invalidate_target_line_2(&self) {
self.invalidate_target_line_2_label_1();
self.invalidate_target_line_2_label_2();
self.invalidate_target_line_2_combo_box_1();
self.invalidate_target_line_2_combo_box_2();
self.invalidate_target_line_2_edit_control();
self.invalidate_target_line_2_button();
}

Expand Down Expand Up @@ -3245,24 +3311,26 @@ impl View for MappingPanel {
// max value would "fix" a previously entered min value too soon.
self
};
use root::*;
match resource_id {
// Source
ID_SOURCE_NUMBER_EDIT_CONTROL => {
root::ID_SOURCE_NUMBER_EDIT_CONTROL => {
view.write(|p| p.update_source_parameter_number_message_number());
}
ID_SOURCE_OSC_ADDRESS_PATTERN_EDIT_CONTROL => {
root::ID_SOURCE_OSC_ADDRESS_PATTERN_EDIT_CONTROL => {
view.write(|p| p.update_source_pattern());
}
// Mode
ID_MODE_EEL_CONTROL_TRANSFORMATION_EDIT_CONTROL => {
root::ID_MODE_EEL_CONTROL_TRANSFORMATION_EDIT_CONTROL => {
view.write(|p| p.update_mode_eel_control_transformation());
}
ID_MODE_EEL_FEEDBACK_TRANSFORMATION_EDIT_CONTROL => {
root::ID_MODE_EEL_FEEDBACK_TRANSFORMATION_EDIT_CONTROL => {
view.write(|p| p.update_mode_eel_feedback_transformation());
}
// Target
ID_TARGET_VALUE_EDIT_CONTROL => {
root::ID_TARGET_LINE_2_EDIT_CONTROL => {
view.write(|p| p.handle_target_line_2_edit_control_change())
}
root::ID_TARGET_VALUE_EDIT_CONTROL => {
let (target, value) = view.write(|p| {
let value = p
.get_value_from_target_edit_control(root::ID_TARGET_VALUE_EDIT_CONTROL)
Expand Down
1 change: 1 addition & 0 deletions main/src/infrastructure/ui/realearn.rc
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ BEGIN
LTEXT "Parameter", ID_TARGET_SNAPSHOT_NAME, 220, 158, 158, 9, NOT WS_GROUP | SS_LEFT, WS_EX_LEFT
LTEXT "Address", ID_SOURCE_OSC_ADDRESS_LABEL_TEXT, 11, 201, 30, 9, NOT WS_GROUP | SS_LEFT, WS_EX_LEFT
COMBOBOX ID_TARGET_LINE_2_COMBO_BOX_1, 220, 116, 58, 30, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
EDITTEXT ID_TARGET_LINE_2_EDIT_CONTROL, 282, 115, 127, 14, ES_AUTOHSCROLL, WS_EX_LEFT
END


Expand Down
5 changes: 3 additions & 2 deletions main/src/infrastructure/ui/realearn.rc_mac_dlg
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ SWELL_DEFINE_DIALOG_RESOURCE_END(ID_MAIN_PANEL)
#endif
SWELL_DEFINE_DIALOG_RESOURCE_BEGIN(ID_MAPPING_PANEL,SET_ID_MAPPING_PANEL_STYLE,"Edit mapping",451,480,SET_ID_MAPPING_PANEL_SCALE)
BEGIN
COMBOBOX ID_TARGET_LINE_2_COMBO_BOX_2, 284, 116, 154, 30, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
PUSHBUTTON "Pick", ID_TARGET_LINE_2_BUTTON, 412, 114, 26, 14, 0, WS_EX_LEFT
LTEXT "Action name", ID_TARGET_LINE_2_LABEL_2, 220, 118, 189, 9, NOT WS_GROUP | SS_LEFT, WS_EX_LEFT
COMBOBOX ID_TARGET_LINE_2_COMBO_BOX_2, 283, 116, 155, 30, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
PUSHBUTTON "Pick", ID_TARGET_LINE_2_BUTTON, 412, 114, 26, 14, 0, WS_EX_LEFT
AUTOCHECKBOX "Prevent echo feedback", ID_MAPPING_PREVENT_ECHO_FEEDBACK_CHECK_BOX, 11, 54, 91, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Send feedback after control", ID_MAPPING_SEND_FEEDBACK_AFTER_CONTROL_CHECK_BOX, 109, 54, 104, 8, 0, WS_EX_LEFT
PUSHBUTTON "Advanced settings", ID_MAPPING_ADVANCED_BUTTON, 259, 50, 87, 14, 0, WS_EX_LEFT
Expand Down Expand Up @@ -206,6 +206,7 @@ LTEXT "Max", 0, 266, 437, 14, 9, NOT WS_GROUP | SS_LEFT, WS_EX_LEFT
LTEXT "Parameter", ID_TARGET_SNAPSHOT_NAME, 220, 158, 158, 9, NOT WS_GROUP | SS_LEFT, WS_EX_LEFT
LTEXT "Address", ID_SOURCE_OSC_ADDRESS_LABEL_TEXT, 11, 201, 30, 9, NOT WS_GROUP | SS_LEFT, WS_EX_LEFT
COMBOBOX ID_TARGET_LINE_2_COMBO_BOX_1, 220, 116, 58, 30, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
EDITTEXT ID_TARGET_LINE_2_EDIT_CONTROL, 282, 115, 127, 14, ES_AUTOHSCROLL, WS_EX_LEFT
END
SWELL_DEFINE_DIALOG_RESOURCE_END(ID_MAPPING_PANEL)

Expand Down
1 change: 1 addition & 0 deletions main/src/infrastructure/ui/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define ID_MAIN_PANEL_VERSION_TEXT 40000
#define ID_MAPPING_ROW_REMOVE_BUTTON 40000
#define ID_MESSAGE_TEXT 40000
#define ID_TARGET_LINE_2_EDIT_CONTROL 40000
#define ID_YAML_EDIT_INFO_TEXT 40000
#define IDM_BUTTONS 40001
#define IDM_SERVER_START 40001
Expand Down

0 comments on commit ec0c218

Please sign in to comment.