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

Use ClassName for DragValue::CLASS

`has_class` now takes `&str`, so class definitions stay `ClassName` for
consistency with the built-in `Button` and `TextEdit` classes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lucas Meurer
2026-08-31 16:51:50 +02:00
parent 095edcdce2
commit 5b057a8d17
3 changed files with 7 additions and 6 deletions

View File

@@ -147,12 +147,11 @@ impl StyleProvider<TextEditStyle> for DefaultStyle {
atom_layout: AtomLayoutStyle { atom_layout: AtomLayoutStyle {
frame: Frame { frame: Frame {
fill, fill,
stroke,
corner_radius: widget_visuals.corner_radius, corner_radius: widget_visuals.corner_radius,
inner_margin: Margin::symmetric(4, 2), inner_margin: Margin::symmetric(4, 2),
..Default::default() ..Default::default()
} }
.expand_in_place(widget_visuals.expansion), .apply_stroke_and_expansion_without_layout_shift(stroke, widget_visuals.expansion),
gap: style.spacing.icon_spacing, gap: style.spacing.icon_spacing,
text_style: text, text_style: text,
..Default::default() ..Default::default()

View File

@@ -1,8 +1,9 @@
use crate::{ use crate::{
Atom, AtomExt as _, AtomKind, Atoms, Button, CursorIcon, Id, IntoAtoms, Key, MINUS_CHAR_STR, Atom, AtomExt as _, AtomKind, Atoms, Button, CursorIcon, Id, IntoAtoms, Key, MINUS_CHAR_STR,
Modifiers, NumExt as _, Response, RichText, Sense, TextEdit, TextWrapMode, Ui, Widget, Modifiers, NumExt as _, Response, RichText, Sense, TextEdit, TextWrapMode, Ui, Widget,
WidgetInfo, emath, text, WidgetInfo,
widget_style::{Classes, HasClasses}, class::{ClassName, Classes, HasClasses},
emath, text,
}; };
use core::{cmp::Ordering, ops::RangeInclusive}; use core::{cmp::Ordering, ops::RangeInclusive};
use emath::Vec2; use emath::Vec2;
@@ -72,7 +73,7 @@ impl<'a> DragValue<'a> {
const ATOM_ID: &'static str = "drag_item"; const ATOM_ID: &'static str = "drag_item";
/// Present on the [`Button`] and the [`TextEdit`] a drag value is built from. /// Present on the [`Button`] and the [`TextEdit`] a drag value is built from.
pub const CLASS: &'static str = "egui::drag_value"; pub const CLASS: ClassName = ClassName::from_static("egui::drag_value");
pub fn new<Num: emath::Numeric>(value: &'a mut Num) -> Self { pub fn new<Num: emath::Numeric>(value: &'a mut Num) -> Self {
let slf = Self::from_get_set(move |v: Option<f64>| { let slf = Self::from_get_set(move |v: Option<f64>| {

View File

@@ -8,6 +8,7 @@ use crate::{
CursorIcon, Event, EventFilter, FontSelection, Frame, IMEPurpose, Id, IdSalt, ImeEvent, CursorIcon, Event, EventFilter, FontSelection, Frame, IMEPurpose, Id, IdSalt, ImeEvent,
IntoAtoms, IntoSizedResult, Key, KeyboardShortcut, Margin, Modifiers, NumExt as _, Response, IntoAtoms, IntoSizedResult, Key, KeyboardShortcut, Margin, Modifiers, NumExt as _, Response,
Sense, SizedAtomKind, TextBuffer, TextStyle, Ui, Vec2, Widget, WidgetInfo, WidgetWithState, Sense, SizedAtomKind, TextBuffer, TextStyle, Ui, Vec2, Widget, WidgetInfo, WidgetWithState,
class::{ClassName, Classes, HasClasses},
epaint, epaint,
os::OperatingSystem, os::OperatingSystem,
output::OutputEvent, output::OutputEvent,
@@ -17,7 +18,7 @@ use crate::{
self, CCursorRange, text_cursor_state::cursor_rect, visuals::paint_text_selection, self, CCursorRange, text_cursor_state::cursor_rect, visuals::paint_text_selection,
}, },
vec2, vec2,
widget_style::{ClassName, Classes, HasClasses, TextEditStyle}, widget_style::TextEditStyle,
}; };
use super::{TextEditOutput, TextEditState}; use super::{TextEditOutput, TextEditState};