Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Text tool click targets on text layers to use the text box #2145

Merged
merged 5 commits into from
Dec 28, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions editor/src/messages/tool/tool_messages/text_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,24 @@ impl TextToolData {
font_cache: &FontCache,
responses: &mut VecDeque<Message>,
) -> TextToolFsmState {
// Check if the user has selected an existing text layer
if let Some(clicked_text_layer_path) = document.click(input).filter(|&layer| is_layer_fed_by_node_of_name(layer, &document.network_interface, "Text")) {
// Check if the user has selected an existing text layerQ
if let Some(clicked_text_layer_path) = document
.metadata()
.all_layers()
.filter(|&layer| is_layer_fed_by_node_of_name(layer, &document.network_interface, "Text"))
.find(|&layer| {
let (text, font, font_size, line_height_ratio, character_spacing) = graph_modification_utils::get_text(layer, &document.network_interface).unwrap();
let buzz_face = font_cache.get(font).map(|data| load_face(data));
let far = graphene_core::text::bounding_box(text, buzz_face, font_size, line_height_ratio, character_spacing, None);
let quad = Quad::from_box([DVec2::ZERO, far]);
Comment on lines +322 to +323
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Farquaad_portrait

let transformed_quad = document.metadata().transform_to_viewport(layer) * quad;
let mouse = DVec2::new(input.mouse.position.x, input.mouse.position.y);

if transformed_quad.contains(mouse) {
return true;
}
false
}) {
self.start_editing_layer(clicked_text_layer_path, state, document, font_cache, responses);

TextToolFsmState::Editing
Expand Down