drafftink_core/widget/state.rs
1//! Widget state definitions.
2
3/// The UI state of a widget/shape.
4#[derive(Debug, Clone, PartialEq)]
5pub enum WidgetState {
6 /// Normal display state - no interaction.
7 Normal,
8 /// Mouse is hovering over the widget.
9 Hovered,
10 /// Widget is selected (shows handles, can be moved/resized).
11 Selected,
12 /// Widget is in editing mode (e.g., text editing).
13 Editing(EditingKind),
14}
15
16impl Default for WidgetState {
17 fn default() -> Self {
18 Self::Normal
19 }
20}
21
22impl WidgetState {
23 /// Check if widget is selected (either just selected or editing).
24 pub fn is_selected(&self) -> bool {
25 matches!(self, Self::Selected | Self::Editing(_))
26 }
27
28 /// Check if widget is in editing mode.
29 pub fn is_editing(&self) -> bool {
30 matches!(self, Self::Editing(_))
31 }
32}
33
34/// Kind of editing mode.
35#[derive(Debug, Clone, PartialEq)]
36pub enum EditingKind {
37 /// Text editing mode - cursor position, selection, etc.
38 Text,
39 /// Path editing mode - for freehand shapes.
40 Path,
41}