feat(iced): implement selection menu operations
- Add Inverse selection (Shift+Ctrl+I) with engine.invert_selection() - Add Shrink, Feather, Border, Smooth menu items with parameter dialogs - Implement selection_border() and selection_smooth() in engine API - Implement border_mask() and smooth_mask() in hcie-selection crate - Update SelectionOpApply handler for all selection operations
This commit is contained in:
@@ -412,6 +412,36 @@ impl Engine {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a border from the current selection.
|
||||
///
|
||||
/// **Purpose:** Extracts only the edge pixels of the selection, keeping
|
||||
/// pixels that are selected but have at least one unselected neighbor.
|
||||
///
|
||||
/// **Arguments:**
|
||||
/// - `px`: Border thickness in pixels.
|
||||
pub fn selection_border(&mut self, px: u32) {
|
||||
if let Some(ref mut mask) = self.document.selection_mask {
|
||||
let w = self.document.canvas_width;
|
||||
let h = self.document.canvas_height;
|
||||
hcie_selection::border_mask(mask, w, h, px);
|
||||
}
|
||||
}
|
||||
|
||||
/// Smooth the current selection edges.
|
||||
///
|
||||
/// **Purpose:** Softens jagged selection edges by applying a box blur
|
||||
/// within the specified radius.
|
||||
///
|
||||
/// **Arguments:**
|
||||
/// - `px`: Blur radius in pixels.
|
||||
pub fn selection_smooth(&mut self, px: u32) {
|
||||
if let Some(ref mut mask) = self.document.selection_mask {
|
||||
let w = self.document.canvas_width;
|
||||
let h = self.document.canvas_height;
|
||||
hcie_selection::smooth_mask(mask, w, h, px);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn selection_invert(&mut self) {
|
||||
if let Some(ref mut mask) = self.document.selection_mask {
|
||||
hcie_selection::invert_mask(mask);
|
||||
|
||||
Reference in New Issue
Block a user