diff --git a/dialogs/src/base.rs b/dialogs/src/base.rs index 5dc64fd3c..9b263e2c6 100644 --- a/dialogs/src/base.rs +++ b/dialogs/src/base.rs @@ -203,7 +203,7 @@ impl<'a> Display for DialogScalingAsRustCode<'a> { } pub struct ScopedContext<'a> { - context: &'a mut Context, + pub(crate) context: &'a mut Context, scope: Option, } @@ -261,6 +261,10 @@ pub struct OsSpecificSettings { pub scaling: DialogScaling, } +pub fn rect(x: u32, y: u32, width: u32, height: u32) -> Rect { + Rect::new(x, y, width, height) +} + impl<'a> ScopedContext<'a> { pub fn default_dialog(&self) -> Dialog { self.context.default_dialog() diff --git a/dialogs/src/ext.rs b/dialogs/src/ext.rs index 901c7e7e3..cbfaefba5 100644 --- a/dialogs/src/ext.rs +++ b/dialogs/src/ext.rs @@ -1,5 +1,18 @@ use crate::base::*; +impl<'a> ScopedContext<'a> { + pub fn checkbox(&mut self, caption: Caption, id: &'static str, rect: Rect) -> Control { + use Style::*; + let fixed_rect = self.rect_flexible(Rect { height: 10, ..rect }); + control( + caption, + self.context.named_id(id), + SubControlKind::Button, + fixed_rect, + ) + BS_AUTOCHECKBOX + } +} + pub fn ok_button(id: Id, rect: Rect) -> Control { defpushbutton("OK", id, rect) } @@ -9,13 +22,6 @@ pub fn dropdown(id: Id, rect: Rect) -> Control { combobox(id, rect) + CBS_DROPDOWNLIST + CBS_HASSTRINGS } -pub fn checkbox(caption: Caption, id: Id, rect: Rect) -> Control { - use Style::*; - // TODO-high This fixes the already scaled height, but we should fix the source height! - // let fixed_rect = Rect { height: 10, ..rect }; - control(caption, id, SubControlKind::Button, rect) + BS_AUTOCHECKBOX -} - pub fn slider(id: Id, rect: Rect) -> Control { use Style::*; control("", id, SubControlKind::msctls_trackbar32, rect) + TBS_BOTH + TBS_NOTICKS diff --git a/dialogs/src/header_panel.rs b/dialogs/src/header_panel.rs index 7ebe00e45..16246b693 100644 --- a/dialogs/src/header_panel.rs +++ b/dialogs/src/header_panel.rs @@ -51,15 +51,15 @@ pub fn create(mut context: ScopedContext) -> Dialog { context.named_id("ID_LET_THROUGH_LABEL_TEXT"), context.rect(270, 26, 39, 9), ), - checkbox( + context.checkbox( "Matched events", - context.named_id("ID_LET_MATCHED_EVENTS_THROUGH_CHECK_BOX"), - context.rect(319, 26, 67, 8), + "ID_LET_MATCHED_EVENTS_THROUGH_CHECK_BOX", + rect(319, 26, 67, 8), ) + WS_TABSTOP, - checkbox( + context.checkbox( "Unmatched events", - context.named_id("ID_LET_UNMATCHED_EVENTS_THROUGH_CHECK_BOX"), - context.rect(392, 26, 76, 8), + "ID_LET_UNMATCHED_EVENTS_THROUGH_CHECK_BOX", + rect(392, 26, 76, 8), ) + WS_TABSTOP, ]; let show_controls = [ diff --git a/dialogs/src/mapping_panel.rs b/dialogs/src/mapping_panel.rs index 5de9db540..9a7042945 100644 --- a/dialogs/src/mapping_panel.rs +++ b/dialogs/src/mapping_panel.rs @@ -13,10 +13,10 @@ pub fn create(mut context: ScopedContext) -> Dialog { ) + CBS_DROPDOWNLIST + CBS_HASSTRINGS + WS_TABSTOP, - checkbox( + context.checkbox( "Show in projection", - context.named_id("ID_MAPPING_SHOW_IN_PROJECTION_CHECK_BOX"), - context.rect(180, 53, 74, 8), + "ID_MAPPING_SHOW_IN_PROJECTION_CHECK_BOX", + rect(180, 53, 74, 8), ) + WS_GROUP + WS_TABSTOP, pushbutton( @@ -80,11 +80,7 @@ pub fn create(mut context: ScopedContext) -> Dialog { context.named_id("ID_SOURCE_NOTE_OR_CC_NUMBER_LABEL_TEXT"), context.rect(11, 158, 34, 9), ) + NOT_WS_GROUP, - checkbox( - "RPN", - context.named_id("ID_SOURCE_RPN_CHECK_BOX"), - context.rect(48, 158, 30, 8), - ) + WS_TABSTOP, + context.checkbox("RPN", "ID_SOURCE_RPN_CHECK_BOX", rect(48, 158, 30, 8)) + WS_TABSTOP, dropdown( context.named_id("ID_SOURCE_LINE_4_COMBO_BOX_1"), context.rect(47, 156, 26, 15), @@ -116,10 +112,10 @@ pub fn create(mut context: ScopedContext) -> Dialog { context.named_id("ID_SOURCE_LINE_5_EDIT_CONTROL"), context.rect(48, 176, 120, 14), ) + ES_AUTOHSCROLL, - checkbox( + context.checkbox( "14-bit values", - context.named_id("ID_SOURCE_14_BIT_CHECK_BOX"), - context.rect(47, 192, 56, 8), + "ID_SOURCE_14_BIT_CHECK_BOX", + rect(47, 192, 56, 8), ) + WS_TABSTOP, ltext( "Address", @@ -274,35 +270,35 @@ pub fn create(mut context: ScopedContext) -> Dialog { context.named_id("ID_TARGET_LINE_5_EDIT_CONTROL"), context.rect(282, 175, 127, 14), ) + ES_AUTOHSCROLL, - checkbox( + context.checkbox( "Monitoring FX", - context.named_id("ID_TARGET_CHECK_BOX_1"), - context.rect(181, 175, 68, 8), + "ID_TARGET_CHECK_BOX_1", + rect(181, 175, 68, 8), ) + WS_TABSTOP, - checkbox( + context.checkbox( "Track must be selected", - context.named_id("ID_TARGET_CHECK_BOX_2"), - context.rect(255, 175, 101, 8), + "ID_TARGET_CHECK_BOX_2", + rect(255, 175, 101, 8), ) + WS_TABSTOP, - checkbox( + context.checkbox( "FX must have focus", - context.named_id("ID_TARGET_CHECK_BOX_3"), - context.rect(363, 175, 76, 8), + "ID_TARGET_CHECK_BOX_3", + rect(363, 175, 76, 8), ) + WS_TABSTOP, - checkbox( + context.checkbox( "Monitoring FX", - context.named_id("ID_TARGET_CHECK_BOX_4"), - context.rect(181, 195, 69, 8), + "ID_TARGET_CHECK_BOX_4", + rect(181, 195, 69, 8), ) + WS_TABSTOP, - checkbox( + context.checkbox( "Track must be selected", - context.named_id("ID_TARGET_CHECK_BOX_5"), - context.rect(255, 195, 101, 8), + "ID_TARGET_CHECK_BOX_5", + rect(255, 195, 101, 8), ) + WS_TABSTOP, - checkbox( + context.checkbox( "FX must have focus", - context.named_id("ID_TARGET_CHECK_BOX_6"), - context.rect(363, 195, 76, 8), + "ID_TARGET_CHECK_BOX_6", + rect(363, 195, 76, 8), ) + WS_TABSTOP, ltext( "Value", @@ -458,10 +454,10 @@ pub fn create(mut context: ScopedContext) -> Dialog { context.rect(379, 291, 56, 9), ) + SS_WORDELLIPSIS + NOT_WS_GROUP, - checkbox( + context.checkbox( "Reverse", - context.named_id("ID_SETTINGS_REVERSE_CHECK_BOX"), - context.rect(400, 307, 39, 8), + "ID_SETTINGS_REVERSE_CHECK_BOX", + rect(400, 307, 39, 8), ) + WS_TABSTOP, dropdown( context.named_id("IDC_MODE_FEEDBACK_TYPE_COMBO_BOX"), @@ -548,10 +544,10 @@ pub fn create(mut context: ScopedContext) -> Dialog { context.named_id("ID_MODE_TAKEOVER_MODE"), context.rect(53, 407, 86, 15), ) + WS_TABSTOP, - checkbox( + context.checkbox( "Round target value", - context.named_id("ID_SETTINGS_ROUND_TARGET_VALUE_CHECK_BOX"), - context.rect(146, 409, 73, 8), + "ID_SETTINGS_ROUND_TARGET_VALUE_CHECK_BOX", + rect(146, 409, 73, 8), ) + WS_TABSTOP, ltext( "Control transformation (EEL)", @@ -619,15 +615,15 @@ pub fn create(mut context: ScopedContext) -> Dialog { context.named_id("ID_MODE_RELATIVE_FILTER_COMBO_BOX"), context.rect(231, 388, 104, 15), ) + WS_TABSTOP, - checkbox( + context.checkbox( "Wrap", - context.named_id("ID_SETTINGS_ROTATE_CHECK_BOX"), - context.rect(342, 391, 30, 8), + "ID_SETTINGS_ROTATE_CHECK_BOX", + rect(342, 391, 30, 8), ) + WS_TABSTOP, - checkbox( + context.checkbox( "Make absolute", - context.named_id("ID_SETTINGS_MAKE_ABSOLUTE_CHECK_BOX"), - context.rect(375, 391, 60, 8), + "ID_SETTINGS_MAKE_ABSOLUTE_CHECK_BOX", + rect(375, 391, 60, 8), ) + WS_TABSTOP, groupbox( "For buttons (control only)", @@ -714,10 +710,10 @@ pub fn create(mut context: ScopedContext) -> Dialog { context.named_id("ID_MAPPING_PANEL_OK"), context.rect(201, 514, 50, 14), ), - checkbox( + context.checkbox( "Enabled", - context.named_id("IDC_MAPPING_ENABLED_CHECK_BOX"), - context.rect(405, 516, 39, 10), + "IDC_MAPPING_ENABLED_CHECK_BOX", + rect(405, 516, 39, 10), ) + WS_TABSTOP, ]; Dialog { diff --git a/dialogs/src/mapping_row_panel.rs b/dialogs/src/mapping_row_panel.rs index aeeab390a..d645dfc2f 100644 --- a/dialogs/src/mapping_row_panel.rs +++ b/dialogs/src/mapping_row_panel.rs @@ -10,11 +10,7 @@ pub fn create(mut context: ScopedContext) -> Dialog { context.named_id("ID_MAPPING_ROW_MAPPING_LABEL"), context.rect(14, 3, 225, 9), ) + NOT_WS_GROUP, - checkbox( - "", - context.named_id("IDC_MAPPING_ROW_ENABLED_CHECK_BOX"), - context.rect(2, 2, 10, 10), - ) + WS_GROUP, + context.checkbox("", "IDC_MAPPING_ROW_ENABLED_CHECK_BOX", rect(2, 2, 10, 10)) + WS_GROUP, // Mapping actions pushbutton( "Edit", @@ -43,15 +39,15 @@ pub fn create(mut context: ScopedContext) -> Dialog { context.rect(394, 28, 53, 14), ) + NOT_WS_TABSTOP, // Control/feedback checkboxes - checkbox( + context.checkbox( "=>", - context.named_id("ID_MAPPING_ROW_CONTROL_CHECK_BOX"), - context.rect(138, 15, 24, 8), + "ID_MAPPING_ROW_CONTROL_CHECK_BOX", + rect(138, 15, 24, 8), ), - checkbox( + context.checkbox( "<=", - context.named_id("ID_MAPPING_ROW_FEEDBACK_CHECK_BOX"), - context.rect(138, 30, 24, 8), + "ID_MAPPING_ROW_FEEDBACK_CHECK_BOX", + rect(138, 30, 24, 8), ), // Source and target labels ctext( diff --git a/dialogs/src/shared_group_mapping_panel.rs b/dialogs/src/shared_group_mapping_panel.rs index b781f1736..8deb17be8 100644 --- a/dialogs/src/shared_group_mapping_panel.rs +++ b/dialogs/src/shared_group_mapping_panel.rs @@ -30,15 +30,15 @@ pub fn create(mut context: ScopedContext) -> Dialog { ) + ES_MULTILINE + ES_AUTOHSCROLL, // Control/feedback checkboxes - checkbox( + context.checkbox( "=> Control", - context.named_id("ID_MAPPING_CONTROL_ENABLED_CHECK_BOX"), - context.rect(col_1_x + 325, line_1_y + 3, 50, 8), + "ID_MAPPING_CONTROL_ENABLED_CHECK_BOX", + rect(col_1_x + 325, line_1_y + 3, 50, 8), ) + WS_TABSTOP, - checkbox( + context.checkbox( "<= Feedback", - context.named_id("ID_MAPPING_FEEDBACK_ENABLED_CHECK_BOX"), - context.rect(col_1_x + 376, line_1_y + 3, 56, 8), + "ID_MAPPING_FEEDBACK_ENABLED_CHECK_BOX", + rect(col_1_x + 376, line_1_y + 3, 56, 8), ) + WS_TABSTOP, // Conditional activation ltext( @@ -61,10 +61,10 @@ pub fn create(mut context: ScopedContext) -> Dialog { context.rect(col_1_x + 177, line_2_y, 90, 15), ) + WS_VSCROLL + WS_TABSTOP, - checkbox( + context.checkbox( "", - context.named_id("ID_MAPPING_ACTIVATION_SETTING_1_CHECK_BOX"), - context.rect(col_1_x + 271, line_2_y + 2, 11, 8), + "ID_MAPPING_ACTIVATION_SETTING_1_CHECK_BOX", + rect(col_1_x + 271, line_2_y + 2, 11, 8), ) + WS_TABSTOP, // Conditional activation criteria 2 ltext( @@ -77,10 +77,10 @@ pub fn create(mut context: ScopedContext) -> Dialog { context.rect(col_1_x + 325, line_2_y, 90, 15), ) + WS_VSCROLL + WS_TABSTOP, - checkbox( + context.checkbox( "", - context.named_id("ID_MAPPING_ACTIVATION_SETTING_2_CHECK_BOX"), - context.rect(col_1_x + 419, line_2_y + 2, 11, 8), + "ID_MAPPING_ACTIVATION_SETTING_2_CHECK_BOX", + rect(col_1_x + 419, line_2_y + 2, 11, 8), ) + WS_TABSTOP, ltext( "EEL (e.g. y = p1 > 0)",