mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 21:48:36 +00:00
aaand examples compile. complex trait bounds there...
This commit is contained in:
parent
8b22856090
commit
f743fefe79
@ -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)
|
||||
@ -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);
|
||||
@ -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)
|
||||
@ -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)
|
||||
@ -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);
|
||||
});
|
||||
@ -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") ;
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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,
|
||||
@ -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 {
|
||||
@ -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 {
|
||||
@ -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 {
|
||||
@ -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 {
|
||||
|
||||
@ -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)
|
||||
}
|
||||
@ -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)
|
||||
}
|
||||
@ -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)
|
||||
}
|
||||
@ -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>
|
||||
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)
|
||||
}
|
||||
@ -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>
|
||||
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)
|
||||
}
|
||||
@ -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>
|
||||
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)
|
||||
}
|
||||
|
||||
@ -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")]
|
||||
@ -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")]
|
||||
@ -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")]
|
||||
@ -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),
|
||||
@ -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")]
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user