Files
hcie-rust-v3.05/hcie-egui-app/IMPLEMENTATION.md
T
2026-07-09 02:59:53 +03:00

3.0 KiB

Implementation: Separate per-filter settings dialogs

Changes required

1. HcieAppState additions

File: crates/hcie-gui-egui/src/app/mod.rs

  • Add to HcieAppState (or HcieApp if using a struct-level state):
    • pub filter_selected_id: String
    • pub filter_params_open: bool
    • pub filter_preview_active: bool
    • pub filter_sky_path: String
  • Initialize to defaults in the struct constructor.

2. Filter dialog redesign

File: crates/hcie-gui-egui/src/app/filter_dialog.rs

  • Replace the monolithic filter dialog with two windows:
    1. Main filter dialog — filter list only + common controls (Close, Undo Last Filter, Apply-to-New-Layer)
    2. Per-filter settings window — opened when a filter is selected

3. New functions in filter_dialog.rs

  • show_filter_list_window(app, ctx) — shows the filter category tree
    • Calls egui_panel_filters::show_filter_list_ui(...)
    • On filter click: set app.filter_selected_id, open app.filter_params_open = true
  • show_filter_params_window(app, ctx) — shows the selected filter's controls
    • Uses get_filter_panel(filter_id) to get the panel spec
    • Renders render_module_panel for the parameter widgets
    • Renders sky-path input for sky_replacement
    • Buttons: Preview / Stop Preview, Apply, Reset, Close
    • Close button sets filter_params_open = false

4. Preview feature

  • In show_filter_params_window:
    • If filter_preview_active is true:
      • On widget change: call engine.filter_preview_restore() + engine.filter_preview_begin() + engine.apply_filter_preview(id, params)
      • Show "Stop Preview" button instead of "Preview"
    • If not previewing:
      • "Preview" button starts preview: engine.filter_preview_begin(), then apply once
      • Set filter_preview_active = true
    • On window close: if preview active, call engine.filter_preview_restore() and clear flag

5. Reset feature

  • "Reset" button:
    • Re-initialize all widget values to defaults from get_filter_panel(filter_id)
    • If preview active, also restore original pixels and stop preview
    • Keep window open

6. Apply feature

  • "Apply" button:
    • Compile params with compile_filter_params
    • If preview active, restore first
    • Call engine.apply_filter(id, params)
    • Clear filter_selected_id, set filter_params_open = false

7. is_raster check

  • Pass is_raster from the engine to both windows
  • Main filter list shows the mismatch warning if not raster
  • Per-filter window is disabled/hidden if not raster

8. FilterType to string ID mapping

File: crates/hcie-gui-egui/src/app/menus.rs

  • Add a helper function filter_type_to_id(ft: FilterType) -> &'static str
  • Map each menu item's filter type to the corresponding ID string
  • Update menu handlers to set both app.show_filter = true and app.filter_selected_id = id

Implementation order

  1. Add state fields to HcieApp
  2. Implement show_filter_params_window
  3. Implement show_filter_list_window
  4. Update main filter dialog to use new windows
  5. Add preview/reset logic
  6. Update menus