Revolve gizmo: the rings, plates and readouts draw through the content painter's own painter, and the Transparency panel imports DataColor with the other style types

This commit is contained in:
dotCooCoo
2026-11-24 17:02:27 -08:00
parent 95c0d489ad
commit 854feab983
2 changed files with 7 additions and 8 deletions
+5 -7
View File
@@ -22,7 +22,7 @@ use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDia
use craft::ui::primitives::{ContentPainterCx, TextRun};
use craft::ui::runtime::focus::KeyUse;
use craft::ui::style::{ComponentStyle, StyleColor, StyleCx, TypeRole};
use egui::{Painter, Pos2, Rect, Response, Stroke, Ui, Vec2, vec2};
use egui::{Pos2, Rect, Response, Stroke, Ui, Vec2, vec2};
use serde_json::json;
use vectorcraft_effects::{CLASSIC_REVOLVE, REVOLVE};
use vectorcraft_geom::Point;
@@ -572,7 +572,6 @@ impl Component for RevolveGizmo<'_> {
let content = ui.content_painter(cx);
let paint = Paint {
content: &content,
painter: &content.painter,
style: cx.style,
view: &space.view,
subject: self.subject,
@@ -610,9 +609,8 @@ fn light_position(g: Geometry, options: Revolve) -> Pos2 {
/// What a pass draws with.
struct Paint<'a> {
/// The content painter, which lays out and paints the labels.
/// The content painter: its `painter` draws the rings and plates, and its `Draw` lays out and paints the labels.
content: &'a ContentPainterCx<'a>,
painter: &'a Painter,
style: &'a RevolveGizmoStyle,
view: &'a CanvasView,
subject: &'a Subject,
@@ -626,7 +624,7 @@ struct Paint<'a> {
impl Paint<'_> {
fn rotation(&self) {
let (g, s, painter) = (self.g, self.style, self.painter);
let (g, s, painter) = (self.g, self.style, &self.content.painter);
for (axis, ring) in g.rings.iter().enumerate() {
let hot = self.active == Some(axis);
let ink = if hot { s.hot } else { s.axis(axis) };
@@ -668,7 +666,7 @@ impl Paint<'_> {
}
fn light(&self) {
let (g, s, painter) = (self.g, self.style, self.painter);
let (g, s, painter) = (self.g, self.style, &self.content.painter);
let options = light_options(&self.subject.fields);
let radius = g.radius * 1.4;
painter.circle_stroke(g.center, radius, Stroke::new(1.0, s.muted.egui().gamma_multiply(0.3)));
@@ -732,7 +730,7 @@ impl Paint<'_> {
/// `text` on a plate centred at `at`.
fn readout(&self, text: &str, at: Pos2) {
let (s, painter) = (self.style, self.painter);
let (s, painter) = (self.style, &self.content.painter);
self.text(text, s.ink, |size| {
painter.rect_filled(Rect::from_center_size(at, size + vec2(14.0, 8.0)), 4.0, s.plate.egui());
at - size * 0.5
+2 -1
View File
@@ -25,6 +25,7 @@ use craft::ui::primitives::{
use craft::ui::primitives::{Revision, ThumbPaint};
use craft::ui::runtime::commands::{CommandRef, CommandState, CommandStates};
use craft::ui::runtime::env::UnitKind;
use craft::ui::style::DataColor;
use craft::ui::text::NumberField;
use egui::{Color32, Ui};
use serde_json::{Value, json};
@@ -193,7 +194,7 @@ fn mask_row(
store.paint(cx, rect, s, paper);
}
if disabled {
let red = craft::ui::style::DataColor::new(super::swatches::OFF_MARK);
let red = DataColor::new(super::swatches::OFF_MARK);
cx.with_draw(|draw| {
for line in [[rect.left_top(), rect.right_bottom()], [rect.right_top(), rect.left_bottom()]] {
draw.stroke(&PaintShape::Path(line.to_vec()), StrokeWidth::Thick, red);