Set text fill color to the primary color (#521)

* Fix text has no fill

* Use primary color for text fill

* Use correct text color when editing

* Change fallback text color to gray
This commit is contained in:
Paul Kupper
2022-02-07 20:58:22 +01:00
committed by Keavon Chambers
parent 5ea4654f53
commit cb9a37b638
3 changed files with 7 additions and 3 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ use crate::misc::{HintData, HintGroup, HintInfo, KeysGroup};
use crate::viewport_tools::tool::{DocumentToolData, Fsm, ToolActionHandlerData}; use crate::viewport_tools::tool::{DocumentToolData, Fsm, ToolActionHandlerData};
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};
use graphene::color::Color;
use graphene::intersection::Quad; use graphene::intersection::Quad;
use graphene::layers::style::{self, Fill, Stroke}; use graphene::layers::style::{self, Fill, Stroke};
use graphene::Operation; use graphene::Operation;
@@ -253,7 +254,7 @@ impl Fsm for TextToolFsmState {
transform: DAffine2::ZERO.to_cols_array(), transform: DAffine2::ZERO.to_cols_array(),
insert_index: -1, insert_index: -1,
text: r#""#.to_string(), text: r#""#.to_string(),
style: style::PathStyle::new(Some(style::Stroke::new(tool_data.primary_color, 0.)), None), style: style::PathStyle::new(None, Some(Fill::new(tool_data.primary_color))),
size: font_size as f64, size: font_size as f64,
} }
.into(), .into(),
@@ -197,7 +197,6 @@
overflow: visible; overflow: visible;
div { div {
color: black;
background: none; background: none;
cursor: text; cursor: text;
border: none; border: none;
+5 -1
View File
@@ -43,13 +43,17 @@ impl LayerData for Text {
if self.editable { if self.editable {
let _ = write!( let _ = write!(
svg, svg,
r#"<foreignObject transform="matrix({})"></foreignObject>"#, r#"<foreignObject transform="matrix({})" style="color: {}"></foreignObject>"#,
transform transform
.to_cols_array() .to_cols_array()
.iter() .iter()
.enumerate() .enumerate()
.map(|(i, entry)| { entry.to_string() + if i == 5 { "" } else { "," } }) .map(|(i, entry)| { entry.to_string() + if i == 5 { "" } else { "," } })
.collect::<String>(), .collect::<String>(),
match self.style.fill() {
Some(fill) => format!("#{}", fill.color().rgba_hex()),
None => "gray".to_string(),
}
); );
} else { } else {
let mut path = self.to_bez_path(); let mut path = self.to_bez_path();