mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 02:48:12 +08:00
Remake node type icons (closes #483); color picker cleanup
This commit is contained in:
@@ -162,7 +162,7 @@ impl MessageHandler<PropertiesPanelMessage, &GrapheneDocument> for PropertiesPan
|
||||
ModifyStroke { color, weight } => {
|
||||
let path = self.active_path.clone().expect("Received update for properties panel with no active layer");
|
||||
let layer = graphene_document.layer(&path).unwrap();
|
||||
if let Some(color) = Color::from_rgba_str(&color).or(Color::from_rgb_str(&color)) {
|
||||
if let Some(color) = Color::from_rgba_str(&color).or_else(|| Color::from_rgb_str(&color)) {
|
||||
let stroke = Stroke::new(color, weight as f32);
|
||||
responses.push_back(Operation::SetLayerStroke { path, stroke }.into())
|
||||
} else {
|
||||
@@ -214,15 +214,15 @@ fn register_layer_properties(layer: &Layer, responses: &mut VecDeque<Message>) {
|
||||
widgets: vec![
|
||||
match &layer.data {
|
||||
LayerDataType::Folder(_) => WidgetHolder::new(Widget::IconLabel(IconLabel {
|
||||
icon: "NodeTypeFolder".into(),
|
||||
icon: "NodeFolder".into(),
|
||||
gap_after: true,
|
||||
})),
|
||||
LayerDataType::Shape(_) => WidgetHolder::new(Widget::IconLabel(IconLabel {
|
||||
icon: "NodeTypePath".into(),
|
||||
icon: "NodePath".into(),
|
||||
gap_after: true,
|
||||
})),
|
||||
LayerDataType::Text(_) => WidgetHolder::new(Widget::IconLabel(IconLabel {
|
||||
icon: "NodeTypePath".into(),
|
||||
icon: "NodeText".into(),
|
||||
gap_after: true,
|
||||
})),
|
||||
},
|
||||
@@ -258,7 +258,7 @@ fn register_layer_properties(layer: &Layer, responses: &mut VecDeque<Message>) {
|
||||
vec![]
|
||||
}
|
||||
LayerDataType::Shape(shape) => {
|
||||
if let Some(fill_layout) = node_section_fill(&shape.style.fill()) {
|
||||
if let Some(fill_layout) = node_section_fill(shape.style.fill()) {
|
||||
vec![node_section_transform(layer), fill_layout, node_section_stroke(&shape.style.stroke().unwrap_or_default())]
|
||||
} else {
|
||||
vec![node_section_transform(layer), node_section_stroke(&shape.style.stroke().unwrap_or_default())]
|
||||
@@ -267,7 +267,7 @@ fn register_layer_properties(layer: &Layer, responses: &mut VecDeque<Message>) {
|
||||
LayerDataType::Text(text) => {
|
||||
vec![
|
||||
node_section_transform(layer),
|
||||
node_section_fill(&text.style.fill()).expect("Text should have fill"),
|
||||
node_section_fill(text.style.fill()).expect("Text should have fill"),
|
||||
node_section_stroke(&text.style.stroke().unwrap_or_default()),
|
||||
]
|
||||
}
|
||||
@@ -421,13 +421,13 @@ fn node_section_fill(fill: &Fill) -> Option<LayoutRow> {
|
||||
..TextLabel::default()
|
||||
})),
|
||||
WidgetHolder::new(Widget::Separator(Separator {
|
||||
separator_type: SeparatorType::Related,
|
||||
separator_type: SeparatorType::Unrelated,
|
||||
direction: SeparatorDirection::Horizontal,
|
||||
})),
|
||||
WidgetHolder::new(Widget::ColorInput(ColorInput {
|
||||
value: color.rgba_hex(),
|
||||
on_update: WidgetCallback::new(|text_input: &ColorInput| {
|
||||
if let Some(color) = Color::from_rgba_str(&text_input.value).or(Color::from_rgb_str(&text_input.value)) {
|
||||
if let Some(color) = Color::from_rgba_str(&text_input.value).or_else(|| Color::from_rgb_str(&text_input.value)) {
|
||||
let new_fill = Fill::Solid(color);
|
||||
PropertiesPanelMessage::ModifyFill { fill: new_fill }.into()
|
||||
} else {
|
||||
@@ -452,13 +452,13 @@ fn node_section_fill(fill: &Fill) -> Option<LayoutRow> {
|
||||
..TextLabel::default()
|
||||
})),
|
||||
WidgetHolder::new(Widget::Separator(Separator {
|
||||
separator_type: SeparatorType::Related,
|
||||
separator_type: SeparatorType::Unrelated,
|
||||
direction: SeparatorDirection::Horizontal,
|
||||
})),
|
||||
WidgetHolder::new(Widget::ColorInput(ColorInput {
|
||||
value: gradient_1.positions[0].1.rgba_hex(),
|
||||
on_update: WidgetCallback::new(move |text_input: &ColorInput| {
|
||||
if let Some(color) = Color::from_rgba_str(&text_input.value).or(Color::from_rgb_str(&text_input.value)) {
|
||||
if let Some(color) = Color::from_rgba_str(&text_input.value).or_else(|| Color::from_rgb_str(&text_input.value)) {
|
||||
let mut new_gradient = (*gradient_1).clone();
|
||||
new_gradient.positions[0].1 = color;
|
||||
PropertiesPanelMessage::ModifyFill {
|
||||
@@ -480,13 +480,13 @@ fn node_section_fill(fill: &Fill) -> Option<LayoutRow> {
|
||||
..TextLabel::default()
|
||||
})),
|
||||
WidgetHolder::new(Widget::Separator(Separator {
|
||||
separator_type: SeparatorType::Related,
|
||||
separator_type: SeparatorType::Unrelated,
|
||||
direction: SeparatorDirection::Horizontal,
|
||||
})),
|
||||
WidgetHolder::new(Widget::ColorInput(ColorInput {
|
||||
value: gradient_2.positions[1].1.rgba_hex(),
|
||||
on_update: WidgetCallback::new(move |text_input: &ColorInput| {
|
||||
if let Some(color) = Color::from_rgba_str(&text_input.value).or(Color::from_rgb_str(&text_input.value)) {
|
||||
if let Some(color) = Color::from_rgba_str(&text_input.value).or_else(|| Color::from_rgb_str(&text_input.value)) {
|
||||
let mut new_gradient = (*gradient_2).clone();
|
||||
new_gradient.positions[1].1 = color;
|
||||
PropertiesPanelMessage::ModifyFill {
|
||||
@@ -521,7 +521,7 @@ fn node_section_stroke(stroke: &Stroke) -> LayoutRow {
|
||||
..TextLabel::default()
|
||||
})),
|
||||
WidgetHolder::new(Widget::Separator(Separator {
|
||||
separator_type: SeparatorType::Related,
|
||||
separator_type: SeparatorType::Unrelated,
|
||||
direction: SeparatorDirection::Horizontal,
|
||||
})),
|
||||
WidgetHolder::new(Widget::ColorInput(ColorInput {
|
||||
@@ -544,7 +544,7 @@ fn node_section_stroke(stroke: &Stroke) -> LayoutRow {
|
||||
..TextLabel::default()
|
||||
})),
|
||||
WidgetHolder::new(Widget::Separator(Separator {
|
||||
separator_type: SeparatorType::Related,
|
||||
separator_type: SeparatorType::Unrelated,
|
||||
direction: SeparatorDirection::Horizontal,
|
||||
})),
|
||||
WidgetHolder::new(Widget::NumberInput(NumberInput {
|
||||
|
||||
Reference in New Issue
Block a user