fix(viewport): improve cursor and paper contrast
Derive crosshair color from drawing background instead of UI theme. Use RGB 138 for Paper Space desk background. Refs #594
This commit is contained in:
parent
c5b5cd9dee
commit
7285e3de51
2 changed files with 23 additions and 20 deletions
|
|
@ -32,6 +32,12 @@ use viewcube::{viewcube_nav_controls, viewcube_ucs_picker, UCS_PICKER_W};
|
||||||
pub(in crate::app) use overlay::{MTEXT_TEXT_ID, TEXT_INLINE_ID};
|
pub(in crate::app) use overlay::{MTEXT_TEXT_ID, TEXT_INLINE_ID};
|
||||||
|
|
||||||
const VIEWCUBE_HIT_SIZE: f32 = VIEWCUBE_REGION_PX;
|
const VIEWCUBE_HIT_SIZE: f32 = VIEWCUBE_REGION_PX;
|
||||||
|
const PAPER_SPACE_BACKGROUND: Color = Color {
|
||||||
|
r: 138.0 / 255.0,
|
||||||
|
g: 138.0 / 255.0,
|
||||||
|
b: 138.0 / 255.0,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
|
||||||
/// Clear gap (px) kept between the render-mode bar (top-left) and the ViewCube
|
/// Clear gap (px) kept between the render-mode bar (top-left) and the ViewCube
|
||||||
/// (top-right) before the cube is judged to collide and hides.
|
/// (top-right) before the cube is judged to collide and hides.
|
||||||
|
|
@ -574,6 +580,11 @@ impl OpenCADStudio {
|
||||||
tab.pan_mode,
|
tab.pan_mode,
|
||||||
self.ribbon.open_dropdown.is_some(),
|
self.ribbon.open_dropdown.is_some(),
|
||||||
hover_locked,
|
hover_locked,
|
||||||
|
if tab.scene.input_uses_model_space() {
|
||||||
|
tab.scene.bg_color
|
||||||
|
} else {
|
||||||
|
tab.scene.paper_bg_color
|
||||||
|
},
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -591,13 +602,7 @@ impl OpenCADStudio {
|
||||||
.on_exit(Message::ViewportExit);
|
.on_exit(Message::ViewportExit);
|
||||||
|
|
||||||
let bg_color = if is_paper {
|
let bg_color = if is_paper {
|
||||||
// Desk color — matches the DESK constant in paper_canvas.rs.
|
PAPER_SPACE_BACKGROUND
|
||||||
Color {
|
|
||||||
r: 0.22,
|
|
||||||
g: 0.24,
|
|
||||||
b: 0.28,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
tab.bg_color
|
tab.bg_color
|
||||||
.map(|[r, g, b, a]| Color { r, g, b, a })
|
.map(|[r, g, b, a]| Color { r, g, b, a })
|
||||||
|
|
@ -706,16 +711,10 @@ impl OpenCADStudio {
|
||||||
// container background, the white sheet + paper entities + borders
|
// container background, the white sheet + paper entities + borders
|
||||||
// come from the full-canvas top-locked "sheet" viewport, and the
|
// come from the full-canvas top-locked "sheet" viewport, and the
|
||||||
// floating content viewports overlay it (same path as model space).
|
// floating content viewports overlay it (same path as model space).
|
||||||
const DESK: Color = Color {
|
|
||||||
r: 0.22,
|
|
||||||
g: 0.24,
|
|
||||||
b: 0.28,
|
|
||||||
a: 1.0,
|
|
||||||
};
|
|
||||||
stack![
|
stack![
|
||||||
container(grid_overlay)
|
container(grid_overlay)
|
||||||
.style(move |_: &Theme| container::Style {
|
.style(move |_: &Theme| container::Style {
|
||||||
background: Some(Background::Color(DESK)),
|
background: Some(Background::Color(PAPER_SPACE_BACKGROUND)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.width(Fill)
|
.width(Fill)
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,7 @@ pub fn selection_overlay<'a>(
|
||||||
pan_mode: bool,
|
pan_mode: bool,
|
||||||
suppressed: bool,
|
suppressed: bool,
|
||||||
hover_locked: bool,
|
hover_locked: bool,
|
||||||
|
crosshair_bg: [f32; 4],
|
||||||
) -> Element<'a, Message> {
|
) -> Element<'a, Message> {
|
||||||
canvas(SelectionCanvas {
|
canvas(SelectionCanvas {
|
||||||
selection,
|
selection,
|
||||||
|
|
@ -239,6 +240,7 @@ pub fn selection_overlay<'a>(
|
||||||
pan_mode,
|
pan_mode,
|
||||||
suppressed,
|
suppressed,
|
||||||
hover_locked,
|
hover_locked,
|
||||||
|
crosshair_bg,
|
||||||
})
|
})
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
|
|
@ -290,6 +292,9 @@ struct SelectionCanvas {
|
||||||
/// The entity under the crosshair is on a locked layer — draw a small lock
|
/// The entity under the crosshair is on a locked layer — draw a small lock
|
||||||
/// badge by the cursor so the user knows it can't be selected/edited.
|
/// badge by the cursor so the user knows it can't be selected/edited.
|
||||||
hover_locked: bool,
|
hover_locked: bool,
|
||||||
|
/// Background of the active drawing space. Crosshair contrast follows this
|
||||||
|
/// rather than the UI theme, which may be light over a dark model viewport.
|
||||||
|
crosshair_bg: [f32; 4],
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_grip_marker(frame: &mut canvas::Frame, grip: &GripMarker, theme: &Theme) {
|
fn draw_grip_marker(frame: &mut canvas::Frame, grip: &GripMarker, theme: &Theme) {
|
||||||
|
|
@ -908,12 +913,11 @@ impl canvas::Program<Message> for SelectionCanvas {
|
||||||
// PAN mode replaces the crosshair with a hand cursor.
|
// PAN mode replaces the crosshair with a hand cursor.
|
||||||
if !over_viewcube && !over_divider && !self.pan_mode && !self.suppressed {
|
if !over_viewcube && !over_divider && !self.pan_mode && !self.suppressed {
|
||||||
if let Some(cp) = self.selection.last_move_pos {
|
if let Some(cp) = self.selection.last_move_pos {
|
||||||
let color = theme
|
let [r, g, b, a] = crate::scene::view::render::adapt_to_bg(
|
||||||
.palette()
|
[1.0, 1.0, 1.0, 0.90],
|
||||||
.background
|
self.crosshair_bg,
|
||||||
.base
|
);
|
||||||
.text
|
let color = Color { r, g, b, a };
|
||||||
.scale_alpha(0.90);
|
|
||||||
let stroke = canvas::Stroke {
|
let stroke = canvas::Stroke {
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
style: canvas::Style::Solid(color),
|
style: canvas::Style::Solid(color),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue