mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 07:08:11 +08:00
Implement outline view mode (#401)
* Created wasm binding to action's of the radio buttons which control the view mode
Added entry to DocumentMessage Enum
* draw in wireframe mode by changing parameters on each shape
added functions/changed behavior to do as above
not working yet
- newly added shapes should be drawn in wireframe
- setting fill to "none" on a path does not only draw an outline
- maybe the stroke width is 0?
* Wire frame view mostly functional for ellipses
- Need to implement for all shapes
- BUG: shapes don't immediatley update upon changing view-mode
* Fixed: active document now updates after view mode swap
* The Pros:
- wire frame mode effects all shapes correctly
The Cons:
- wire frame mode effects everything, including things that maybe shouldn't be, like select boxes and pen lines
* wire frame view no longer effects overlay layers
* Fixed: While in wireframe view the pen tool will draw regular thickness lines.
* some commenting
* Fixed potential bug:
In layer/file system with a Folder layer with a sub-layer that is also
a Folder cache_dirty must be set in order for all shapes to update properly
* refactored code to use ViewMode enum names throughout
* Changed: All wireframe lines are blank
cargo fmt
* Wireframe thickness doesn't change as a result of zooming
- Added DocumentMessage::ReRenderDocument, which marks layers as dirty and renders with the updated render-string
- All "zoom" messages in the movement_handler send a re-render message
- while in wireframe view, the "render-transform" of all shapes includes the root layer transform
Added getter/setter methods for graphene::Document::view_mode
* cargo fmt
* wireframe now has proper thickness after "Zoom Canvas to Fit all" action
* Refactored
- Changed FrontendMessage::UpdateCanvas to RenderDocument message to allow for lazy evaluation
- Created DocumentOperation::SetViewMode to be more consistent with existing code
- removed log statement
- Added constants for empty fill and thin-black stroke
* cargo fmt
* Removed ReRenderDocument message
* cargo fmt
* Fixes as suggested by TrueDoctor
* clean up merge
cargo fmt
* Refactor:
moved view_mode to DocumentMessageHandler
* Polishing
* changed those two comments
* Remove unknown todo comment
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
Keavon Chambers
parent
e13e9337f4
commit
20f154bc25
@@ -1,4 +1,5 @@
|
||||
pub mod style;
|
||||
use style::ViewMode;
|
||||
|
||||
use glam::DAffine2;
|
||||
use glam::{DMat2, DVec2};
|
||||
@@ -18,7 +19,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Write;
|
||||
|
||||
pub trait LayerData {
|
||||
fn render(&mut self, svg: &mut String, transforms: &mut Vec<glam::DAffine2>);
|
||||
fn render(&mut self, svg: &mut String, transforms: &mut Vec<glam::DAffine2>, view_mode: ViewMode);
|
||||
fn intersects_quad(&self, quad: Quad, path: &mut Vec<LayerId>, intersections: &mut Vec<Vec<LayerId>>);
|
||||
fn bounding_box(&self, transform: glam::DAffine2) -> Option<[DVec2; 2]>;
|
||||
}
|
||||
@@ -46,12 +47,14 @@ impl LayerDataType {
|
||||
}
|
||||
|
||||
impl LayerData for LayerDataType {
|
||||
fn render(&mut self, svg: &mut String, transforms: &mut Vec<glam::DAffine2>) {
|
||||
self.inner_mut().render(svg, transforms)
|
||||
fn render(&mut self, svg: &mut String, transforms: &mut Vec<glam::DAffine2>, view_mode: ViewMode) {
|
||||
self.inner_mut().render(svg, transforms, view_mode)
|
||||
}
|
||||
|
||||
fn intersects_quad(&self, quad: Quad, path: &mut Vec<LayerId>, intersections: &mut Vec<Vec<LayerId>>) {
|
||||
self.inner().intersects_quad(quad, path, intersections)
|
||||
}
|
||||
|
||||
fn bounding_box(&self, transform: glam::DAffine2) -> Option<[DVec2; 2]> {
|
||||
self.inner().bounding_box(transform)
|
||||
}
|
||||
@@ -102,14 +105,14 @@ impl Layer {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render(&mut self, transforms: &mut Vec<DAffine2>) -> &str {
|
||||
pub fn render(&mut self, transforms: &mut Vec<DAffine2>, view_mode: ViewMode) -> &str {
|
||||
if !self.visible {
|
||||
return "";
|
||||
}
|
||||
if self.cache_dirty {
|
||||
transforms.push(self.transform);
|
||||
self.thumbnail_cache.clear();
|
||||
self.data.render(&mut self.thumbnail_cache, transforms);
|
||||
self.data.render(&mut self.thumbnail_cache, transforms, if self.overlay { ViewMode::Normal } else { view_mode });
|
||||
|
||||
self.cache.clear();
|
||||
let _ = writeln!(self.cache, r#"<g transform="matrix("#);
|
||||
|
||||
Reference in New Issue
Block a user