diff --git a/CHANGELOG.md b/CHANGELOG.md index c759e1a8..e97640a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Simple drop-down combo box menu * Logarithmic sliders * Optimization: coarse culling in the tesselator +* CHANGED: switch argument order of `ui.checkbox` and `ui.radio` ## 0.1.4 - 2020-09-08 diff --git a/egui/src/demos/app.rs b/egui/src/demos/app.rs index cc7167b3..8068a200 100644 --- a/egui/src/demos/app.rs +++ b/egui/src/demos/app.rs @@ -356,8 +356,8 @@ impl DemoApp { ui.separator(); ui.checkbox( - "Show color blend test (debug backend painter)", &mut self.show_color_test, + "Show color blend test (debug backend painter)", ); } @@ -365,9 +365,9 @@ impl DemoApp { ui.horizontal(|ui| { let run_mode = &mut self.run_mode; ui.label("Run mode:"); - ui.radio_value("Continuous", run_mode, RunMode::Continuous) + ui.radio_value(run_mode, RunMode::Continuous, "Continuous") .on_hover_text("Repaint everything each frame"); - ui.radio_value("Reactive", run_mode, RunMode::Reactive) + ui.radio_value(run_mode, RunMode::Reactive, "Reactive") .on_hover_text("Repaint when there are animations or input (e.g. mouse movement)"); }); } diff --git a/egui/src/demos/color_test.rs b/egui/src/demos/color_test.rs index 6d0b3dc1..2391931a 100644 --- a/egui/src/demos/color_test.rs +++ b/egui/src/demos/color_test.rs @@ -31,9 +31,9 @@ impl ColorTest { ui.label("It is meant to ensure you do proper sRGBA decoding of both texture and vertex colors, and blend using premultiplied alpha."); ui.label("If everything is set up correctly, all groups of gradients will look uniform"); - ui.checkbox("Vertex gradients", &mut self.vertex_gradients); - ui.checkbox("Texture gradients", &mut self.texture_gradients); - ui.checkbox("Show naive sRGBA horror", &mut self.srgb); + ui.checkbox(&mut self.vertex_gradients, "Vertex gradients"); + ui.checkbox(&mut self.texture_gradients, "Texture gradients"); + ui.checkbox(&mut self.srgb, "Show naive sRGBA horror"); ui.heading("sRGB color test"); ui.label("Use a color picker to ensure this color is (255, 165, 0) / #ffa500"); diff --git a/egui/src/demos/sliders.rs b/egui/src/demos/sliders.rs index 100845c2..7a951e57 100644 --- a/egui/src/demos/sliders.rs +++ b/egui/src/demos/sliders.rs @@ -93,16 +93,16 @@ impl Sliders { ui.horizontal(|ui| { ui.label("Slider type:"); - ui.radio_value("i32", integer, true); - ui.radio_value("f64", integer, false); + ui.radio_value(integer, true, "i32"); + ui.radio_value(integer, false, "f64"); }); ui.label("(f32, usize etc are also possible)"); - ui.checkbox("Logarithmic", logarithmic); + ui.checkbox(logarithmic, "Logarithmic"); ui.label("Logarithmic sliders are great for when you want to span a huge range, i.e. from zero to a million."); ui.label("Logarithmic sliders can include infinity and zero."); - ui.checkbox("Smart Aim", smart_aim); + ui.checkbox(smart_aim, "Smart Aim"); ui.label("Smart Aim will guide you towards round values when you drag the slider so you you are more likely to hit 250 than 247.23"); if ui.button("Reset slider demo").clicked { diff --git a/egui/src/demos/widgets.rs b/egui/src/demos/widgets.rs index 6b3ca9ca..df363adb 100644 --- a/egui/src/demos/widgets.rs +++ b/egui/src/demos/widgets.rs @@ -71,15 +71,15 @@ impl Widgets { .on_hover_text("The current font supports only a few non-latin characters and Egui does not currently support right-to-left text."); ui.horizontal(|ui| { - ui.radio_value("First", &mut self.radio, Enum::First); - ui.radio_value("Second", &mut self.radio, Enum::Second); - ui.radio_value("Third", &mut self.radio, Enum::Third); + ui.radio_value(&mut self.radio, Enum::First, "First"); + ui.radio_value(&mut self.radio, Enum::Second, "Second"); + ui.radio_value(&mut self.radio, Enum::Third, "Third"); }); combo_box_with_label(ui, "Combo Box", format!("{:?}", self.radio), |ui| { - ui.radio_value("First", &mut self.radio, Enum::First); - ui.radio_value("Second", &mut self.radio, Enum::Second); - ui.radio_value("Third", &mut self.radio, Enum::Third); + ui.radio_value(&mut self.radio, Enum::First, "First"); + ui.radio_value(&mut self.radio, Enum::Second, "Second"); + ui.radio_value(&mut self.radio, Enum::Third, "Third"); }); ui.add(Checkbox::new(&mut self.button_enabled, "Button enabled")); diff --git a/egui/src/style.rs b/egui/src/style.rs index 7f794b60..af175d6d 100644 --- a/egui/src/style.rs +++ b/egui/src/style.rs @@ -305,7 +305,7 @@ impl Style { ui.horizontal(|ui| { ui.label("Default text style:"); for &value in &[TextStyle::Body, TextStyle::Monospace] { - ui.radio_value(format!("{:?}", value), body_text_style, value); + ui.radio_value(body_text_style, value, format!("{:?}", value)); } }); ui.collapsing("Spacing", |ui| spacing.ui(ui)); diff --git a/egui/src/ui.rs b/egui/src/ui.rs index 09cc964c..cf0fd663 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -503,37 +503,35 @@ impl Ui { self.add(Hyperlink::new(url)) } + pub fn text_edit(&mut self, text: &mut String) -> Response { + self.add(TextEdit::new(text)) + } + /// Shortcut for `add(Button::new(text))` #[must_use = "You should check if the user clicked this with `if ui.button(...).clicked { ... } "] pub fn button(&mut self, text: impl Into) -> Response { self.add(Button::new(text)) } - // Argument order matching that of Dear ImGui /// Show a checkbox. - pub fn checkbox(&mut self, text: impl Into, checked: &mut bool) -> Response { + pub fn checkbox(&mut self, checked: &mut bool, text: impl Into) -> Response { self.add(Checkbox::new(checked, text)) } - // Argument order matching that of Dear ImGui /// Show a radio button. - pub fn radio(&mut self, text: impl Into, checked: bool) -> Response { + pub fn radio(&mut self, checked: bool, text: impl Into) -> Response { self.add(RadioButton::new(checked, text)) } - pub fn text_edit(&mut self, text: &mut String) -> Response { - self.add(TextEdit::new(text)) - } - /// Show a radio button. It is selected if `*current_value == radio_value`. /// If clicked, `radio_value` is assigned to `*current_value`; pub fn radio_value( &mut self, - text: impl Into, current_value: &mut Value, radio_value: Value, + text: impl Into, ) -> Response { - let response = self.radio(text, *current_value == radio_value); + let response = self.radio(*current_value == radio_value, text); if response.clicked { *current_value = radio_value; }