Skip to content

Commit

Permalink
aaand examples compile. complex trait bounds there...
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbox-irl committed Sep 30, 2021
1 parent 8b22856 commit f743fef
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 40 deletions.
18 changes: 9 additions & 9 deletions imgui-examples/examples/test_window_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) {
ui.input_float3("input float3", &mut state.vec3f)
.build();
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, || {
ui.input_float2("input float2", &mut state.vec2f)
Expand Down Expand Up @@ -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.
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)
.alpha(false)
.build(ui);

ui.text("Color widget HSV with Alpha:");
ColorEdit3::new("MyColor##2", &mut s.color)
ColorEdit4::new("MyColor##2", &mut s.color)
.flags(misc_flags)
.input_mode(ColorEditInputMode::HSV)
.build(ui);

ui.text("Color widget with Float Display:");
ColorEdit3::new("MyColor##2f", &mut s.color)
ColorEdit4::new("MyColor##2f", &mut s.color)
.flags(misc_flags)
.format(ColorFormat::Float)
.build(ui);
Expand All @@ -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 \
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)
.inputs(false)
.label(false)
Expand All @@ -642,13 +642,13 @@ CTRL+click on individual component to input value.\n",
ui.checkbox("With Ref Color", &mut s.ref_color);
if s.ref_color {
ui.same_line();
ColorEdit3::new("##RefColor", &mut s.ref_color_v)
ColorEdit4::new("##RefColor", &mut s.ref_color_v)
.flags(misc_flags)
.inputs(false)
.build(ui);
}
}
let mut b = ColorPicker3::new
let mut b = ColorPicker4::new
("MyColor##4", &mut s.color)
.flags(misc_flags)
.alpha(s.alpha)
Expand All @@ -657,7 +657,7 @@ CTRL+click on individual component to input value.\n",
.display_rgb(true);

if s.ref_color {
b = b.reference_color(&s.ref_color_v)
b = b.reference_color(s.ref_color_v)
}
b.build(ui);
});
Expand Down Expand Up @@ -806,7 +806,7 @@ CTRL+click on individual component to input value.\n",
let items = &["aaaa", "bbbb", "cccc", "dddd", "eeee"];
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..") {
ui.open_popup("Stacked 2") ;
Expand Down
2 changes: 1 addition & 1 deletion imgui-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exclude = ["third-party/*.json", "third-party/*.lua", "third-party/imgui/*/"]

[dependencies]
chlorine = "1.0.7"
mint = "0.5"
mint = "0.5.6"

