mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-25 03:58:12 +08:00
Add sizing gizmos to the Text tool's text area (#2176)
* Fix abortion while dragging * Create function for text bounding box * Reorder arms of text tool FSM * add transform cage to textbox pt.1 * add transform cage pt.2 * Fix minor issue after merge * Get bounding box working in place without action keys * Add max_height and disable pivot drag * Cleanup code and write doco for new utility function * Minor change due to merge * Add bottom overlay * Get modifier keys to work pt.1 * Code cleanup * cleanup * Fix transform * Minor improvements * Undo debug statement! * Add comments and keep original layer transformation * Alt from centre * Fix merge conflict * Minor code review --------- Co-authored-by: Keavon Chambers <keavon@keavon.com> Co-authored-by: hypercube <0hypercube@gmail.com> Co-authored-by: James Lindsay <78500760+0HyperCube@users.noreply.github.com>
This commit is contained in:
co-authored by
Keavon Chambers
hypercube
James Lindsay
parent
a696aae044
commit
c0d3eb8072
@@ -351,9 +351,13 @@ pub fn snap_drag(start: DVec2, current: DVec2, axis_align: bool, snap_data: Snap
|
||||
/// Contains info on the overlays for the bounding box and transform handles
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct BoundingBoxManager {
|
||||
/// The corners of the box. Transform with original_bound_transform to get viewport co-ordinates.
|
||||
pub bounds: [DVec2; 2],
|
||||
/// The transform to viewport space for the bounds co-ordinates when the bounds were last updated.
|
||||
pub transform: DAffine2,
|
||||
/// Was the transform previously singular?
|
||||
pub transform_tampered: bool,
|
||||
/// The transform to viewport space for the bounds co-ordinates when the transformation was started.
|
||||
pub original_bound_transform: DAffine2,
|
||||
pub selected_edges: Option<SelectedEdges>,
|
||||
pub original_transforms: OriginalTransforms,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
||||
use crate::messages::prelude::*;
|
||||
use crate::messages::tool::common_functionality::graph_modification_utils::get_text;
|
||||
|
||||
use graphene_core::renderer::Quad;
|
||||
use graphene_core::text::{load_face, FontCache};
|
||||
use graphene_std::vector::PointId;
|
||||
|
||||
use glam::DVec2;
|
||||
@@ -53,3 +56,13 @@ where
|
||||
|
||||
best
|
||||
}
|
||||
|
||||
/// Calculates the bounding box of the layer's text, based on the settings for max width and height specified in the typesetting config.
|
||||
pub fn text_bounding_box(layer: LayerNodeIdentifier, document: &DocumentMessageHandler, font_cache: &FontCache) -> Quad {
|
||||
let (text, font, typesetting) = get_text(layer, &document.network_interface).expect("Text layer should have text when interacting with the Text tool");
|
||||
|
||||
let buzz_face = font_cache.get(font).map(|data| load_face(data));
|
||||
let far = graphene_core::text::bounding_box(text, buzz_face.as_ref(), typesetting);
|
||||
|
||||
Quad::from_box([DVec2::ZERO, far])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user