Skip to content

Commit 672e6c8

Browse files
committed
Move the new traits to a better place.
1 parent 0aa0f71 commit 672e6c8

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

editor/src/messages/portfolio/document/node_graph/node_properties.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use graphene_core::raster::{
1616
BlendMode, CellularDistanceFunction, CellularReturnType, Color, DomainWarpType, FractalType, LuminanceCalculation, NoiseType, RedGreenBlue, RedGreenBlueAlpha, RelativeAbsolute,
1717
SelectiveColorChoice,
1818
};
19-
use graphene_core::registry::VariantMetadata;
19+
use graphene_core::registry::{ChoiceTypeStatic, ChoiceWidgetHint, VariantMetadata};
2020
use graphene_core::text::Font;
2121
use graphene_core::vector::misc::CentroidType;
2222
use graphene_core::vector::style::{GradientType, LineCap, LineJoin};
@@ -95,13 +95,13 @@ trait ChoiceSource {
9595
fn into_tagged_value(v: Self::Value) -> TaggedValue;
9696
fn from_tagged_value(tv: Option<&TaggedValue>) -> Option<Self::Value>;
9797
fn enumerate() -> impl Iterator<Item = impl Iterator<Item = &'static (Self::Value, VariantMetadata)>>;
98-
fn widget_hint() -> graphene_core::vector::misc::ChoiceWidgetHint;
98+
fn widget_hint() -> ChoiceWidgetHint;
9999
}
100100

101-
struct ChoiceSourceStatic<T: graphene_core::vector::misc::ChoiceTypeStatic>(std::marker::PhantomData<T>);
101+
struct ChoiceSourceStatic<T: ChoiceTypeStatic>(std::marker::PhantomData<T>);
102102
impl<T> ChoiceSource for ChoiceSourceStatic<T>
103103
where
104-
T: graphene_core::vector::misc::ChoiceTypeStatic + 'static,
104+
T: ChoiceTypeStatic + 'static,
105105
for<'a> &'a T: TryFrom<&'a TaggedValue>,
106106
TaggedValue: From<T>,
107107
{
@@ -120,12 +120,12 @@ where
120120
fn enumerate() -> impl Iterator<Item = impl Iterator<Item = &'static (Self::Value, VariantMetadata)>> {
121121
T::list().into_iter().map(|i| i.into_iter())
122122
}
123-
fn widget_hint() -> graphene_core::vector::misc::ChoiceWidgetHint {
123+
fn widget_hint() -> ChoiceWidgetHint {
124124
T::WIDGET_HINT
125125
}
126126
}
127127

128-
fn enum_source<E: graphene_core::vector::misc::ChoiceTypeStatic>() -> ChoiceSourceStatic<E> {
128+
fn enum_source<E: ChoiceTypeStatic>() -> ChoiceSourceStatic<E> {
129129
ChoiceSourceStatic(std::marker::PhantomData)
130130
}
131131

@@ -139,8 +139,8 @@ fn choice_widget<E: ChoiceSource>(list: E, document_node: &DocumentNode, node_id
139139

140140
if let Some(current) = E::from_tagged_value(input.as_non_exposed_value()) {
141141
let widget = match E::widget_hint() {
142-
graphene_std::vector::misc::ChoiceWidgetHint::Dropdown => dropdown(list, node_id, index, current),
143-
graphene_std::vector::misc::ChoiceWidgetHint::RadioButtons => radio_buttons(list, node_id, index, current),
142+
ChoiceWidgetHint::Dropdown => dropdown(list, node_id, index, current),
143+
ChoiceWidgetHint::RadioButtons => radio_buttons(list, node_id, index, current),
144144
};
145145
widgets.extend_from_slice(&[Separator::new(SeparatorType::Unrelated).widget_holder(), widget]);
146146
}

editor/src/messages/portfolio/menu_bar/menu_bar_message_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl LayoutHolder for MenuBarMessageHandler {
414414
action: MenuBarEntry::no_action(),
415415
disabled: no_active_document || !has_selected_layers,
416416
children: MenuBarEntryChildren(vec![{
417-
let list = <BooleanOperation as graphene_core::vector::misc::ChoiceTypeStatic>::list();
417+
let list = <BooleanOperation as graphene_core::registry::ChoiceTypeStatic>::list();
418418
list.into_iter()
419419
.map(|i| i.into_iter())
420420
.flatten()

editor/src/messages/tool/tool_messages/select_tool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl SelectTool {
180180
}
181181

182182
fn boolean_widgets(&self, selected_count: usize) -> impl Iterator<Item = WidgetHolder> + use<> {
183-
let list = <BooleanOperation as graphene_core::vector::misc::ChoiceTypeStatic>::list();
183+
let list = <BooleanOperation as graphene_core::registry::ChoiceTypeStatic>::list();
184184
list.into_iter().map(|i| i.into_iter()).flatten().map(move |(operation, info)| {
185185
let mut tooltip = info.label.to_string();
186186
if let Some(doc) = info.docstring.as_deref() {

node-graph/gcore/src/registry.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ pub struct FieldMetadata {
5252
pub number_mode_range: Option<(f64, f64)>,
5353
}
5454

55+
pub trait ChoiceTypeStatic: Sized + Copy + crate::vector::misc::AsU32 + std::fmt::Display + std::fmt::Debug + Send + Sync {
56+
const WIDGET_HINT: ChoiceWidgetHint;
57+
fn list() -> &'static [&'static [(Self, VariantMetadata)]];
58+
}
59+
60+
pub enum ChoiceWidgetHint {
61+
Dropdown,
62+
RadioButtons,
63+
}
64+
5565
// Translation struct between macro and definition
5666
#[derive(Clone, Debug)]
5767
pub struct VariantMetadata {

node-graph/gcore/src/vector/misc.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ pub enum BooleanOperation {
3131
Difference,
3232
}
3333

34-
pub trait ChoiceTypeStatic: Sized + Copy + AsU32 + std::fmt::Display + std::fmt::Debug + Send + Sync {
35-
const WIDGET_HINT: ChoiceWidgetHint;
36-
fn list() -> &'static [&'static [(Self, crate::registry::VariantMetadata)]];
37-
}
38-
39-
pub enum ChoiceWidgetHint {
40-
Dropdown,
41-
RadioButtons,
42-
}
43-
4434
pub trait AsU32 {
4535
fn as_u32(&self) -> u32;
4636
}

node-graph/node-macro/src/derive_choice_type.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ fn derive_enum(enum_attrs: &[Attribute], name: Ident, input: syn::DataEnum) -> s
165165
}
166166
}
167167

168-
impl #crate_name::vector::misc::ChoiceTypeStatic for #name {
169-
const WIDGET_HINT: #crate_name::vector::misc::ChoiceWidgetHint = #crate_name::vector::misc::ChoiceWidgetHint::#widget_hint;
168+
impl #crate_name::registry::ChoiceTypeStatic for #name {
169+
const WIDGET_HINT: #crate_name::registry::ChoiceWidgetHint = #crate_name::registry::ChoiceWidgetHint::#widget_hint;
170170
fn list() -> &'static [&'static [(Self, #crate_name::registry::VariantMetadata)]] {
171171
&[ #(#group)* ]
172172
}

0 commit comments

Comments
 (0)