aumate 0.2.8

Cross-platform desktop automation library with GUI support
Documentation
//! Text action - toggles text input mode for adding text to screenshot

use crate::screenshot::action::{ActionContext, ActionResult, ScreenAction, ToolCategory};

/// Action to toggle text input mode
///
/// When active, allows adding text annotations to the screenshot.
pub struct TextAction {
    /// Whether text mode is currently active
    active: bool,
}

impl TextAction {
    pub fn new() -> Self {
        Self { active: false }
    }
}

impl Default for TextAction {
    fn default() -> Self {
        Self::new()
    }
}

impl ScreenAction for TextAction {
    fn id(&self) -> &str {
        "text"
    }

    fn name(&self) -> &str {
        "Text"
    }

    fn icon_id(&self) -> Option<&str> {
        Some("text")
    }

    fn category(&self) -> ToolCategory {
        ToolCategory::Drawing
    }

    fn is_active(&self) -> bool {
        self.active
    }

    fn set_active(&mut self, active: bool) {
        self.active = active;
    }

    fn on_click(&mut self, _ctx: &ActionContext) -> ActionResult {
        self.active = !self.active;
        ActionResult::Continue
    }
}