Move viewport preferences into a cog dropdown
This commit is contained in:
parent
229412af22
commit
c8389c9ef7
|
|
@ -232,7 +232,6 @@ impl Editor {
|
|||
let ratio=d.layer_aspect.ratio().unwrap_or(old[0]/old[1]);
|
||||
if d.size[0]!=old[0] { d.size[1]=d.size[0]/ratio; } else if d.size[1]!=old[1] { d.size[0]=d.size[1]*ratio; }
|
||||
}
|
||||
ui.checkbox(&mut self.keep_aspect_ratio,"Keep aspect ratio when resizing");
|
||||
}
|
||||
if self.property_tab != PropertyTab::Crop {
|
||||
let g=self.layout.layers()[i];
|
||||
|
|
@ -283,7 +282,6 @@ impl Editor {
|
|||
if ui.add(egui::Button::new(if self.edit_content { "Done adjusting crop" } else { "Adjust layer crop" }).selected(self.edit_content)).clicked() {
|
||||
self.edit_content = !self.edit_content;
|
||||
}
|
||||
ui.checkbox(&mut self.show_pattern,"Show source-coordinate test pattern in viewport");
|
||||
let (_,rect)=ui.allocate_space(Vec2::new(ui.available_width(),170.0));
|
||||
let preview_rect=fit_rect(rect,[current.width,current.height]);
|
||||
paint_pattern(ui.painter(),preview_rect,self.layout.formats().sources[self.layout.formats().source_for[i]],self.layout.formats().advanced[i]);
|
||||
|
|
|
|||
|
|
@ -1085,7 +1085,6 @@ impl Editor {
|
|||
});
|
||||
}
|
||||
if !selected.is_empty() {
|
||||
ui.checkbox(&mut self.keep_aspect_ratio, "Keep aspect ratio");
|
||||
ui.menu_button("Align…", |ui| self.alignment_menu(ui));
|
||||
ui.separator();
|
||||
if ui.button("Copy layer values").clicked() {
|
||||
|
|
@ -1457,12 +1456,42 @@ impl Editor {
|
|||
ui.menu_button("Project", |ui| self.project_menu(ui));
|
||||
},
|
||||
);
|
||||
ui.put(
|
||||
Rect::from_min_size(ink.point(24.0, 63.0), Vec2::new(310.0, 20.0)),
|
||||
egui::Checkbox::new(
|
||||
&mut self.keep_aspect_ratio,
|
||||
"Keep aspect ratio when resizing",
|
||||
),
|
||||
ui.scope_builder(
|
||||
egui::UiBuilder::new()
|
||||
.max_rect(Rect::from_min_size(
|
||||
ink.point(424.0, 21.0),
|
||||
Vec2::new(36.0, 34.0),
|
||||
))
|
||||
.layout(egui::Layout::left_to_right(egui::Align::Center)),
|
||||
|ui| {
|
||||
ui.spacing_mut().interact_size = Vec2::new(36.0, 34.0);
|
||||
ui.spacing_mut().button_padding.x = 11.0;
|
||||
let menu = ui.menu_button(" ", |ui| {
|
||||
ui.checkbox(
|
||||
&mut self.keep_aspect_ratio,
|
||||
"Keep aspect ratio when resizing",
|
||||
);
|
||||
ui.checkbox(
|
||||
&mut self.show_pattern,
|
||||
"Show source-coordinate test pattern in viewport",
|
||||
);
|
||||
});
|
||||
let response = menu.response.on_hover_text("Viewport options");
|
||||
response.widget_info(|| {
|
||||
egui::WidgetInfo::labeled(egui::WidgetType::Button, true, "Viewport options")
|
||||
});
|
||||
let center = response.rect.center();
|
||||
let stroke = Stroke::new(1.6_f32, if response.hovered() { CYAN } else { TEXT });
|
||||
let points = (0..32)
|
||||
.map(|i| {
|
||||
let angle = i as f32 * std::f32::consts::TAU / 32.0;
|
||||
let radius = if i % 4 == 0 || i % 4 == 3 { 8.0 } else { 11.0 };
|
||||
center + Vec2::angled(angle) * radius
|
||||
})
|
||||
.collect();
|
||||
ui.painter().add(egui::Shape::closed_line(points, stroke));
|
||||
ui.painter().circle_stroke(center, 3.5, stroke);
|
||||
},
|
||||
);
|
||||
if self.layout.selected().is_none() {
|
||||
self.edit_content = false;
|
||||
|
|
@ -1487,11 +1516,11 @@ impl Editor {
|
|||
)
|
||||
};
|
||||
ui.put(
|
||||
Rect::from_min_size(ink.point(24.0, 90.0), Vec2::new(r.width() - 48.0, 52.0)),
|
||||
Rect::from_min_size(ink.point(24.0, 62.0), Vec2::new(r.width() - 48.0, 52.0)),
|
||||
egui::Label::new(egui::RichText::new(text).color(color)).wrap(),
|
||||
);
|
||||
let area = Rect::from_min_max(
|
||||
r.min + Vec2::new(20.0, 159.0),
|
||||
r.min + Vec2::new(20.0, 131.0),
|
||||
r.max - Vec2::new(20.0, 85.0),
|
||||
);
|
||||
let base = ((area.width() - 48.0) / sw).min((area.height() - 48.0) / sh);
|
||||
|
|
@ -2353,6 +2382,48 @@ mod tests {
|
|||
frame(&mut app, &ctx, vec![key(egui::Key::Escape)]);
|
||||
assert!(!app.edit_content);
|
||||
}
|
||||
#[test]
|
||||
fn viewport_options_menu_toggles_preferences_without_changing_layout() {
|
||||
let mut app = Editor::default();
|
||||
let ctx = egui::Context::default();
|
||||
let before = *app.layout.layers();
|
||||
let formats = *app.layout.formats();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
let pos = Pos2::new(442.0, 82.0);
|
||||
frame(
|
||||
&mut app,
|
||||
&ctx,
|
||||
vec![egui::Event::PointerMoved(pos), mouse(pos, true)],
|
||||
);
|
||||
frame(&mut app, &ctx, vec![mouse(pos, false)]);
|
||||
for label in [
|
||||
"Keep aspect ratio when resizing",
|
||||
"Show source-coordinate test pattern in viewport",
|
||||
] {
|
||||
let output = frame(&mut app, &ctx, vec![]);
|
||||
let pos = output
|
||||
.shapes
|
||||
.iter()
|
||||
.find_map(|s| match &s.shape {
|
||||
egui::Shape::Text(t) if t.galley.text() == label => {
|
||||
Some(t.pos + t.galley.size() / 2.0)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.expect("viewport setting rendered");
|
||||
frame(
|
||||
&mut app,
|
||||
&ctx,
|
||||
vec![egui::Event::PointerMoved(pos), mouse(pos, true)],
|
||||
);
|
||||
frame(&mut app, &ctx, vec![mouse(pos, false)]);
|
||||
}
|
||||
assert!(!app.keep_aspect_ratio);
|
||||
assert!(app.show_pattern);
|
||||
assert_eq!(*app.layout.layers(), before);
|
||||
assert_eq!(*app.layout.formats(), formats);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn visual_reset_crop_centers_at_minimum_zoom_and_is_undoable() {
|
||||
let mut app = Editor {
|
||||
|
|
|
|||
|
|
@ -143,8 +143,7 @@ clipboard testing against a running draw.io instance remains to be done.
|
|||
can be toggled on paste. This is not a native WebRCS clipboard payload.
|
||||
|
||||
Right-click a layer for **Source properties**, **Layer properties**, **Crop properties**,
|
||||
**Adjust layer crop**, aspect-ratio
|
||||
locking, alignment, copying values, and lock/hide actions. Right-clicking a layer
|
||||
**Adjust layer crop**, alignment, copying values, and lock/hide actions. Right-clicking a layer
|
||||
already in a selection keeps the whole selection and offers **Resize together**.
|
||||
Right-clicking an unselected layer selects it first. Locked/hidden layers remain
|
||||
protected; use the layer list to unlock/show them. Right-click empty canvas for
|
||||
|
|
@ -404,3 +403,8 @@ Visual crop mode also provides **Reset crop** beside **Done adjusting crop** in
|
|||
layer properties. It restores 100% content zoom and centered offsets, keeps the
|
||||
visible box and source/input crop unchanged, and leaves visual editing active.
|
||||
The reset is undoable.
|
||||
|
||||
The toolbar’s **Viewport options** cog contains **Keep aspect ratio when resizing**
|
||||
and **Show source-coordinate test pattern in viewport**. Both apply immediately
|
||||
and are preserved in saved projects. Crop editing always previews source content
|
||||
and keeps its proportions, independently of these layer/view preferences.
|
||||
|
|
|
|||
Loading…
Reference in New Issue