egui: highlight selected zones

This commit is contained in:
Mikolaj Wielgus 2024-04-18 16:35:10 +02:00
parent 43f1248a76
commit 8a6b0724e9
1 changed files with 26 additions and 8 deletions

View File

@ -152,13 +152,13 @@ impl eframe::App for App {
); );
} }
for node in layout.drawing().layer_primitive_nodes(1) { for primitive in layout.drawing().layer_primitive_nodes(1) {
let shape = node.primitive(layout.drawing()).shape(); let shape = primitive.primitive(layout.drawing()).shape();
let color = if self let color = if self
.overlay .overlay
.selection() .selection()
.contains(&GenericNode::Primitive(node)) .contains(&GenericNode::Primitive(primitive))
{ {
egui::Color32::from_rgb(100, 100, 255) egui::Color32::from_rgb(100, 100, 255)
} else { } else {
@ -168,22 +168,31 @@ impl eframe::App for App {
} }
for zone in layout.layer_zones(1) { for zone in layout.layer_zones(1) {
let color = if self
.overlay
.selection()
.contains(&GenericNode::Compound(zone))
{
egui::Color32::from_rgb(100, 100, 255)
} else {
egui::Color32::from_rgb(52, 52, 200)
};
painter.paint_polygon( painter.paint_polygon(
&layout &layout
.compound_weight(zone) .compound_weight(zone)
.shape(&layout.drawing(), zone) .shape(&layout.drawing(), zone)
.polygon, .polygon,
egui::Color32::from_rgb(52, 52, 200), color,
) )
} }
for node in layout.drawing().layer_primitive_nodes(0) { for primitive in layout.drawing().layer_primitive_nodes(0) {
let shape = node.primitive(layout.drawing()).shape(); let shape = primitive.primitive(layout.drawing()).shape();
let color = if self let color = if self
.overlay .overlay
.selection() .selection()
.contains(&GenericNode::Primitive(node)) .contains(&GenericNode::Primitive(primitive))
{ {
egui::Color32::from_rgb(255, 100, 100) egui::Color32::from_rgb(255, 100, 100)
} else { } else {
@ -193,12 +202,21 @@ impl eframe::App for App {
} }
for zone in layout.layer_zones(0) { for zone in layout.layer_zones(0) {
let color = if self
.overlay
.selection()
.contains(&GenericNode::Compound(zone))
{
egui::Color32::from_rgb(255, 100, 100)
} else {
egui::Color32::from_rgb(200, 52, 52)
};
painter.paint_polygon( painter.paint_polygon(
&layout &layout
.compound_weight(zone) .compound_weight(zone)
.shape(&layout.drawing(), zone) .shape(&layout.drawing(), zone)
.polygon, .polygon,
egui::Color32::from_rgb(200, 52, 52), color,
) )
} }
} }