mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 18:23:52 -06:00
Ribbon: one Shape Fill helper for Home and Shape Format
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d44cee711c
commit
d59e65550c
@@ -279,6 +279,19 @@ pub(super) fn kurbo_flatten(path: &deckcraft_geom::BezPath, mut f: impl FnMut(Fl
|
||||
});
|
||||
}
|
||||
|
||||
/// Applies a Shape Fill pick (Home and Shape Format), remembering a colour for the split button.
|
||||
pub(super) fn apply_fill(app: &mut SlideApp, pick: Option<deckcraft_model::ColorRef>) {
|
||||
let params = match pick {
|
||||
Some(color) => {
|
||||
let color = cref_param(&color);
|
||||
app.last_fill = color.clone();
|
||||
json!({"color": color})
|
||||
}
|
||||
None => json!({"none": true}),
|
||||
};
|
||||
let _ = app.run("shape.fill", params);
|
||||
}
|
||||
|
||||
fn apply_line_pick(app: &mut SlideApp, pick: Option<deckcraft_model::ColorRef>) {
|
||||
let params = match pick {
|
||||
Some(color) => {
|
||||
|
||||
@@ -17,7 +17,9 @@ use egui::{Color32, Ui};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::arrange::arrange_menu;
|
||||
use super::galleries::{self, LayoutPick, cref_param, effects_menu, layout_gallery, outline_menu, quick_styles, shapes_gallery, smartart_gallery};
|
||||
use super::galleries::{
|
||||
self, LayoutPick, apply_fill, cref_param, effects_menu, layout_gallery, outline_menu, quick_styles, shapes_gallery, smartart_gallery,
|
||||
};
|
||||
use super::{fmt_state, fonts};
|
||||
use crate::SlideApp;
|
||||
use crate::icons::Icon;
|
||||
@@ -431,18 +433,6 @@ fn drawing(app: &mut SlideApp, ui: &mut Ui) {
|
||||
});
|
||||
}
|
||||
|
||||
fn apply_fill(app: &mut SlideApp, pick: Option<deckcraft_model::ColorRef>) {
|
||||
let params = match pick {
|
||||
Some(color) => {
|
||||
let color = cref_param(&color);
|
||||
app.last_fill = color.clone();
|
||||
json!({"color": color})
|
||||
}
|
||||
None => json!({"none": true}),
|
||||
};
|
||||
let _ = app.run("shape.fill", params);
|
||||
}
|
||||
|
||||
/// Opens the Home tab's groups in document-editing order.
|
||||
pub(crate) fn home(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
// Answers are taken outside group bodies because those bodies also run for measurement.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::arrange::{arrange_group, size_group};
|
||||
use super::galleries::{apply_line_answer, cref_param, effects_menu, outline_menu, quick_styles, shapes_gallery};
|
||||
use super::galleries::{apply_fill, apply_line_answer, cref_param, effects_menu, outline_menu, quick_styles, shapes_gallery};
|
||||
use super::{Icon, SlideApp, Ui, json};
|
||||
use crate::panels::color_row::{color_menu, take_color_answer};
|
||||
use craft::behavior::{Selection, SelectionChange};
|
||||
@@ -240,17 +240,6 @@ pub(crate) fn shape_format(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
});
|
||||
}
|
||||
|
||||
fn apply_fill(app: &mut SlideApp, pick: Option<deckcraft_model::ColorRef>) {
|
||||
let params = match pick {
|
||||
Some(color) => {
|
||||
app.last_fill = cref_param(&color);
|
||||
json!({"color": app.last_fill.clone()})
|
||||
}
|
||||
None => json!({"none": true}),
|
||||
};
|
||||
let _ = app.run("shape.fill", params);
|
||||
}
|
||||
|
||||
fn apply_text_color(app: &mut SlideApp, command: &str, pick: Option<deckcraft_model::ColorRef>) {
|
||||
let _ = app.run(command, json!({"color": pick.as_ref().map(cref_param)}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user