aaand examples compile. complex trait bounds there...

This commit is contained in:
Jack Mac 2021-09-24 17:17:27 -04:00
parent 8b22856090
commit f743fefe79
5 changed files with 40 additions and 40 deletions

View File

@ -545,7 +545,7 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) {
ui.input_float3("input float3", &mut state.vec3f) ui.input_float3("input float3", &mut state.vec3f)
.build(); .build();
ColorEdit3::new("color 1", &mut state.col1).build(ui); ColorEdit3::new("color 1", &mut state.col1).build(ui);
ColorEdit3::new("color 2", &mut state.col2).build(ui); ColorEdit4::new("color 2", &mut state.col2).build(ui);
TreeNode::new("Multi-component Widgets").build(ui, || { TreeNode::new("Multi-component Widgets").build(ui, || {
ui.input_float2("input float2", &mut state.vec2f) ui.input_float2("input float2", &mut state.vec2f)
@ -601,19 +601,19 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) {
"Click on the colored square to open a color picker. "Click on the colored square to open a color picker.
CTRL+click on individual component to input value.\n", CTRL+click on individual component to input value.\n",
); );
ColorEdit3::new("MyColor##1", &mut s.color) ColorEdit4::new("MyColor##1", &mut s.color)
.flags(misc_flags) .flags(misc_flags)
.alpha(false) .alpha(false)
.build(ui); .build(ui);
ui.text("Color widget HSV with Alpha:"); ui.text("Color widget HSV with Alpha:");
ColorEdit3::new("MyColor##2", &mut s.color) ColorEdit4::new("MyColor##2", &mut s.color)
.flags(misc_flags) .flags(misc_flags)
.input_mode(ColorEditInputMode::HSV) .input_mode(ColorEditInputMode::HSV)
.build(ui); .build(ui);
ui.text("Color widget with Float Display:"); ui.text("Color widget with Float Display:");
ColorEdit3::new("MyColor##2f", &mut s.color) ColorEdit4::new("MyColor##2f", &mut s.color)
.flags(misc_flags) .flags(misc_flags)
.format(ColorFormat::Float) .format(ColorFormat::Float)
.build(ui); .build(ui);
@ -627,7 +627,7 @@ CTRL+click on individual component to input value.\n",
With the label(false) function you can pass a non-empty label which \ With the label(false) function you can pass a non-empty label which \
will only be used for the tooltip and picker popup.", will only be used for the tooltip and picker popup.",
); );
ColorEdit3::new("MyColor##3", &mut s.color) ColorEdit4::new("MyColor##3", &mut s.color)
.flags(misc_flags) .flags(misc_flags)
.inputs(false) .inputs(false)
.label(false) .label(false)
@ -642,13 +642,13 @@ CTRL+click on individual component to input value.\n",
ui.checkbox("With Ref Color", &mut s.ref_color); ui.checkbox("With Ref Color", &mut s.ref_color);
if s.ref_color { if s.ref_color {
ui.same_line(); ui.same_line();
ColorEdit3::new("##RefColor", &mut s.ref_color_v) ColorEdit4::new("##RefColor", &mut s.ref_color_v)
.flags(misc_flags) .flags(misc_flags)
.inputs(false) .inputs(false)
.build(ui); .build(ui);
} }
} }
let mut b = ColorPicker3::new let mut b = ColorPicker4::new
("MyColor##4", &mut s.color) ("MyColor##4", &mut s.color)
.flags(misc_flags) .flags(misc_flags)
.alpha(s.alpha) .alpha(s.alpha)
@ -657,7 +657,7 @@ CTRL+click on individual component to input value.\n",
.display_rgb(true); .display_rgb(true);
if s.ref_color { if s.ref_color {
b = b.reference_color(&s.ref_color_v) b = b.reference_color(s.ref_color_v)
} }
b.build(ui); b.build(ui);
}); });
@ -806,7 +806,7 @@ CTRL+click on individual component to input value.\n",
let items = &["aaaa", "bbbb", "cccc", "dddd", "eeee"]; let items = &["aaaa", "bbbb", "cccc", "dddd", "eeee"];
ui.combo_simple_string("Combo", &mut state.stacked_modals_item, items); ui.combo_simple_string("Combo", &mut state.stacked_modals_item, items);
ColorEdit3::new("color", &mut state.stacked_modals_color).build(ui); ColorEdit4::new("color", &mut state.stacked_modals_color).build(ui);
if ui.button("Add another modal..") { if ui.button("Add another modal..") {
ui.open_popup("Stacked 2") ; ui.open_popup("Stacked 2") ;

View File

@ -15,7 +15,7 @@ exclude = ["third-party/*.json", "third-party/*.lua", "third-party/imgui/*/"]
[dependencies] [dependencies]
chlorine = "1.0.7" chlorine = "1.0.7"
mint = "0.5" mint = "0.5.6"
[build-dependencies] [build-dependencies]
cc = "1.0" cc = "1.0"

View File

@ -553,9 +553,9 @@ impl<'ui, 'p, L: AsRef<str>> InputFloat<'ui, 'p, L> {
} }
macro_rules! impl_input_floatn { macro_rules! impl_input_floatn {
($InputFloatN:ident, $MINT_TARGET:ident, $N:expr, $igInputFloatN:ident) => { ($InputFloatN:ident, $MINT_TARGET:ty, $N:expr, $igInputFloatN:ident) => {
#[must_use] #[must_use]
pub struct $InputFloatN<'ui, 'p, L, T = [f32; $N]> { pub struct $InputFloatN<'ui, 'p, L, T> {
label: L, label: L,
value: &'p mut T, value: &'p mut T,
flags: InputTextFlags, flags: InputTextFlags,
@ -565,8 +565,8 @@ macro_rules! impl_input_floatn {
impl<'ui, 'p, L, T> $InputFloatN<'ui, 'p, L, T> impl<'ui, 'p, L, T> $InputFloatN<'ui, 'p, L, T>
where where
L: AsRef<str>, L: AsRef<str>,
T: From<$MINT_TARGET> + Copy, T: Copy + Into<$MINT_TARGET>,
$MINT_TARGET: From<T>, $MINT_TARGET: Into<T> + Into<[f32; $N]>,
{ {
pub fn new(ui: &'ui Ui<'ui>, label: L, value: &'p mut T) -> Self { pub fn new(ui: &'ui Ui<'ui>, label: L, value: &'p mut T) -> Self {
$InputFloatN { $InputFloatN {
@ -578,7 +578,7 @@ macro_rules! impl_input_floatn {
} }
pub fn build(self) -> bool { pub fn build(self) -> bool {
let value: $MINT_TARGET = $MINT_TARGET::from(*self.value); let value: $MINT_TARGET = (*self.value).into();
let mut value: [f32; $N] = value.into(); let mut value: [f32; $N] = value.into();
let changed = unsafe { let changed = unsafe {
@ -620,8 +620,8 @@ macro_rules! impl_input_intn {
impl<'ui, 'p, L, T> $InputIntN<'ui, 'p, L, T> impl<'ui, 'p, L, T> $InputIntN<'ui, 'p, L, T>
where where
L: AsRef<str>, L: AsRef<str>,
T: From<$MINT_TARGET> + Copy, T: Copy + Into<$MINT_TARGET>,
$MINT_TARGET: From<T>, $MINT_TARGET: Into<T> + Into<[i32; $N]>,
{ {
pub fn new(ui: &'ui Ui<'ui>, label: L, value: &'p mut T) -> Self { pub fn new(ui: &'ui Ui<'ui>, label: L, value: &'p mut T) -> Self {
$InputIntN { $InputIntN {
@ -633,7 +633,7 @@ macro_rules! impl_input_intn {
} }
pub fn build(self) -> bool { pub fn build(self) -> bool {
let value: $MINT_TARGET = $MINT_TARGET::from(*self.value); let value: $MINT_TARGET = (*self.value).into();
let mut value: [i32; $N] = value.into(); let mut value: [i32; $N] = value.into();
let changed = unsafe { let changed = unsafe {

View File

@ -397,8 +397,8 @@ impl<'ui> Ui<'ui> {
) -> InputFloat2<'ui, 'p, L, T> ) -> InputFloat2<'ui, 'p, L, T>
where where
L: AsRef<str>, L: AsRef<str>,
T: From<MintVec2> + Copy, T: Copy + Into<MintVec2>,
MintVec2: From<T>, MintVec2: Into<T> + Into<[f32; 2]>,
{ {
InputFloat2::new(self, label, value) InputFloat2::new(self, label, value)
} }
@ -410,8 +410,8 @@ impl<'ui> Ui<'ui> {
) -> InputFloat3<'ui, 'p, L, T> ) -> InputFloat3<'ui, 'p, L, T>
where where
L: AsRef<str>, L: AsRef<str>,
T: From<MintVec3> + Copy, T: Copy + Into<MintVec3>,
MintVec3: From<T>, MintVec3: Into<T> + Into<[f32; 3]>,
{ {
InputFloat3::new(self, label, value) InputFloat3::new(self, label, value)
} }
@ -423,8 +423,8 @@ impl<'ui> Ui<'ui> {
) -> InputFloat4<'ui, 'p, L, T> ) -> InputFloat4<'ui, 'p, L, T>
where where
L: AsRef<str>, L: AsRef<str>,
T: From<MintVec4> + Copy, T: Copy + Into<MintVec4>,
MintVec4: From<T>, MintVec4: Into<T> + Into<[f32; 4]>,
{ {
InputFloat4::new(self, label, value) InputFloat4::new(self, label, value)
} }
@ -440,8 +440,8 @@ impl<'ui> Ui<'ui> {
pub fn input_int2<'p, L, T>(&'ui self, label: L, value: &'p mut T) -> InputInt2<'ui, 'p, L, T> pub fn input_int2<'p, L, T>(&'ui self, label: L, value: &'p mut T) -> InputInt2<'ui, 'p, L, T>
where where
L: AsRef<str>, L: AsRef<str>,
T: From<MintIVec2> + Copy, T: Copy + Into<MintIVec2>,
MintIVec2: From<T>, MintIVec2: Into<T> + Into<[i32; 2]>,
{ {
InputInt2::new(self, label, value) InputInt2::new(self, label, value)
} }
@ -449,8 +449,8 @@ impl<'ui> Ui<'ui> {
pub fn input_int3<'p, L, T>(&'ui self, label: L, value: &'p mut T) -> InputInt3<'ui, 'p, L, T> pub fn input_int3<'p, L, T>(&'ui self, label: L, value: &'p mut T) -> InputInt3<'ui, 'p, L, T>
where where
L: AsRef<str>, L: AsRef<str>,
T: From<MintIVec3> + Copy, T: Copy + Into<MintIVec3>,
MintIVec3: From<T>, MintIVec3: Into<T> + Into<[i32; 3]>,
{ {
InputInt3::new(self, label, value) InputInt3::new(self, label, value)
} }
@ -458,8 +458,8 @@ impl<'ui> Ui<'ui> {
pub fn input_int4<'p, L, T>(&'ui self, label: L, value: &'p mut T) -> InputInt4<'ui, 'p, L, T> pub fn input_int4<'p, L, T>(&'ui self, label: L, value: &'p mut T) -> InputInt4<'ui, 'p, L, T>
where where
L: AsRef<str>, L: AsRef<str>,
T: From<MintIVec4> + Copy, T: Copy + Into<MintIVec4>,
MintIVec4: From<T>, MintIVec4: Into<T> + Into<[i32; 4]>,
{ {
InputInt4::new(self, label, value) InputInt4::new(self, label, value)
} }

View File

@ -195,8 +195,8 @@ pub struct ColorEdit3<'a, T, C> {
impl<'a, T, C> ColorEdit3<'a, T, C> impl<'a, T, C> ColorEdit3<'a, T, C>
where where
T: AsRef<str>, T: AsRef<str>,
MintVec3: From<C>, C: Copy + Into<MintVec3>,
C: From<MintVec3> + Copy, MintVec3: Into<C> + Into<[f32; 3]>,
{ {
/// Constructs a new color editor builder. /// Constructs a new color editor builder.
#[doc(alias = "ColorEdit3")] #[doc(alias = "ColorEdit3")]
@ -377,8 +377,8 @@ pub struct ColorEdit4<'a, T, C> {
impl<'a, T, C> ColorEdit4<'a, T, C> impl<'a, T, C> ColorEdit4<'a, T, C>
where where
T: AsRef<str>, T: AsRef<str>,
MintVec4: From<C>, C: Copy + Into<MintVec4>,
C: From<MintVec4> + Copy, MintVec4: Into<C> + Into<[f32; 4]>,
{ {
/// Constructs a new color editor builder. /// Constructs a new color editor builder.
#[doc(alias = "ColorEdit4")] #[doc(alias = "ColorEdit4")]
@ -556,8 +556,8 @@ pub struct ColorPicker3<'a, Label, Color> {
impl<'a, Label, Color> ColorPicker3<'a, Label, Color> impl<'a, Label, Color> ColorPicker3<'a, Label, Color>
where where
Label: AsRef<str>, Label: AsRef<str>,
MintVec3: From<Color>, Color: Copy + Into<MintVec3>,
Color: From<MintVec3> + Copy, MintVec3: Into<Color> + Into<[f32; 3]>,
{ {
/// Constructs a new color picker builder. /// Constructs a new color picker builder.
#[doc(alias = "ColorPicker3")] #[doc(alias = "ColorPicker3")]
@ -696,7 +696,7 @@ where
/// Returns true if the color value was changed. /// Returns true if the color value was changed.
pub fn build(mut self, ui: &Ui<'_>) -> bool { pub fn build(mut self, ui: &Ui<'_>) -> bool {
self.flags.insert(ColorEditFlags::NO_ALPHA); self.flags.insert(ColorEditFlags::NO_ALPHA);
let mut value: [f32; 3] = MintVec3::from(*self.value).into(); let mut value: [f32; 3] = (*self.value).into().into();
let changed = unsafe { let changed = unsafe {
sys::igColorPicker3( sys::igColorPicker3(
ui.scratch_txt(self.label), ui.scratch_txt(self.label),
@ -741,8 +741,8 @@ pub struct ColorPicker4<'a, Label, Color> {
impl<'a, Label, Color> ColorPicker4<'a, Label, Color> impl<'a, Label, Color> ColorPicker4<'a, Label, Color>
where where
Label: AsRef<str>, Label: AsRef<str>,
MintVec4: From<Color>, Color: Copy + Into<MintVec4>,
Color: From<MintVec4> + Copy, MintVec4: Into<Color> + Into<[f32; 4]>,
{ {
/// Constructs a new color picker builder. /// Constructs a new color picker builder.
#[doc(alias = "ColorPicker4")] #[doc(alias = "ColorPicker4")]
@ -888,7 +888,7 @@ where
/// Returns true if the color value was changed. /// Returns true if the color value was changed.
pub fn build(mut self, ui: &Ui<'_>) -> bool { pub fn build(mut self, ui: &Ui<'_>) -> bool {
self.flags.insert(ColorEditFlags::NO_ALPHA); self.flags.insert(ColorEditFlags::NO_ALPHA);
let mut value: [f32; 4] = MintVec4::from(*self.value).into(); let mut value: [f32; 4] = (*self.value).into().into();
let ref_color = self.ref_color.map(|c| c.as_ptr()).unwrap_or(ptr::null()); let ref_color = self.ref_color.map(|c| c.as_ptr()).unwrap_or(ptr::null());
let changed = unsafe { let changed = unsafe {