diff --git a/render-wasm/src/render/text_editor.rs b/render-wasm/src/render/text_editor.rs index 2cf7eeab0c..9c1cdaf526 100644 --- a/render-wasm/src/render/text_editor.rs +++ b/render-wasm/src/render/text_editor.rs @@ -66,7 +66,7 @@ fn render_selection( } let mut paint = Paint::default(); - paint.set_blend_mode(BlendMode::Multiply); + paint.set_blend_mode(BlendMode::default()); paint.set_color(editor_state.theme.selection_color); paint.set_anti_alias(true); diff --git a/render-wasm/src/state/text_editor.rs b/render-wasm/src/state/text_editor.rs index f68e84ba87..1f5e03ac96 100644 --- a/render-wasm/src/state/text_editor.rs +++ b/render-wasm/src/state/text_editor.rs @@ -91,7 +91,7 @@ pub enum TextEditorEvent { } /// FIXME: It should be better to get these constants from the frontend through the API. -const SELECTION_COLOR: Color = Color::from_argb(255, 0, 209, 184); +const SELECTION_COLOR: Color = Color::from_argb(127, 0, 209, 184); const CURSOR_WIDTH: f32 = 1.5; const CURSOR_COLOR: Color = Color::BLACK; const CURSOR_BLINK_INTERVAL_MS: f64 = 530.0; diff --git a/render-wasm/src/wasm/text_editor.rs b/render-wasm/src/wasm/text_editor.rs index f153672fb4..2728ba9f2f 100644 --- a/render-wasm/src/wasm/text_editor.rs +++ b/render-wasm/src/wasm/text_editor.rs @@ -6,6 +6,7 @@ use crate::utils::uuid_from_u32_quartet; use crate::utils::uuid_to_u32_quartet; use crate::{with_state, with_state_mut, STATE}; use macros::ToJs; +use skia_safe::Color; #[derive(PartialEq, ToJs)] #[repr(u8)] @@ -23,6 +24,21 @@ pub enum CursorDirection { // STATE MANAGEMENT // ============================================================================ +#[no_mangle] +pub extern "C" fn text_editor_apply_theme( + selection_color: u32, + cursor_width: f32, + cursor_color: u32, +) { + with_state_mut!(state, { + // NOTE: In the future could be interesting to fill al this data from + // a structure pointer. + state.text_editor_state.theme.selection_color = Color::new(selection_color); + state.text_editor_state.theme.cursor_width = cursor_width; + state.text_editor_state.theme.cursor_color = Color::new(cursor_color); + }) +} + #[no_mangle] pub extern "C" fn text_editor_start(a: u32, b: u32, c: u32, d: u32) -> bool { with_state_mut!(state, {