mirror of
https://github.com/penpot/penpot.git
synced 2026-11-26 21:00:32 +00:00
⚡ Re-present the frame when the grid overlay changes (#13248)
Hovering a grid frame requested a full render. That clears the canvas and walks every visible tile even though the overlay is only UI. show_grid and hide_grid now re-present the last frame.
This commit is contained in:
parent
deffc02098
commit
277ca546f2
@ -260,7 +260,7 @@
|
||||
last-vern-ref (mf/use-ref nil)
|
||||
|
||||
;; WASM grid overlay was visible last run (`hover-grid?` true). Used so `clear-grid`
|
||||
;; (expensive: `_hide_grid` + full `request-render`) runs only when hiding the overlay.
|
||||
;; runs only when hiding the overlay.
|
||||
prev-hover-grid-shown?-ref (mf/use-ref false)
|
||||
|
||||
;; STATE REFS
|
||||
|
||||
@ -2669,6 +2669,7 @@
|
||||
(p/rejected cause))))))
|
||||
|
||||
(defn show-grid
|
||||
"Show the grid overlay for `id`. The WASM call re-presents the last frame."
|
||||
[id]
|
||||
(when (initialized?)
|
||||
(let [buffer (uuid/get-u32 id)]
|
||||
@ -2676,8 +2677,7 @@
|
||||
(aget buffer 0)
|
||||
(aget buffer 1)
|
||||
(aget buffer 2)
|
||||
(aget buffer 3)))
|
||||
(request-render "show-grid")))
|
||||
(aget buffer 3)))))
|
||||
|
||||
(defn set-rulers-visible!
|
||||
[visible?]
|
||||
@ -2716,10 +2716,10 @@
|
||||
(sr-clr/hex->u32argb accent-hex 1))))
|
||||
|
||||
(defn clear-grid
|
||||
"Hide the hover grid overlay. The WASM call re-presents the last frame."
|
||||
[]
|
||||
(when (initialized?)
|
||||
(h/call wasm/internal-module "_hide_grid")
|
||||
(request-render "clear-grid")))
|
||||
(h/call wasm/internal-module "_hide_grid")))
|
||||
|
||||
;; Ruler guides ----------------------------------------------------------------
|
||||
|
||||
|
||||
@ -240,15 +240,26 @@ pub extern "C" fn set_grid_cells() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Hover only changes the grid overlay on the UI surface. Re-present the last
|
||||
/// frame so the lines update without a tile pass. A full render clears the
|
||||
/// canvas and walks every visible tile.
|
||||
fn present_grid_overlay() {
|
||||
with_state!(state, {
|
||||
state.present_frame();
|
||||
});
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn show_grid(a: u32, b: u32, c: u32, d: u32) {
|
||||
let id = uuid_from_u32_quartet(a, b, c, d);
|
||||
get_render_state().show_grid = Some(id);
|
||||
present_grid_overlay();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn hide_grid() {
|
||||
get_render_state().show_grid = None;
|
||||
present_grid_overlay();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user