0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 08:20:45 -05:00

🐛 Fix real time blend mode rendering

This commit is contained in:
Alejandro Alonso 2024-11-15 12:51:41 +01:00 committed by AzazelN28
parent aa07a8046b
commit b4e9f9e28c
2 changed files with 36 additions and 15 deletions

View file

@ -11,10 +11,13 @@
[app.common.data.macros :as dm]
[app.main.data.workspace :as dw]
[app.main.data.workspace.shapes :as dwsh]
[app.main.data.workspace.state-helpers :as wsh]
[app.main.features :as features]
[app.main.store :as st]
[app.main.ui.components.numeric-input :refer [numeric-input*]]
[app.main.ui.components.select :refer [select]]
[app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
[app.render-wasm.api :as wasm.api]
[app.util.i18n :as i18n :refer [tr]]
[rumext.v2 :as mf]))
@ -32,24 +35,30 @@
(mf/defc layer-menu
{::mf/wrap-props false}
[props]
(let [ids (unchecked-get props "ids")
values (unchecked-get props "values")
(let [ids (unchecked-get props "ids")
values (unchecked-get props "values")
hidden? (:hidden values)
blocked? (:blocked values)
hidden? (:hidden values)
blocked? (:blocked values)
current-blend-mode (or (:blend-mode values) :normal)
current-opacity (opacity->string (:opacity values))
current-blend-mode (or (:blend-mode values) :normal)
current-opacity (opacity->string (:opacity values))
state* (mf/use-state
{:selected-blend-mode current-blend-mode
:option-highlighted? false
:preview-complete? true})
state* (mf/use-state
{:selected-blend-mode current-blend-mode
:option-highlighted? false
:preview-complete? true})
state (deref state*)
selected-blend-mode (get state :selected-blend-mode)
option-highlighted? (get state :option-highlighted?)
preview-complete? (get state :preview-complete?)
state (deref state*)
selected-blend-mode (get state :selected-blend-mode)
option-highlighted? (get state :option-highlighted?)
preview-complete? (get state :preview-complete?)
wasm-renderer-enabled? (features/use-feature "render-wasm/v1")
shapes (->
(wsh/lookup-page-objects @st/state)
(select-keys ids)
vals)
on-change
(mf/use-fn
@ -75,6 +84,12 @@
(swap! state* assoc
:preview-complete? false
:option-highlighted? true)
(when wasm-renderer-enabled?
(doseq [shape shapes]
(wasm.api/use-shape (:id shape))
(wasm.api/set-shape-blend-mode value)))
(st/emit! (dw/set-preview-blend-mode ids value))))
handle-blend-mode-leave

View file

@ -271,7 +271,9 @@
(:y first-shape)
(:y selected-frame))
rule-area-size (/ rulers/ruler-area-size zoom)]
rule-area-size (/ rulers/ruler-area-size zoom)
preview-blend (-> refs/workspace-preview-blend
(mf/deref))]
(mf/with-effect []
(when-let [canvas (mf/ref-val canvas-ref)]
@ -287,6 +289,10 @@
(when @canvas-init?
(wasm.api/set-objects base-objects)))
(mf/with-effect [preview-blend canvas-init?]
(when (and @canvas-init? preview-blend)
(wasm.api/request-render)))
(mf/with-effect [vbox canvas-init?]
(when @canvas-init?
(wasm.api/set-view zoom vbox)))