Fix grid overlay color showing as none

This commit is contained in:
Keavon Chambers 2024-07-27 17:09:10 -07:00
parent d6dad92659
commit a4a513911d
4 changed files with 9 additions and 5 deletions

View file

@ -11,7 +11,7 @@ use graphene_std::vector::style::FillChoice;
fn grid_overlay_rectangular(document: &DocumentMessageHandler, overlay_context: &mut OverlayContext, spacing: DVec2) {
let origin = document.snapping_state.grid.origin;
let grid_color: Color = document.snapping_state.grid.grid_color;
let grid_color = document.snapping_state.grid.grid_color;
let Some(spacing) = GridSnapping::compute_rectangle_spacing(spacing, &document.document_ptz) else {
return;
};
@ -51,7 +51,7 @@ fn grid_overlay_rectangular(document: &DocumentMessageHandler, overlay_context:
// The draw dashed line method will also be not grid aligned for tilted grids.
// TODO: Potentially create an image and render the image onto the canvas a single time.
// TODO: Implement this with a dashed line (`set_line_dash`), with integer spacing which is continuously adjusted to correct the accumulated error.
fn grid_overlay_dot(document: &DocumentMessageHandler, overlay_context: &mut OverlayContext, spacing: DVec2) {
fn grid_overlay_rectangular_dot(document: &DocumentMessageHandler, overlay_context: &mut OverlayContext, spacing: DVec2) {
let origin = document.snapping_state.grid.origin;
let grid_color = document.snapping_state.grid.grid_color;
let Some(spacing) = GridSnapping::compute_rectangle_spacing(spacing, &document.document_ptz) else {
@ -188,7 +188,7 @@ pub fn grid_overlay(document: &DocumentMessageHandler, overlay_context: &mut Ove
match document.snapping_state.grid.grid_type {
GridType::Rectangle { spacing } => {
if document.snapping_state.grid.dot_display {
grid_overlay_dot(document, overlay_context, spacing)
grid_overlay_rectangular_dot(document, overlay_context, spacing)
} else {
grid_overlay_rectangular(document, overlay_context, spacing)
}
@ -276,6 +276,7 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
color_widgets.push(
ColorButton::new(FillChoice::Solid(grid.grid_color))
.tooltip("Grid display color")
.allow_none(false)
.on_update(update_color(grid, |grid| Some(&mut grid.grid_color)))
.widget_holder(),
);

View file

@ -812,6 +812,7 @@ export class CheckboxInput extends WidgetProps {
export class ColorButton extends WidgetProps {
@Transform(({ value }) => {
if (value instanceof Gradient) return value;
const gradient = value["Gradient"];
if (gradient) {
const stops = gradient.map(([position, color]: [number, color: { red: number; green: number; blue: number; alpha: number }]) => ({
@ -821,6 +822,7 @@ export class ColorButton extends WidgetProps {
return new Gradient(stops);
}
if (value instanceof Color) return value;
const solid = value["Solid"];
if (solid) {
return new Color(solid.red, solid.green, solid.blue, solid.alpha);

View file

@ -95,7 +95,8 @@ impl log::Log for WasmLog {
let file = record.file().unwrap_or_else(|| record.target());
let line = record.line().map_or_else(|| "[Unknown]".to_string(), |line| line.to_string());
let msg = &format!("%c{} {file}:{line} \n{}%c", name, record.args());
let args = record.args();
let msg = &format!("%c{name}\t{file}:{line}\n{args}"); // The %c is replaced by the message color
log(msg, color)
}

View file

@ -12,7 +12,7 @@ mod base64_serde {
use super::super::Pixel;
use base64::Engine;
use serde::{ser::SerializeTuple, Deserialize, Deserializer, Serialize, Serializer};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
pub fn as_base64<S, P: Pixel>(key: &[P], serializer: S) -> Result<S::Ok, S::Error>
where