Opacity roles for label tints, span bars and secondary ink over data colours

This commit is contained in:
aiongg
2026-11-12 14:32:43 +00:00
parent 28f79987f7
commit 9d44fd0afc
5 changed files with 18 additions and 14 deletions
+2 -4
View File
@@ -1,5 +1,6 @@
//! Cursor chat: your box at the pointer, and everyone's bubbles.
use craft_theme::Opacity;
use craft_theme::variant::Variant;
use craft_ui::contract::{Bind, NoValue, Outcome, PaintUi, Pattern, Props, Remember as _, Show as _, ShowContainer as _};
use craft_ui::layout_components::Stack;
@@ -16,9 +17,6 @@ use crate::collab::CollabRequest;
#[cfg(feature = "screen-testing")]
mod stories;
/// How much of the ink the name over a bubble's text keeps.
const NAME_INK: f32 = 0.8;
craft_ui::words! {
/// The chat box's words, English by default.
#[non_exhaustive]
@@ -85,7 +83,7 @@ pub fn paint_chat_bubble(ui: &PaintUi<'_>, look: &BubbleLook, tip: Pos2, name: O
draw.data_fill(&PaintShape::Rect(rect, CornerRadius { nw: 0, ne: round, sw: round, se: round }), DataColor::new(background));
let mut at = rect.min + look.pad;
if let Some(title) = &title {
draw.faded(NAME_INK, |draw| {
draw.faded(Opacity::SECONDARY, |draw| {
draw.text(Rect::from_min_size(at, Vec2::new(width, look.caption.1)), title);
});
at.y += head_height;
+10
View File
@@ -221,4 +221,14 @@ impl Opacity {
pub const MOVING: f32 = 0.75;
/// Alpha of a mark the app derived, drawn beside the user's own marks of the same kind so those stand out.
pub const DERIVED: f32 = 0.7;
/// Alpha of a colour that faintly washes an area behind its content: a track's label colour over its lane.
pub const WASH: f32 = 0.10;
/// Alpha of a colour that tints an area behind or over content so the area stands out while the content still
/// reads: a track's label colour over its header, an inspected element's padding.
pub const TINT: f32 = 0.18;
/// Alpha of a data colour filling a span bar beside the solid mark it belongs to: a range marker's duration.
pub const SPAN: f32 = 0.5;
/// Alpha of secondary ink drawn over a data colour, below the primary ink of the same surface: the author's name
/// over a chat bubble's message.
pub const SECONDARY: f32 = 0.8;
}
+2 -3
View File
@@ -7,6 +7,7 @@
use std::rc::Rc;
use craft_behavior::{CursorIcon, HitLevel, HitPriority, Intent, MarqueeSelect, PartKey, PartRef, PointerButton, PressPhase, SelectionChange, Sense};
use craft_theme::Opacity;
use craft_ui::contract::{
Access, Component, ContentPainter, Cx, Edit as _, Focus as _, Name, Outcome, PaintUi, PartsCx, Pointer as _, Remember as _, Styled as _,
};
@@ -21,8 +22,6 @@ use crate::model::{ClipId, ClipInfo};
use crate::time::Tick;
use crate::timecode::format_time;
/// How strongly a track's colour label tints its lane (FilmCraft `timeline.rs:255` `TRACK_LANE_TINT`, used at `:335`).
const LANE_LABEL_TINT: f32 = 0.10;
/// The locked hatch's line spacing, as a share of the control height.
const HATCH_STEP_SHARE: f32 = 0.25;
/// Within this share of the edge zone of a cut, the Selection tool with its no-modifier trims rolls.
@@ -573,7 +572,7 @@ impl<'a> ClipLane<'a> {
let palette = label_palette(&cx.env);
let geometry = self.geometry(axis, lane, look);
if let Some(label) = self.track_label {
let tint = palette.0[usize::from(label.0) % palette.0.len()].gamma_multiply(LANE_LABEL_TINT);
let tint = palette.0[usize::from(label.0) % palette.0.len()].gamma_multiply(Opacity::WASH);
ui.draw().data_fill(&PaintShape::Rect(lane, CornerRadius::ZERO), DataColor::new(tint));
}
for clip in self.clips {
+2 -3
View File
@@ -12,6 +12,7 @@ use craft_behavior::{
Arrows, CancelReason, CursorIcon, EditEvent, GestureId, Granularity, HitLevel, HitPriority, Input, Intent, Metrics, Mixed, NavShape, PartKey,
PointerButton, PressCancel, PressPhase, Roving, Sense,
};
use craft_theme::Opacity;
use craft_ui::contract::{
Access, Common, Component, Cx, Focus as _, MeasureCx, Name, NoValue, Outcome, PaintUi, PartsCx, Pointer as _, Props as _, Remember as _, Role,
SetPosition, WordSetCx as _, clicked,
@@ -30,8 +31,6 @@ use crate::markers::{Marker, MarkerColor, MarkerId};
use crate::time::Tick;
use crate::timecode::format_time;
/// The fill of a range marker's duration bar, as a share of the label colour (EffectCraft `markers_ui.rs:296`).
const DURATION_TINT: f32 = 0.5;
/// Where a marker's point sits, as a share of the strip's height (EffectCraft `markers_ui.rs:274`). A proportion of
/// the strip, not a size.
pub const MARKER_POINT: f32 = 0.6;
@@ -436,7 +435,7 @@ impl Component for MarkerStrip<'_> {
let end = (length > Tick::ZERO).then(|| axis.x_of(start + length, rect.left()));
if let Some(end) = end {
let bar = Rect::from_min_max(pos2(x, rect.top()), pos2(end, rect.top() + height));
draw.data_fill(&PaintShape::Rect(bar, CornerRadius::ZERO), DataColor::new(tint(marker.color).gamma_multiply(DURATION_TINT)));
draw.data_fill(&PaintShape::Rect(bar, CornerRadius::ZERO), DataColor::new(tint(marker.color).gamma_multiply(Opacity::SPAN)));
}
if marker.name.is_empty() {
continue;
+2 -4
View File
@@ -16,6 +16,7 @@ use craft_behavior::{
ColumnKey, ColumnWidth, CursorIcon, DisplayOrder, EditEvent, EditEvents, HitLevel, HitPriority, IconId, ItemSource, MarqueeSelect, Metrics,
Mixed, PartKey, PressPhase, Selection, SelectionChange, Sense, SizeHint, SpanLayout,
};
use craft_theme::Opacity;
use craft_ui::contract::{
Access, Bind, BindMut, Collection, CollectionProps, CollectionResponse, ColumnKind, ColumnSpec, Common, Component, ContainerProps, Cx, Edit as _,
ItemKeys, ItemOutput, MeasureCx, Name, Outcome, PaintUi, PartsCx, Pointer as _, Props, Remember as _, Role, Scroll, ScrollAnchor, SelectMode,
@@ -62,9 +63,6 @@ const SWITCHES: [(ColumnKey, &str, &str); 6] = [
(SOLO, "solo", "solo"),
];
/// How strongly a track's colour label tints its header: a share of the label colour (FilmCraft `TRACK_HEADER_TINT`).
const HEADER_LABEL_TINT: f32 = 0.18;
/// The sizes of a timeline's tracks and headers, all from the tokens.
#[derive(Clone, Copy, Debug, PartialEq)]
#[non_exhaustive]
@@ -599,7 +597,7 @@ impl Component for TrackRow<'_> {
if let Some(label) = self.track.label {
let palette: LabelPalette = label_palette(&cx.env);
let tint = palette.0[usize::from(label.0) % palette.0.len()];
draw.data_fill(&PaintShape::Rect(headers, CornerRadius::ZERO), DataColor::new(tint.gamma_multiply(HEADER_LABEL_TINT)));
draw.data_fill(&PaintShape::Rect(headers, CornerRadius::ZERO), DataColor::new(tint.gamma_multiply(Opacity::TINT)));
if let Some(strip) = self.cell(&STRIP) {
draw.data_fill(&PaintShape::Rect(strip, CornerRadius::ZERO), DataColor::new(tint));
}