mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-25 17:28:11 +08:00
Add rank-0 Item leaf variants to the Graphic enum alongside its List variants (#4437)
* Add the rank-0 Item leaf variants to the Graphic enum, rendering leaves and list rows through shared per-row logic * Traverse the rank-0 Graphic leaf variants in the vector node helpers and flattening * Reach rank-0 vector graphics from the styling and gradient-fitting helpers * Two code review fixes * Fix comment
This commit is contained in:
@@ -934,10 +934,10 @@ pub async fn wrap_graphic<T: Into<Graphic> + 'n>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
List<Graphic>,
|
||||
List<Vector>,
|
||||
List<Vector>,
|
||||
List<Raster<CPU>>,
|
||||
List<Raster<GPU>>,
|
||||
List<Color>,
|
||||
List<Raster<GPU>>,
|
||||
List<Color>,
|
||||
List<Gradient>,
|
||||
List<String>,
|
||||
Item<DAffine2>,
|
||||
@@ -981,6 +981,12 @@ pub async fn flatten_graphic(_: impl Ctx, content: List<Graphic>, fully_flatten:
|
||||
|
||||
let recurse = fully_flatten || recursion_depth == 0;
|
||||
|
||||
// A boxed single graphic is the rank-0 spelling of the same nesting, so it flattens through the list path
|
||||
let current_element = match current_element {
|
||||
Graphic::Graphic(item) if recurse => Graphic::GraphicList(List::new_from_item(*item)),
|
||||
element => element,
|
||||
};
|
||||
|
||||
match current_element {
|
||||
// If we're allowed to recurse, flatten any graphics we encounter
|
||||
Graphic::GraphicList(mut current_element) if recurse => {
|
||||
|
||||
Reference in New Issue
Block a user