💄 Rename text-dimensions to get-text-dimensions

This commit is contained in:
Andrey Antukh
2025-08-12 13:55:36 +02:00
parent 0d6eac7656
commit c55f3182d8
5 changed files with 18 additions and 17 deletions

View File

@@ -58,13 +58,13 @@
([{:keys [id points selrect] :as shape} content]
(wasm.api/use-shape id)
(wasm.api/set-shape-text id content)
(let [dimension (wasm.api/text-dimensions)
resize-v
(gpt/point
(/ (:width dimension) (-> selrect :width))
(/ (:height dimension) (-> selrect :height)))
(let [dimension (wasm.api/get-text-dimensions)
resize-v (gpt/point
(/ (:width dimension) (-> selrect :width))
(/ (:height dimension) (-> selrect :height)))
origin (first points)]
origin (first points)]
{id
{:modifiers
(ctm/resize-modifiers

View File

@@ -19,7 +19,7 @@
(if (features/active-feature? @st/state "render-wasm/v1")
(let [transform (gsh/transform-str shape)
{:keys [id x y grow-type]} shape
{:keys [width height]} (if (= :fixed grow-type) shape (wasm.api/text-dimensions id))]
{:keys [width height]} (if (= :fixed grow-type) shape (wasm.api/get-text-dimensions id))]
[:rect.main.viewport-selrect
{:x x
:y y

View File

@@ -310,7 +310,7 @@
[x y width height]
(if (features/active-feature? @st/state "render-wasm/v1")
(let [{:keys [max-width height]} (wasm.api/text-dimensions shape-id)
(let [{:keys [max-width height]} (wasm.api/get-text-dimensions shape-id)
{:keys [x y]} (:selrect shape)]
[x y max-width height])

View File

@@ -309,7 +309,7 @@
(ted/export-content))]
(wasm.api/use-shape edition)
(wasm.api/set-shape-text-content edition content)
(let [dimension (wasm.api/text-dimensions)]
(let [dimension (wasm.api/get-text-dimensions)]
(st/emit! (dwt/resize-text-editor edition dimension))
(wasm.api/clear-drawing-cache)
(wasm.api/request-render "content"))))))

View File

@@ -645,6 +645,7 @@
fonts (fonts/get-content-fonts content)
emoji? (atom false)
languages (atom #{})]
(loop [index 0]
(when (< index (count paragraphs))
(let [paragraph (nth paragraphs index)
@@ -673,16 +674,17 @@
[grow-type]
(h/call wasm/internal-module "_set_shape_grow_type" (sr/translate-grow-type grow-type)))
(defn text-dimensions
(defn get-text-dimensions
([id]
(use-shape id)
(text-dimensions))
(get-text-dimensions))
([]
(let [offset (h/call wasm/internal-module "_get_text_dimensions")
heapf32 (mem/get-heap-f32)
width (aget heapf32 (mem/->offset-32 offset))
height (aget heapf32 (mem/->offset-32 (+ offset 4)))
max-width (aget heapf32 (mem/->offset-32 (+ offset 8)))]
(let [offset (-> (h/call wasm/internal-module "_get_text_dimensions")
(mem/->offset-32))
heapf32 (mem/get-heap-f32)
width (aget heapf32 (+ offset 0))
height (aget heapf32 (+ offset 1))
max-width (aget heapf32 (+ offset 2))]
(mem/free)
{:width width :height height :max-width max-width})))
@@ -776,7 +778,6 @@
(perf/end-measure "set-object")
pending)))
(defn process-pending
[pending]
(let [event (js/CustomEvent. "wasm:set-objects-finished")