1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-03 15:20:05 -04:00

Resizing of horizontal layouts

This commit is contained in:
Emil Ernerfeldt
2023-05-02 19:30:59 +02:00
parent f8ce589fd5
commit 4f4261f173
4 changed files with 139 additions and 0 deletions

View File

@@ -1,3 +1,10 @@
// # TODO
// * A new ui for each node, nested
// * Better drag-and-drop around the "empty" drag source
// * Resizing of vertical layouts and grids
// * Styling
// * Handle rects without a lot of unwraps
use std::collections::{HashMap, HashSet};
use egui::{Id, Key, NumExt, Pos2, Rect, Response, Sense, TextStyle, Ui, WidgetText};
@@ -207,9 +214,29 @@ pub trait Behavior<Leaf> {
1.0
}
// No child should shrink below this size
fn min_size(&self) -> f32 {
32.0
}
fn simplification_options(&self) -> SimplificationOptions {
SimplificationOptions::default()
}
fn resize_stroke(&self, style: &egui::Style, resize_state: ResizeState) -> egui::Stroke {
match resize_state {
ResizeState::Idle => egui::Stroke::NONE, // Let the gap speak for itself
ResizeState::Hovering => style.visuals.widgets.hovered.fg_stroke,
ResizeState::Dragging => style.visuals.widgets.active.fg_stroke,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ResizeState {
Idle,
Hovering,
Dragging,
}
// ----------------------------------------------------------------------------