mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 10:13:09 -06:00
Canvas grid: production's faint ink, a line every spacing at any zoom
The grid takes production's black at alpha 40 instead of the overlay grid grey, and GridCrowding::Dense, so it keeps the grid spacing zoomed out as production does instead of doubling it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
97a6f1c5fc
commit
7336202afb
@@ -4,6 +4,7 @@ use craft::theme::Rgba;
|
||||
use craft::ui::canvas::{CanvasSpace, Guide, GuideKey, GuideLine};
|
||||
use craft::ui::canvas_controls::{CanvasGrid, GridCrowding, GuideReadout, Guides};
|
||||
use craft::ui::contract::{Bind, Show as _};
|
||||
use craft::ui::style::DataColor;
|
||||
use deckcraft_engine::ToolKind;
|
||||
use deckcraft_model::DrawGuide;
|
||||
use serde_json::json;
|
||||
@@ -13,6 +14,9 @@ use crate::SlideApp;
|
||||
/// The drawing guides' ink: one see-through mid grey in every theme, so a guide reads on any slide.
|
||||
const GUIDE_INK: Rgba = Rgba([120, 120, 120, 170]);
|
||||
|
||||
/// The grid's ink: a faint black in every theme, light over the slide's text and pictures.
|
||||
const GRID_INK: Rgba = Rgba([0, 0, 0, 40]);
|
||||
|
||||
/// Selected guide indices and the document guide list they identify; never saved.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub(crate) struct GuideSelection {
|
||||
@@ -23,7 +27,7 @@ pub(crate) struct GuideSelection {
|
||||
represented: Vec<DrawGuide>,
|
||||
}
|
||||
|
||||
/// Shows the document grid within the slide's bounds.
|
||||
/// Shows the document grid within the slide's bounds: a line every grid spacing at any zoom, a faint wash zoomed out.
|
||||
pub(crate) fn show_grid(app: &mut SlideApp, ui: &mut egui::Ui, space: &CanvasSpace) {
|
||||
if !app.ui.gridlines {
|
||||
return;
|
||||
@@ -31,11 +35,13 @@ pub(crate) fn show_grid(app: &mut SlideApp, ui: &mut egui::Ui, space: &CanvasSpa
|
||||
let Some(st) = app.session.active() else { return };
|
||||
let size = st.doc.slide_size;
|
||||
let spacing = app.session.prefs.grid_spacing;
|
||||
let [r, g, b, a] = GRID_INK.0;
|
||||
let _ = CanvasGrid::new("Grid")
|
||||
.spacing(Vec2::new(spacing, spacing))
|
||||
.origin(Point::ZERO)
|
||||
.bounds(Rect::new(0.0, 0.0, size.width, size.height))
|
||||
.crowding(GridCrowding::Thin)
|
||||
.color(DataColor::new(egui::Color32::from_rgba_unmultiplied(r, g, b, a)))
|
||||
.crowding(GridCrowding::Dense)
|
||||
.show_at(ui, space.view.rect);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user