Dialogs: the Select chip keeps its size on hover (#1387)
New frame::add_outlined adds a button that draws its own outline with the theme's outline width set to the same width in every state, so its padding no longer drops a pixel on hover. Used by the dialogs' Select chip, Sketch Text's Path chip and the bug report's Open GitHub draft button. New dialog_chip_hover test. Fixes the second point of #1335.
This commit is contained in:
1 parent
e382a77350
commit
fd422a3fc1
5 files changed
+45
-9
No files matched your search
@@ -108,6 +108,22 @@ pub fn window<'a>(ctx: &egui::Context, title: impl Into<WidgetText>, width: Widt
|
||||
.max_width(max)
|
||||
}
|
||||
|
||||
/// Add a button drawn with its own outline (`Button::stroke`) of `width`, keeping the same size
|
||||
/// in every state (#1335). egui sizes a button's padding as the spacing minus the *theme's*
|
||||
/// outline width for the state (none while idle, 1 px hovered), which keeps a themed button's
|
||||
/// size steady, but a button with its own outline then lost a pixel of padding each side on
|
||||
/// hover: it shrank, and the panel around it with it.
|
||||
pub fn add_outlined(ui: &mut Ui, button: egui::Button<'_>, width: f32) -> egui::Response {
|
||||
ui.scope(|ui| {
|
||||
let w = &mut ui.visuals_mut().widgets;
|
||||
for state in [&mut w.inactive, &mut w.hovered, &mut w.active, &mut w.open] {
|
||||
state.bg_stroke.width = width;
|
||||
}
|
||||
ui.add(button)
|
||||
})
|
||||
.inner
|
||||
}
|
||||
|
||||
/// Floating model controls share the report's read-only drawing boundary with windows.
|
||||
pub fn area(id: egui::Id) -> egui::Area {
|
||||
egui::Area::new(id).enabled(!crate::issue_report::cad_input_blocked())
|
||||
|
||||
Reference in new issue
Block a user