feat(ui): refine ribbon and view navigation

This commit is contained in:
Hakan Seven committed 2026-08-04 18:21:52 +03:00
1 parent 675538eb8d
commit d1f9055901
14 files changed
+466 -116

No files matched your search

+15 -12
View File
@@ -671,7 +671,7 @@ impl OpenCADStudio {
dividers,
pane_move_rect,
pane_drop_rect,
tab.pan_mode,
tab.pan_mode || tab.orbit_mode,
self.ribbon.open_dropdown.is_some(),
hover_locked,
crosshair_background(tab, is_paper),
@@ -886,15 +886,18 @@ impl OpenCADStudio {
// both layered ABOVE the viewport mouse_area so they receive
// clicks (the shader viewport sits below it). Positioned with
// leading Spaces sized to the viewport's screen rectangle.
let active_vp_rect: Option<iced::Rectangle> = if is_paper && !tab.is_start {
tab.scene.active_viewport.and_then(|h| {
let (cw, ch) = tab.scene.selection.borrow().vp_size;
tab.scene.viewport_screen_rect(h, (cw, ch))
})
} else {
None
};
if let Some(rect) = active_vp_rect {
let active_vp_rect: Option<(acadrust::Handle, iced::Rectangle)> =
if is_paper && !tab.is_start {
tab.scene.active_viewport.and_then(|h| {
let (cw, ch) = tab.scene.selection.borrow().vp_size;
tab.scene
.viewport_screen_rect(h, (cw, ch))
.map(|rect| (h, rect))
})
} else {
None
};
if let Some((active_vp, rect)) = active_vp_rect {
// Clip the outline to the visible canvas. Clamping only the origin
// (max(0.0)) while keeping the full width/height shifted the whole
// outline inward when the viewport ran off the top/left edge, so
@@ -964,7 +967,7 @@ impl OpenCADStudio {
let cube_x = (rect.x + rect.width - VIEWCUBE_HIT_SIZE - VIEWCUBE_PAD).max(0.0);
let cube_y = (rect.y + VIEWCUBE_PAD).max(0.0);
let controls = iced::widget::pin(viewcube_nav_controls())
let controls = iced::widget::pin(viewcube_nav_controls(Some(active_vp)))
.position(iced::Point::new(cube_x, cube_y));
viewport_stack = viewport_stack.push(controls);
@@ -1003,7 +1006,7 @@ impl OpenCADStudio {
let cube_y = (rect.y + VIEWCUBE_PAD).max(0.0);
// Cube hit area + nav controls (home / roll / nudge) as one layer.
let controls = iced::widget::pin(viewcube_nav_controls())
let controls = iced::widget::pin(viewcube_nav_controls(None))
.position(iced::Point::new(cube_x, cube_y));
viewport_stack = viewport_stack.push(controls);
+5 -3
View File
@@ -52,7 +52,9 @@ fn vc_btn<'a>(content: Element<'a, Message>, size: f32, msg: Message) -> Element
/// Overlay of home / roll / nudge controls sized to the whole nav region, so
/// the caller can position it exactly like the cube hit area.
pub(super) fn viewcube_nav_controls<'a>() -> Element<'a, Message> {
pub(super) fn viewcube_nav_controls<'a>(
viewport: Option<acadrust::Handle>,
) -> Element<'a, Message> {
use crate::scene::NudgeDir;
use crate::ui::icons;
let r = VIEWCUBE_REGION_PX;
@@ -81,8 +83,8 @@ pub(super) fn viewcube_nav_controls<'a>() -> Element<'a, Message> {
.width(iced::Length::Fixed(r))
.height(iced::Length::Fixed(r)),
)
.on_move(Message::CursorMoved)
.on_press(Message::ViewportClick);
.on_move(move |point| Message::CursorMoved(point, viewport))
.on_press(Message::ViewportClick(viewport));
let controls = stack![
cube_hit,