mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
This commit is contained in:
commit
9547aec94a
2 files changed
+34
-2
No files matched your search
@@ -412,6 +412,34 @@ fn color_wheel_ignores_clicks_beside_it() {
|
||||
assert_eq!(bytes(h.state().session.tools.foreground), [0, 0, 255]);
|
||||
}
|
||||
|
||||
/// The Color Wheel shrinks to the Color group at its default height in every theme, as the
|
||||
/// slider modes' ramp does, instead of running past the group's bottom into its scroll area.
|
||||
#[test]
|
||||
fn color_wheel_fits_the_default_color_group() {
|
||||
for kind in ThemeKind::ALL {
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.ui.color_panel.mode = ColorPanelMode::ColorWheel;
|
||||
app.ui.theme = kind;
|
||||
app.ui.dock_tabs.color = Group::Color.tabs(Tokens::for_kind(kind).pro).iter().position(|name| *name == "Color").unwrap();
|
||||
let mut h = Harness::builder().with_size(vec2(1440.0, 1200.0)).build_ui_state(
|
||||
|ui, app: &mut PhotocraftApp| {
|
||||
if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {
|
||||
crate::panels::dock_area(app, ui);
|
||||
egui::CentralPanel::default().show(ui, |_| {});
|
||||
}
|
||||
},
|
||||
app,
|
||||
);
|
||||
PhotocraftApp::setup_context(&h.ctx, kind);
|
||||
h.run_steps(4);
|
||||
let group = crate::panel_docking::probe::native_group_rect(h.state(), &h.ctx, Group::Color).unwrap();
|
||||
assert!((group.height() - Group::Color.default_height()).abs() < 0.5, "{kind:?}: Color group {group:?}");
|
||||
let wheel = h.query_by_label("Color Wheel").unwrap_or_else(|| panic!("{kind:?}: no Color Wheel")).rect();
|
||||
// The group's scroll area ends at least 8 pt above its bottom edge (the card's bottom margin).
|
||||
assert!(wheel.bottom() <= group.bottom() - 8.0, "{kind:?}: wheel {wheel:?} runs past the Color group {group:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The Color tab in `mode` with a document holding one selected black rectangle, the Rectangle tool
|
||||
/// in hand, foreground blue and background red, editing the background chip if `background`.
|
||||
fn color_tab_with_a_shape(mode: ColorPanelMode, background: bool) -> Harness<'static, PhotocraftApp> {
|
||||
|
||||
@@ -537,6 +537,7 @@ fn rgb3(c: [f32; 4]) -> [f32; 3] {
|
||||
/// other corners; the add-to-swatches button sits under it.
|
||||
fn wheel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let top = ui.cursor().top();
|
||||
let background = app.ui.color_panel.background;
|
||||
let rgb = active(app);
|
||||
let v = current_values(ui, Model::Hsb, background, rgb);
|
||||
@@ -556,9 +557,12 @@ fn wheel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
|
||||
let mut changed = edited.is_some();
|
||||
ui.add_space(6.0);
|
||||
let fill = ui.data(|d| d.get_temp::<f32>(color_field_fill_id()));
|
||||
let gaps = 2.0 * ui.spacing().item_spacing.y + 6.0;
|
||||
let w = ui.available_width();
|
||||
let side = fill.filter(|f| f.is_finite()).map_or(w.min(220.0), |f| (f - top_h - gaps).min(w)).max(80.0);
|
||||
// The wheel takes what the dock group has left under the sliders as drawn (they stand taller
|
||||
// than `ROW_H`), down to 28 pt as the slider modes' ramp: an estimate and an 80 pt floor ran
|
||||
// it past the bottom of the Color group at its default height.
|
||||
let used = ui.cursor().top() - top;
|
||||
let side = fill.filter(|f| f.is_finite()).map_or(w.min(220.0), |f| (f - used).min(w)).max(28.0);
|
||||
let (area, resp) = ui.allocate_exact_size(vec2(w, side), Sense::click_and_drag());
|
||||
resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Unknown, ui.is_enabled(), "Color Wheel"));
|
||||
let (center, inner, outer) = wheel_geometry(area);
|
||||
|
||||
Reference in new issue
Block a user