Set text color based on its fill when it's being edited

This commit is contained in:
Keavon Chambers
2022-03-04 12:15:42 -08:00
parent 0bdb08f34d
commit bd9571103e
4 changed files with 9 additions and 2 deletions

View File

@@ -15,10 +15,11 @@ use crate::message_prelude::*;
use crate::viewport_tools::vector_editor::vector_shape::VectorShape;
use crate::EditorError;
use graphene::color::Color;
use graphene::document::Document as GrapheneDocument;
use graphene::layers::folder_layer::FolderLayer;
use graphene::layers::layer_info::LayerDataType;
use graphene::layers::style::ViewMode;
use graphene::layers::style::{Fill, ViewMode};
use graphene::{DocumentError, DocumentResponse, LayerId, Operation as DocumentOperation};
use glam::{DAffine2, DVec2};
@@ -1156,11 +1157,13 @@ impl MessageHandler<DocumentMessage, &InputPreprocessorMessageHandler> for Docum
let text = self.graphene_document.layer(&path).unwrap().as_text().unwrap();
responses.push_back(DocumentOperation::SetTextEditability { path, editable }.into());
if editable {
let color = if let Fill::Solid(solid_color) = text.style.fill() { *solid_color } else { Color::BLACK };
responses.push_back(
FrontendMessage::DisplayEditableTextbox {
text: text.text.clone(),
line_width: text.line_width,
font_size: text.size,
color,
}
.into(),
);