1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00
This commit is contained in:
Lucas Meurer
2026-08-28 17:24:22 +02:00
parent 735774bd98
commit 13dc9d528c
2 changed files with 5 additions and 4 deletions

View File

@@ -62,7 +62,7 @@ impl StyleProvider<ButtonStyle> for DefaultStyle {
let frame = if !has_frame {
// No frame at all: the button takes up no more room than its contents.
Frame::new()
} else if classes.has_class(Button::CLASS_NO_FRAME_WHEN_INACTIVE)
} else if classes.has_class(Button::CLASS_HIDE_FRAME_WHEN_INACTIVE)
&& *state == WidgetState::Inactive
{
// Invisible, but as big as it will be once the user interacts with it.

View File

@@ -50,7 +50,8 @@ impl<'a> Button<'a> {
pub const CLASS_FRAME: &'static str = "egui::frame";
/// Present on a button that should have no frame while it is inactive.
pub const CLASS_NO_FRAME_WHEN_INACTIVE: &'static str = "egui::button::no_frame_when_inactive";
pub const CLASS_HIDE_FRAME_WHEN_INACTIVE: &'static str =
"egui::button::hide_frame_when_inactive";
pub fn new(atoms: impl IntoAtoms<'a>) -> Self {
Self {
@@ -187,7 +188,7 @@ impl<'a> Button<'a> {
/// If `false`, the button will not have a frame when inactive.
///
/// This adds the built-in [`Self::CLASS_NO_FRAME_WHEN_INACTIVE`], which with the
/// This adds the built-in [`Self::CLASS_HIDE_FRAME_WHEN_INACTIVE`], which with the
/// default style removes the fill and the stroke, but keeps the margin, so the button does
/// not change size once the user interacts with it.
///
@@ -197,7 +198,7 @@ impl<'a> Button<'a> {
/// has no effect.
#[inline]
pub fn frame_when_inactive(mut self, frame_when_inactive: bool) -> Self {
self.set_class(Self::CLASS_NO_FRAME_WHEN_INACTIVE, !frame_when_inactive);
self.set_class(Self::CLASS_HIDE_FRAME_WHEN_INACTIVE, !frame_when_inactive);
self
}