[build-dependencies]
cc = "1.0"
Expand Down
16 changes: 8 additions & 8 deletions imgui/src/input_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,9 @@ impl<'ui, 'p, L: AsRef<str>> InputFloat<'ui, 'p, L> {
}

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]
pub struct $InputFloatN<'ui, 'p, L, T = [f32; $N]> {
pub struct $InputFloatN<'ui, 'p, L, T> {
label: L,
value: &'p mut T,
flags: InputTextFlags,
Expand All @@ -565,8 +565,8 @@ macro_rules! impl_input_floatn {
impl<'ui, 'p, L, T> $InputFloatN<'ui, 'p, L, T>
where
L: AsRef<str>,
T: From<$MINT_TARGET> + Copy,
$MINT_TARGET: From<T>,
T: Copy + Into<$MINT_TARGET>,
$MINT_TARGET: Into<T> + Into<[f32; $N]>,
{
pub fn new(ui: &'ui Ui<'ui>, label: L, value: &'p mut T) -> Self {
$InputFloatN {
Expand All @@ -578,7 +578,7 @@ macro_rules! impl_input_floatn {
}

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 changed = unsafe {
Expand Down Expand Up @@ -620,8 +620,8 @@ macro_rules! impl_input_intn {
impl<'ui, 'p, L, T> $InputIntN<'ui, 'p, L, T>
where
L: AsRef<str>,
T: From<$MINT_TARGET> + Copy,
$MINT_TARGET: From<T>,
T: Copy + Into<$MINT_TARGET>,
$MINT_TARGET: Into<T> + Into<[i32; $N]>,
{
pub fn new(ui: &'ui Ui<'ui>, label: L, value: &'p mut T) -> Self {
$InputIntN {
Expand All @@ -633,7 +633,7 @@ macro_rules! impl_input_intn {
}

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 changed = unsafe {
Expand Down
24 changes: 12 additions & 12 deletions imgui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ impl<'ui> Ui<'ui> {
) -> InputFloat2<'ui, 'p, L, T>
where
L: AsRef<str>,
T: From<MintVec2> + Copy,
MintVec2: From<T>,
T: Copy + Into<MintVec2>,
MintVec2: Into<T> + Into<[f32; 2]>,
{
InputFloat2::new(self, label, value)
}
Expand All @@ -410,8 +410,8 @@ impl<'ui> Ui<'ui> {
) -> InputFloat3<'ui, 'p, L, T>
where
L: AsRef<str>,
T: From<MintVec3> + Copy,
MintVec3: From<T>,
T: Copy + Into<MintVec3>,
MintVec3: Into<T> + Into<[f32; 3]>,
{
InputFloat3::new(self, label, value)
}
Expand All @@ -423,8 +423,8 @@ impl<'ui> Ui<'ui> {
) -> InputFloat4<'ui, 'p, L, T>
where
L: AsRef<str>,
T: From<MintVec4> + Copy,
MintVec4: From<T>,
T: Copy + Into<MintVec4>,
MintVec4: Into<T> + Into<[f32; 4]>,
{
InputFloat4::new(self, label, value)
}
Expand All @@ -440,26 +440,26 @@ impl<'ui> Ui<'ui> {
pub fn input_int2<'p, L, T>(&'ui self, label: L, value: &'p mut T) -> InputInt2<'ui, 'p, L, T>
where
L: AsRef<str>,
T: From<MintIVec2> + Copy,
MintIVec2: From<T>,
T: Copy + Into<MintIVec2>,
MintIVec2: Into<T> + Into<[i32; 2]>,
{
InputInt2::new(self, label, value)
}
#[doc(alias = "InputInt3")]
pub fn input_int3<'p, L, T>(&'ui self, label: L, value: &'p mut T) -> InputInt3<'ui, 'p, L, T>
where
L: AsRef<str>,
T: From<MintIVec3> + Copy,
MintIVec3: From<T>,
T: Copy + Into<MintIVec3>,
MintIVec3: Into<T> + Into<[i32; 3]>,
{
InputInt3::new(self, label, value)
}
#[doc(alias = "InputInt4")]
pub fn input_int4<'p, L, T>(&'ui self, label: L, value: &'p mut T) -> InputInt4<'ui, 'p, L, T>
where
L: AsRef<str>,
T: From<MintIVec4> + Copy,
MintIVec4: From<T>,
T: Copy + Into<MintIVec4>,
MintIVec4: Into<T> + Into<[i32; 4]>,
{
InputInt4::new(self, label, value)
}
Expand Down
20 changes: 10 additions & 10 deletions imgui/src/widget/color_editors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ pub struct ColorEdit3<'a, T, C> {
impl<'a, T, C> ColorEdit3<'a, T, C>
where
T: AsRef<str>,
MintVec3: From<C>,
C: From<MintVec3> + Copy,
C: Copy + Into<MintVec3>,
MintVec3: Into<C> + Into<[f32; 3]>,
{
/// Constructs a new color editor builder.
#[doc(alias = "ColorEdit3")]
Expand Down Expand Up @@ -377,8 +377,8 @@ pub struct ColorEdit4<'a, T, C> {
impl<'a, T, C> ColorEdit4<'a, T, C>
where
T: AsRef<str>,
MintVec4: From<C>,
C: From<MintVec4> + Copy,
C: Copy + Into<MintVec4>,
MintVec4: Into<C> + Into<[f32; 4]>,
{
/// Constructs a new color editor builder.
#[doc(alias = "ColorEdit4")]
Expand Down Expand Up @@ -556,8 +556,8 @@ pub struct ColorPicker3<'a, Label, Color> {
impl<'a, Label, Color> ColorPicker3<'a, Label, Color>
where
Label: AsRef<str>,
MintVec3: From<Color>,
Color: From<MintVec3> + Copy,
Color: Copy + Into<MintVec3>,
MintVec3: Into<Color> + Into<[f32; 3]>,
{
/// Constructs a new color picker builder.
#[doc(alias = "ColorPicker3")]
Expand Down Expand Up @@ -696,7 +696,7 @@ where
/// Returns true if the color value was changed.
pub fn build(mut self, ui: &Ui<'_>) -> bool {
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 {
sys::igColorPicker3(
ui.scratch_txt(self.label),
Expand Down Expand Up @@ -741,8 +741,8 @@ pub struct ColorPicker4<'a, Label, Color> {
impl<'a, Label, Color> ColorPicker4<'a, Label, Color>
where
Label: AsRef<str>,
MintVec4: From<Color>,
Color: From<MintVec4> + Copy,
Color: Copy + Into<MintVec4>,
MintVec4: Into<Color> + Into<[f32; 4]>,
{
/// Constructs a new color picker builder.
#[doc(alias = "ColorPicker4")]
Expand Down Expand Up @@ -888,7 +888,7 @@ where
/// Returns true if the color value was changed.
pub fn build(mut self, ui: &Ui<'_>) -> bool {
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 changed = unsafe {
Expand Down

0 comments on commit f743fef

Please sign in to comment.