Skip to content

Commit

Permalink
#593 Make checkbox heights always the same
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Jun 12, 2022
1 parent 3ccac02 commit 21b767b
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 81 deletions.
6 changes: 5 additions & 1 deletion dialogs/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Scope>,
}

Expand Down Expand Up @@ -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()
Expand Down
20 changes: 13 additions & 7 deletions dialogs/src/ext.rs
Original file line number Diff line number Diff line change
@@ -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)
}
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions dialogs/src/header_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
84 changes: 40 additions & 44 deletions dialogs/src/mapping_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 7 additions & 11 deletions dialogs/src/mapping_row_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down
24 changes: 12 additions & 12 deletions dialogs/src/shared_group_mapping_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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)",
Expand Down

0 comments on commit 21b767b

Please sign in to comment.