Fix vertical slider up/down keys and add a line in the changelog

Follow-up to https://github.com/emilk/egui/pull/875
This commit is contained in:
Emil Ernerfeldt 2021-11-13 12:30:13 +01:00
parent 491739b580
commit 4d4c75c6f1
3 changed files with 17 additions and 20 deletions

View file

@ -13,6 +13,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w
* Most widgets containing text (`Label`, `Button` etc) now supports rich text ([#855](https://github.com/emilk/egui/pull/855)).
* When using a custom font you can now specify a font index ([#873](https://github.com/emilk/egui/pull/873)).
* You can now read the plot coordinates of the mouse when building a `Plot` ([#766](https://github.com/emilk/egui/pull/766)).
* Add vertical sliders with `Slider::new(…).vertical()` ([#875](https://github.com/emilk/egui/pull/875)).
### Changed 🔧
* Unifiy the four `Memory` data buckets (`data`, `data_temp`, `id_data` and `id_data_temp`) into a single `Memory::data`, with a new interface ([#836](https://github.com/emilk/egui/pull/836)).
@ -31,11 +32,12 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w
* Removed `egui::paint` (use `egui::epaint` instead).
### Contributors 🙏
* [5225225](https://github.com/5225225): ([#849](https://github.com/emilk/egui/pull/849)).
* [B-Reif](https://github.com/B-Reif) ([#875](https://github.com/emilk/egui/pull/875)).
* [EmbersArc](https://github.com/EmbersArc): ([#766](https://github.com/emilk/egui/pull/766)).
* [mankinskin](https://github.com/mankinskin) ([#543](https://github.com/emilk/egui/pull/543))
* [sumibi-yakitori](https://github.com/sumibi-yakitori) ([#830](https://github.com/emilk/egui/pull/830))
* [5225225](https://github.com/5225225): ([#849](https://github.com/emilk/egui/pull/849)).
* [t18b219k](https://github.com/t18b219k): ([#868](https://github.com/emilk/egui/pull/868)).
* [EmbersArc](https://github.com/EmbersArc): ([#766](https://github.com/emilk/egui/pull/766)).
## 0.15.0 - 2021-10-24 - Syntax highlighting and hscroll

View file

@ -315,8 +315,15 @@ impl<'a> Slider<'a> {
response.widget_info(|| WidgetInfo::slider(value, &self.text));
if response.has_focus() {
let increment = ui.input().num_presses(self.key_increment());
let decrement = ui.input().num_presses(self.key_decrement());
let (dec_key, inc_key) = match self.orientation {
SliderOrientation::Horizontal => (Key::ArrowLeft, Key::ArrowRight),
// Note that this is for moving the slider position,
// so up = decrement y coordinate:
SliderOrientation::Vertical => (Key::ArrowUp, Key::ArrowDown),
};
let decrement = ui.input().num_presses(dec_key);
let increment = ui.input().num_presses(inc_key);
let kb_step = increment as f32 - decrement as f32;
if kb_step != 0.0 {
@ -394,20 +401,6 @@ impl<'a> Slider<'a> {
}
}
fn key_increment(&self) -> Key {
match self.orientation {
SliderOrientation::Horizontal => Key::ArrowRight,
SliderOrientation::Vertical => Key::ArrowUp,
}
}
fn key_decrement(&self) -> Key {
match self.orientation {
SliderOrientation::Horizontal => Key::ArrowLeft,
SliderOrientation::Vertical => Key::ArrowDown,
}
}
fn rail_rect(&self, rect: &Rect, radius: f32) -> Rect {
match self.orientation {
SliderOrientation::Horizontal => Rect::from_min_max(

View file

@ -132,13 +132,15 @@ impl super::View for Sliders {
ui.label("Slider type:");
ui.radio_value(integer, true, "i32");
ui.radio_value(integer, false, "f64");
});
})
.response
.on_hover_text("All numeric types (f32, usize, …) are supported.");
ui.horizontal(|ui| {
ui.label("Slider orientation:");
ui.radio_value(vertical, false, "Horizontal");
ui.radio_value(vertical, true, "Vertical");
});
ui.label("(f32, usize etc are also possible)");
ui.add_space(8.0);
ui.checkbox(logarithmic, "Logarithmic");