Struct exposed to .60 as struct need to be layed out in alphabetical order

because that's the order in which the C++ code generator pass the argument
to the agregate initialization
This commit is contained in:
Olivier Goffart 2021-09-03 17:52:03 +02:00 committed by Olivier Goffart
parent dedc9b3b9b
commit 619ce6c4f7
3 changed files with 12 additions and 14 deletions

View file

@ -379,10 +379,10 @@ using cbindgen_private::sixtyfps_solve_path_layout;
inline LayoutInfo LayoutInfo::merge(const LayoutInfo &other) const
{
// Note: This "logic" is duplicated from LayoutInfo::merge in layout.rs.
return LayoutInfo { std::max(min, other.min),
std::min(max, other.max),
std::max(min_percent, other.min_percent),
return LayoutInfo { std::min(max, other.max),
std::min(max_percent, other.max_percent),
std::max(min, other.min),
std::max(min_percent, other.min_percent),
std::max(preferred, other.preferred),
std::min(stretch, other.stretch) };
}

View file

@ -198,10 +198,10 @@ pub struct KeyboardModifiers {
pub alt: bool,
/// Indicates the control key on a keyboard.
pub control: bool,
/// Indicates the shift key on a keyboard.
pub shift: bool,
/// Indicates the logo key on macOS and the windows key on Windows.
pub meta: bool,
/// Indicates the shift key on a keyboard.
pub shift: bool,
}
#[derive(Debug, Clone, PartialEq, strum_macros::EnumString, strum_macros::Display)]
@ -224,10 +224,10 @@ impl Default for KeyEventType {
#[derive(Debug, Clone, PartialEq, Default)]
#[repr(C)]
pub struct KeyEvent {
/// The unicode representation of the key pressed.
pub text: SharedString,
/// The keyboard modifiers active at the time of the key press event.
pub modifiers: KeyboardModifiers,
/// The unicode representation of the key pressed.
pub text: SharedString,
/// Indicates whether the key was pressed or released
pub event_type: KeyEventType,
}

View file

@ -25,22 +25,20 @@ type Coord = f32;
/// The constraint that applies to an item
// NOTE: when adding new fields, the C++ operator== also need updates
// Also, the field needs to be in alphabetical order because how the generated code sort fields for struct
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct LayoutInfo {
/// The minimum size for this item.
pub min: f32,
/// The maximum size for the item.
pub max: f32,
/// The minimum size in percentage of the parent (value between 0 and 100).
pub min_percent: f32,
/// The maximum size in percentage of the parent (value between 0 and 100).
pub max_percent: f32,
/// The minimum size for this item.
pub min: f32,
/// The minimum size in percentage of the parent (value between 0 and 100).
pub min_percent: f32,
/// the preferred size
pub preferred: f32,
/// the stretch factor
pub stretch: f32,
}