mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 22:30:03 -04:00
Add Ui::spacing() and Ui::spacing_mut() as shortcuts
This commit is contained in:
@@ -90,7 +90,7 @@ impl super::View for FontBook {
|
||||
|
||||
egui::ScrollArea::auto_sized().show(ui, |ui| {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.style_mut().spacing.item_spacing = egui::Vec2::splat(2.0);
|
||||
ui.spacing_mut().item_spacing = egui::Vec2::splat(2.0);
|
||||
|
||||
if self.standard {
|
||||
self.characters_ui(ui, UBUNTU_FONT_CHARACTERS);
|
||||
|
||||
@@ -19,7 +19,7 @@ pub fn toggle(ui: &mut egui::Ui, on: &mut bool) -> egui::Response {
|
||||
// 1. Deciding widget size:
|
||||
// You can query the `ui` how much space is available,
|
||||
// but in this example we have a fixed size widget of the default size for a button:
|
||||
let desired_size = ui.style().spacing.interact_size;
|
||||
let desired_size = ui.spacing().interact_size;
|
||||
|
||||
// 2. Allocating space:
|
||||
// This is where we get a region of the screen assigned.
|
||||
@@ -61,7 +61,7 @@ pub fn toggle(ui: &mut egui::Ui, on: &mut bool) -> egui::Response {
|
||||
/// Here is the same code again, but a bit more compact:
|
||||
#[allow(dead_code)]
|
||||
fn toggle_compact(ui: &mut egui::Ui, on: &mut bool) -> egui::Response {
|
||||
let desired_size = ui.style().spacing.interact_size;
|
||||
let desired_size = ui.spacing().interact_size;
|
||||
let (rect, response) = ui.allocate_exact_size(desired_size, egui::Sense::click());
|
||||
*on ^= response.clicked(); // toggle if clicked
|
||||
|
||||
|
||||
Reference in New Issue
Block a user