SidePanel::left and TopPanel::top now takes impl Hash instead of Id

This commit is contained in:
Emil Ernerfeldt 2020-12-15 15:13:12 +01:00
parent 18ebac116f
commit 0e0beece44
3 changed files with 16 additions and 10 deletions

View file

@ -11,12 +11,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added ⭐
* `ImageButton` - `ui.add(ImageButton::new(...))`
* `ui.vertical_centered` and `ui.vertical_centered_justified`
* `ImageButton` - `ui.add(ImageButton::new(...))`.
* `ui.vertical_centered` and `ui.vertical_centered_justified`.
### Changed 🔧
* `ui.image` now takes `impl Into<Vec2>` as a `size` argument
* `SidePanel::left` and `TopPanel::top` now takes `impl Hash` as first argument.
* `ui.image` now takes `impl Into<Vec2>` as a `size` argument.
## 0.5.0 - 2020-12-13

View file

@ -16,9 +16,13 @@ pub struct SidePanel {
}
impl SidePanel {
/// `id_source`: Something unique, e.g. `"my_side_panel"`.
/// The given `max_width` is a soft maximum (as always), and the actual panel may be smaller or larger.
pub fn left(id: Id, max_width: f32) -> Self {
Self { id, max_width }
pub fn left(id_source: impl std::hash::Hash, max_width: f32) -> Self {
Self {
id: Id::new(id_source),
max_width,
}
}
}
@ -64,11 +68,12 @@ pub struct TopPanel {
}
impl TopPanel {
/// `id_source`: Something unique, e.g. `"my_top_panel"`.
/// Default height is that of `interact_size.y` (i.e. a button),
/// but the panel will expand as needed.
pub fn top(id: Id) -> Self {
pub fn top(id_source: impl std::hash::Hash) -> Self {
Self {
id,
id: Id::new(id_source),
max_height: None,
}
}

View file

@ -3,7 +3,7 @@ use std::sync::Arc;
use crate::{
app,
demos::{self, Demo},
Context, Id, Resize, ScrollArea, Ui, Window,
Context, Resize, ScrollArea, Ui, Window,
};
// ----------------------------------------------------------------------------
@ -105,7 +105,7 @@ impl DemoWindows {
self.previous_link = env.link;
}
crate::SidePanel::left(Id::new("side_panel"), 200.0).show(ctx, |ui| {
crate::SidePanel::left("side_panel", 200.0).show(ctx, |ui| {
ui.heading("✒ Egui Demo");
crate::demos::warn_if_debug_build(ui);
ui.label("Egui is an immediate mode GUI library written in Rust.");
@ -131,7 +131,7 @@ impl DemoWindows {
sidebar_ui(ui);
});
crate::TopPanel::top(Id::new("menu_bar")).show(ctx, |ui| {
crate::TopPanel::top("menu_bar").show(ctx, |ui| {
show_menu_bar(ui, &mut self.open_windows, env.seconds_since_midnight);
});