mirror of
https://github.com/penpot/penpot.git
synced 2026-05-26 10:23:45 +00:00
🔧 Show label if wasm text editor is enabled
This commit is contained in:
parent
802cec1ee4
commit
c8b3407acd
@ -53,6 +53,13 @@
|
|||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
(def use-dpr? (contains? cf/flags :render-wasm-dpr))
|
(def use-dpr? (contains? cf/flags :render-wasm-dpr))
|
||||||
|
|
||||||
|
(defn text-editor-wasm?
|
||||||
|
[]
|
||||||
|
(let [runtime-features (get @st/state :features-runtime)
|
||||||
|
enabled-features (get @st/state :features)]
|
||||||
|
(or (contains? runtime-features "text-editor-wasm/v1")
|
||||||
|
(contains? enabled-features "text-editor-wasm/v1"))))
|
||||||
|
|
||||||
(def ^:const UUID-U8-SIZE 16)
|
(def ^:const UUID-U8-SIZE 16)
|
||||||
(def ^:const UUID-U32-SIZE (/ UUID-U8-SIZE 4))
|
(def ^:const UUID-U32-SIZE (/ UUID-U8-SIZE 4))
|
||||||
|
|
||||||
@ -149,11 +156,8 @@
|
|||||||
;; Determine if text-editor-wasm feature is active without requiring
|
;; Determine if text-editor-wasm feature is active without requiring
|
||||||
;; app.main.features to avoid circular dependency: check runtime and
|
;; app.main.features to avoid circular dependency: check runtime and
|
||||||
;; persisted feature sets in the store state.
|
;; persisted feature sets in the store state.
|
||||||
(let [runtime-features (get @st/state :features-runtime)
|
(when (text-editor-wasm?)
|
||||||
enabled-features (get @st/state :features)]
|
(text-editor/text-editor-render-overlay))
|
||||||
(when (or (contains? runtime-features "text-editor-wasm/v1")
|
|
||||||
(contains? enabled-features "text-editor-wasm/v1"))
|
|
||||||
(text-editor/text-editor-render-overlay)))
|
|
||||||
;; Poll for editor events; if any event occurs, trigger a re-render
|
;; Poll for editor events; if any event occurs, trigger a re-render
|
||||||
(let [ev (text-editor/text-editor-poll-event)]
|
(let [ev (text-editor/text-editor-poll-event)]
|
||||||
(when (and ev (not= ev 0))
|
(when (and ev (not= ev 0))
|
||||||
@ -1395,7 +1399,9 @@
|
|||||||
[]
|
[]
|
||||||
(cond-> 0
|
(cond-> 0
|
||||||
(dbg/enabled? :wasm-viewbox)
|
(dbg/enabled? :wasm-viewbox)
|
||||||
(bit-or 2r00000000000000000000000000000001)))
|
(bit-or 2r00000000000000000000000000000001)
|
||||||
|
(text-editor-wasm?)
|
||||||
|
(bit-or 2r00000000000000000000000000001000)))
|
||||||
|
|
||||||
(defn set-canvas-size
|
(defn set-canvas-size
|
||||||
[canvas]
|
[canvas]
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
(defonce context-initialized? false)
|
(defonce context-initialized? false)
|
||||||
(defonce context-lost? (atom false))
|
(defonce context-lost? (atom false))
|
||||||
|
|
||||||
|
|
||||||
(defonce serializers
|
(defonce serializers
|
||||||
#js {:blur-type shared/RawBlurType
|
#js {:blur-type shared/RawBlurType
|
||||||
:blend-mode shared/RawBlendMode
|
:blend-mode shared/RawBlendMode
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
pub const DEBUG_VISIBLE: u32 = 0x01;
|
pub const DEBUG_VISIBLE: u32 = 0x01;
|
||||||
pub const PROFILE_REBUILD_TILES: u32 = 0x02;
|
pub const PROFILE_REBUILD_TILES: u32 = 0x02;
|
||||||
pub const FAST_MODE: u32 = 0x04;
|
pub const FAST_MODE: u32 = 0x04;
|
||||||
|
pub const INFO_TEXT: u32 = 0x08;
|
||||||
|
|||||||
@ -46,16 +46,25 @@ pub fn render_wasm_label(render_state: &mut RenderState) {
|
|||||||
let mut paint = skia::Paint::default();
|
let mut paint = skia::Paint::default();
|
||||||
paint.set_color(skia::Color::GRAY);
|
paint.set_color(skia::Color::GRAY);
|
||||||
|
|
||||||
let str = if render_state.options.is_debug_visible() {
|
let mut str = if render_state.options.is_debug_visible() {
|
||||||
"WASM RENDERER (DEBUG)"
|
"WASM RENDERER (DEBUG)"
|
||||||
} else {
|
} else {
|
||||||
"WASM RENDERER"
|
"WASM RENDERER"
|
||||||
};
|
};
|
||||||
let (scalar, _) = render_state.fonts.debug_font().measure_str(str, None);
|
let (scalar, _) = render_state.fonts.debug_font().measure_str(str, None);
|
||||||
let p = skia::Point::new(width as f32 - 25.0 - scalar, height as f32 - 25.0);
|
let mut p = skia::Point::new(width as f32 - 25.0 - scalar, height as f32 - 25.0);
|
||||||
|
|
||||||
let debug_font = render_state.fonts.debug_font();
|
let debug_font = render_state.fonts.debug_font();
|
||||||
canvas.draw_str(str, p, debug_font, &paint);
|
canvas.draw_str(str, p, debug_font, &paint);
|
||||||
|
|
||||||
|
if render_state.options.show_info_text() {
|
||||||
|
str = "TEXT EDITOR / V3";
|
||||||
|
|
||||||
|
let (scalar, _) = render_state.fonts.debug_font().measure_str(str, None);
|
||||||
|
p.x = width as f32 - 25.0 - scalar;
|
||||||
|
p.y -= 20.0;
|
||||||
|
canvas.draw_str(str, p, debug_font, &paint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|||||||
@ -31,4 +31,8 @@ impl RenderOptions {
|
|||||||
pub fn dpr(&self) -> f32 {
|
pub fn dpr(&self) -> f32 {
|
||||||
self.dpr.unwrap_or(1.0)
|
self.dpr.unwrap_or(1.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn show_info_text(&self) -> bool {
|
||||||
|
self.flags & options::INFO_TEXT == options::INFO_TEXT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user