mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-19 09:01:20 +01:00
M10: panel rows and the layers list mirror in a right-to-left UI
In a right-to-left UI language the rows inside the panels run from the right as well: the shared Design panel row (right::block), section headers, tight_end, sub-labels, checkboxes, radios, disclosures and the selection header, and the layers and pages lists (indent, disclosure, icon and name from the right, eye and padlock on the left). Names and rename fields align to their start. Hand-placed layouts stay written left to right and are mirrored inside their row with widgets::flip_x / flip_rect, so an English window takes the same code path unchanged. Inside a control nothing turns round. A layers list made wider than the panel by a long name (#1904) mirrors across its whole width, so it starts scrolled to its right end, where its rows start (stick_to_right, with a scroll state per direction so a language switch doesn't leave it at the left end). The Assets panel, version history, Dev Mode's layouts, the colour picker, the toolbar, the tab bar and the home screen stay left to right. Gap 5 had two copies of its "Missing" paragraph, left by merges: one now.
This commit is contained in:
1 parent
f8b1dc7373
commit
aa9991f1cf
13 files changed
+363
-71
No files matched your search
+1
-1
@@ -105,7 +105,7 @@ native speakers' reviews of the nine language drafts need people.
|
||||
| Traditional Chinese (Taiwan) | zh-Hant | 2,647 / 2,647 entries (100%, counted 2026-11-03) | draft (needs native review) |
|
||||
| Spanish | es, es-419 | 100% (es-419: an overlay of 101 entries) | draft (needs native review) |
|
||||
| Hindi | hi | 0% | none |
|
||||
| Arabic | ar | 2,508 / 2,508 entries (100%, counted 2026-10-28) | draft; web builds with craft-fonts offer Arabic by default; the window mirrors (panels swap sides); native review and mirrored panel rows pending |
|
||||
| Arabic | ar | 2,508 / 2,508 entries (100%, counted 2026-10-28) | draft; the window, the Design panel's rows and the layers mirror; web builds with craft-fonts offer Arabic by default; native review and the rest of the mirroring pending |
|
||||
| French | fr | 95% | draft (needs native review) |
|
||||
| Portuguese (Brazil) | pt-BR | 95% | draft (needs native review) |
|
||||
| Indonesian | id | 99% | draft (needs native review) |
|
||||
|
||||
@@ -30,18 +30,32 @@ pub fn paint_name(painter: &Painter, left_center: Pos2, name: &str, font: FontId
|
||||
rect
|
||||
}
|
||||
|
||||
/// [`paint_name`] with its start at `start`'s x: its left end, or its right end in a mirrored
|
||||
/// (right-to-left) panel.
|
||||
pub fn paint_name_from(painter: &Painter, start: Pos2, rtl: bool, name: &str, font: FontId, color: Color32, max_w: f32) -> Rect {
|
||||
if !rtl {
|
||||
return paint_name(painter, start, name, font, color, max_w);
|
||||
}
|
||||
let galley = name_galley(painter, name, font, color, max_w);
|
||||
let rect = Rect::from_min_size(pos2(start.x - galley.size().x, start.y - galley.size().y / 2.0), galley.size());
|
||||
painter.galley(rect.min, galley, color);
|
||||
rect
|
||||
}
|
||||
|
||||
/// A frameless one-line text editor for a name (a [`egui::TextEdit`] with id `id`). The editor's
|
||||
/// text is logical; egui's galley paints it in visual order, and its caret, selection, clicks,
|
||||
/// drags and left and right arrows follow what is on screen while reporting logical char offsets.
|
||||
pub fn single_line(ui: &mut Ui, id: Id, text: &mut String, font: FontId, width: f32) -> Response {
|
||||
// Centred in the height it's given (a rename row), like the name it replaces.
|
||||
let height = ui.available_height().max(0.0);
|
||||
// At the start of its row: the right end in a mirrored (right-to-left) panel.
|
||||
let align = if ui.style().right_to_left { egui::Align2::RIGHT_CENTER } else { egui::Align2::LEFT_CENTER };
|
||||
egui::TextEdit::singleline(text)
|
||||
.id(id)
|
||||
.frame(egui::Frame::NONE)
|
||||
.font(font)
|
||||
.desired_width(width)
|
||||
.align(egui::Align2::LEFT_CENTER)
|
||||
.align(align)
|
||||
.min_size(vec2(0.0, height))
|
||||
.show(ui)
|
||||
.response
|
||||
|
||||
@@ -15,7 +15,7 @@ fn id(v: serde_json::Value) -> NodeId {
|
||||
}
|
||||
|
||||
/// A rectangle named `name` on the page, or inside `parent`.
|
||||
fn named(s: &mut Session, name: &str, parent: Option<NodeId>) -> NodeId {
|
||||
pub(crate) fn named(s: &mut Session, name: &str, parent: Option<NodeId>) -> NodeId {
|
||||
let mut p = json!({"x": 0, "y": 0, "width": 20, "height": 20, "props": {"name": name}});
|
||||
if let Some(parent) = parent {
|
||||
p["parent"] = json!(parent);
|
||||
@@ -24,7 +24,7 @@ fn named(s: &mut Session, name: &str, parent: Option<NodeId>) -> NodeId {
|
||||
}
|
||||
|
||||
/// The painted text starting with `prefix`: (whether it was elided, its position, its size).
|
||||
fn painted(u: &mut Ui, prefix: &str) -> (bool, Pos2, Vec2) {
|
||||
pub(crate) fn painted(u: &mut Ui, prefix: &str) -> (bool, Pos2, Vec2) {
|
||||
let shapes = crate::live_tests::flat(&u.frame_output(vec![]).shapes);
|
||||
shapes
|
||||
.iter()
|
||||
|
||||
@@ -15,6 +15,10 @@ const WINDOW_W: f32 = 1440.0;
|
||||
fn ui(mirrored: bool) -> Ui {
|
||||
let mut s = Session::new();
|
||||
s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 300, "height": 200})).unwrap();
|
||||
ui_from(s, mirrored)
|
||||
}
|
||||
|
||||
fn ui_from(s: Session, mirrored: bool) -> Ui {
|
||||
let mut u = Ui::new(s);
|
||||
u.app.ui.mirrored = mirrored;
|
||||
u.frame(vec![]);
|
||||
@@ -90,6 +94,90 @@ fn switching_back_unmirrors_the_window_and_egui() {
|
||||
assert!(!u.ctx.global_style().right_to_left);
|
||||
}
|
||||
|
||||
/// One frame of `add` in a 240-wide panel, with egui's `right_to_left` as given.
|
||||
fn panel(rtl: bool, add: impl Fn(&mut egui::Ui)) {
|
||||
let ctx = egui::Context::default();
|
||||
ctx.all_styles_mut(|s| s.right_to_left = rtl);
|
||||
let input = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(240.0, 400.0))), ..Default::default() };
|
||||
let mut out = ctx.run_ui(input, |ui| add(ui));
|
||||
out.textures_delta.clear();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flipping_mirrors_across_the_rect_and_only_when_asked() {
|
||||
use crate::widgets::{flip_rect, flip_x};
|
||||
let within = egui::Rect::from_min_max(pos2(100.0, 0.0), pos2(340.0, 40.0));
|
||||
assert_eq!(flip_x(true, within, 116.0), 324.0, "16 in from the left becomes 16 in from the right");
|
||||
assert_eq!(flip_x(false, within, 116.0), 116.0);
|
||||
let r = egui::Rect::from_min_max(pos2(108.0, 8.0), pos2(132.0, 32.0));
|
||||
assert_eq!(flip_rect(true, within, r), egui::Rect::from_min_max(pos2(308.0, 8.0), pos2(332.0, 32.0)));
|
||||
assert_eq!(flip_rect(false, within, r), r);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_panel_row_starts_at_its_right_end_when_mirrored() {
|
||||
use crate::widgets::{GUTTER, PAD};
|
||||
for rtl in [false, true] {
|
||||
panel(rtl, |ui| {
|
||||
let mut placed = Vec::new();
|
||||
crate::right::row_rect(ui, 32.0, |ui| {
|
||||
placed.push(ui.allocate_exact_size(egui::vec2(50.0, 24.0), egui::Sense::hover()).0);
|
||||
placed.push(ui.allocate_exact_size(egui::vec2(50.0, 24.0), egui::Sense::hover()).0);
|
||||
});
|
||||
let w = ui.max_rect().width();
|
||||
let (first, second) = (placed[0], placed[1]);
|
||||
if rtl {
|
||||
assert_eq!(first.max.x, w - PAD, "the first control 16 in from the right");
|
||||
assert_eq!(second.max.x, first.min.x - GUTTER, "the next one to its left");
|
||||
} else {
|
||||
assert_eq!(first.min.x, PAD, "the first control 16 in from the left");
|
||||
assert_eq!(second.min.x, first.max.x + GUTTER, "the next one to its right");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_rows_end_buttons_are_on_its_left_when_mirrored() {
|
||||
for rtl in [false, true] {
|
||||
panel(rtl, |ui| {
|
||||
let mut buttons = Vec::new();
|
||||
crate::right::row_rect(ui, 32.0, |ui| {
|
||||
crate::widgets::tight_end(ui, |ui| {
|
||||
buttons.push(ui.allocate_exact_size(egui::vec2(24.0, 24.0), egui::Sense::hover()).0);
|
||||
buttons.push(ui.allocate_exact_size(egui::vec2(24.0, 24.0), egui::Sense::hover()).0);
|
||||
});
|
||||
});
|
||||
let w = ui.max_rect().width();
|
||||
let last = buttons[1];
|
||||
if rtl {
|
||||
assert_eq!(last.min.x, crate::widgets::PAD_RIGHT, "the last button 8 in from the left");
|
||||
assert!(buttons[0].min.x > last.min.x);
|
||||
} else {
|
||||
assert_eq!(last.max.x, w - crate::widgets::PAD_RIGHT, "the last button 8 in from the right");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_name_is_painted_from_its_start_edge() {
|
||||
for rtl in [false, true] {
|
||||
panel(rtl, |ui| {
|
||||
crate::theme::install_fonts(ui.ctx(), false, 0);
|
||||
let font = crate::theme::regular(11.0);
|
||||
let start = pos2(200.0, 20.0);
|
||||
let r = crate::bidi::paint_name_from(ui.painter(), start, rtl, "Home — Dark", font, egui::Color32::WHITE, 150.0);
|
||||
assert!(r.width() > 0.0);
|
||||
if rtl {
|
||||
assert_eq!(r.max.x, 200.0, "its right end on the start");
|
||||
} else {
|
||||
assert_eq!(r.min.x, 200.0, "its left end on the start");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_minimized_window_has_its_expand_button_where_the_rail_was() {
|
||||
use egui::accesskit::Role;
|
||||
@@ -104,3 +192,103 @@ fn a_minimized_window_has_its_expand_button_where_the_rail_was() {
|
||||
assert_eq!(expand.x, x, "mirrored: {mirrored}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Mirrored, a layer's icon sits at its row's right end (8 + 4 + 22 points in from it), and a
|
||||
/// double-click there zooms to the layer instead of renaming it, as on the left in English.
|
||||
#[test]
|
||||
fn a_double_click_on_a_mirrored_layers_icon_zooms_to_it() {
|
||||
use egui::{Event, Pos2};
|
||||
let mut s = Session::new();
|
||||
let far = crate::layers_wide_names_tests::named(&mut s, "far", None);
|
||||
s.execute("node.set", &json!({"ids": [far], "props": {"x": 3000}})).unwrap();
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
let mut u = ui_from(s, true);
|
||||
let over = |u: &mut Ui, p: Pos2| {
|
||||
u.app.session.ds_mut().unwrap().hover = None;
|
||||
u.frame(vec![Event::PointerMoved(p)]);
|
||||
u.app.session.ds().unwrap().hover == Some(far)
|
||||
};
|
||||
let panel_end = WINDOW_W - layers::RAIL_WIDTH;
|
||||
let ys: Vec<f32> = (60..900).step_by(2).map(|y| y as f32).filter(|&y| over(&mut u, pos2(panel_end - 40.0, y))).collect();
|
||||
let y = (ys.first().expect("the row") + ys.last().expect("the row")) / 2.0;
|
||||
let right = (0..120).map(|d| panel_end - d as f32).find(|&x| over(&mut u, pos2(x, y))).expect("the row's right edge");
|
||||
let icon = pos2(right - 34.0, y);
|
||||
let view = |u: &Ui| {
|
||||
let v = &u.app.session.ds().unwrap().view;
|
||||
(v.cx, v.cy, v.zoom)
|
||||
};
|
||||
let before = view(&u);
|
||||
for _ in 0..2 {
|
||||
u.button(icon, true);
|
||||
u.button(icon, false);
|
||||
}
|
||||
u.frame(vec![]);
|
||||
assert_eq!(u.app.ui.rename, None, "a double-click on the icon renames nothing");
|
||||
assert_eq!(u.app.session.selection(), vec![far], "the layer is selected");
|
||||
assert_ne!(view(&u), before, "the view moved to the layer");
|
||||
}
|
||||
|
||||
/// A list as wide as a long name (#1904) mirrors across its whole width, so mirrored it starts
|
||||
/// scrolled to its right end, where the rows start: the names start at the panel's start edge,
|
||||
/// not past it. English, Arabic, then English again, as when the UI language is switched: each
|
||||
/// direction keeps its own scroll position.
|
||||
#[test]
|
||||
fn a_wide_layers_list_starts_where_its_rows_start() {
|
||||
use crate::layers_wide_names_tests::{named, painted};
|
||||
let mut s = Session::new();
|
||||
named(&mut s, "Size=small, Type=primary, State=default, Icon=leading, Width=full", None);
|
||||
named(&mut s, "Short", None);
|
||||
let mut u = Ui::new(s);
|
||||
for mirrored in [false, true, false] {
|
||||
u.app.ui.mirrored = mirrored;
|
||||
u.frame(vec![]);
|
||||
u.frame(vec![]);
|
||||
let panel = if mirrored {
|
||||
(WINDOW_W - layers::RAIL_WIDTH - PANEL_DEFAULT)..=(WINDOW_W - layers::RAIL_WIDTH)
|
||||
} else {
|
||||
layers::RAIL_WIDTH..=(layers::RAIL_WIDTH + PANEL_DEFAULT)
|
||||
};
|
||||
for name in ["Short", "Size=small"] {
|
||||
let (_, p, size) = painted(&mut u, name);
|
||||
let start = if mirrored { p.x + size.x } else { p.x };
|
||||
assert!(panel.contains(&start), "mirrored: {mirrored}, {name} starts at {start}, outside the panel {panel:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The x of every filled shape painted in the component colour inside `panel`'s header strip.
|
||||
fn component_icon_xs(u: &mut Ui, panel: egui::Rect) -> Vec<f32> {
|
||||
fn walk(shape: &egui::Shape, out: &mut Vec<egui::Pos2>) {
|
||||
match shape {
|
||||
egui::Shape::Path(p) if p.fill == crate::theme::COMPONENT => out.push(p.visual_bounding_rect().center()),
|
||||
egui::Shape::Vec(v) => v.iter().for_each(|s| walk(s, out)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let frame = u.frame_output(vec![]);
|
||||
let mut at = Vec::new();
|
||||
frame.shapes.iter().for_each(|c| walk(&c.shape, &mut at));
|
||||
at.into_iter().filter(|p| panel.x_range().contains(p.x) && p.y < 190.0).map(|p| p.x).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_mirrored_header_paints_the_component_icon_right_of_its_name() {
|
||||
for mirrored in [false, true] {
|
||||
let mut s = Session::new();
|
||||
let f = s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 80, "height": 40, "name": "Knapp"})).unwrap();
|
||||
let c = s.execute("component.create", &json!({"ids": [f["id"]]})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [c["id"]]})).unwrap();
|
||||
let mut u = ui_from(s, mirrored);
|
||||
let panel = u.app.ui.right_panel_rect.expect("the Design panel drew");
|
||||
let name = crate::export_preview_tests::labelled(&mut u)
|
||||
.into_iter()
|
||||
.find(|(t, at)| t == "Knapp" && panel.x_range().contains(at.x) && at.y < 190.0)
|
||||
.map(|(_, at)| at.x)
|
||||
.expect("the header names the component");
|
||||
let icon = component_icon_xs(&mut u, panel);
|
||||
assert!(!icon.is_empty(), "mirrored: {mirrored}, no component icon in the header");
|
||||
for x in icon {
|
||||
assert_eq!(x > name, mirrored, "mirrored: {mirrored}, icon at {x}, name at {name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,9 +326,16 @@ fn preview(app: &mut FigApp, ui: &mut Ui, doc: &Document, id: NodeId) {
|
||||
if resp.hovered() {
|
||||
ui.painter().rect_filled(r, CornerRadius::same(5), t.hover);
|
||||
}
|
||||
let icon = if open { Icon::Chevron } else { Icon::ChevronRight };
|
||||
icons::paint(ui.painter(), Rect::from_center_size(pos2(r.min.x + 8.0, r.center().y), vec2(12.0, 12.0)), icon, t.icon_secondary);
|
||||
ui.painter().text(pos2(r.min.x + 20.0, r.center().y), Align2::LEFT_CENTER, tr("Preview"), regular(11.0), t.text);
|
||||
let rtl = crate::widgets::rtl(ui);
|
||||
let icon = match (open, rtl) {
|
||||
(true, _) => Icon::Chevron,
|
||||
(false, false) => Icon::ChevronRight,
|
||||
(false, true) => Icon::ChevronLeft,
|
||||
};
|
||||
let x = |at: f32| crate::widgets::flip_x(rtl, r, at);
|
||||
icons::paint(ui.painter(), Rect::from_center_size(pos2(x(r.min.x + 8.0), r.center().y), vec2(12.0, 12.0)), icon, t.icon_secondary);
|
||||
let align = if rtl { Align2::RIGHT_CENTER } else { Align2::LEFT_CENTER };
|
||||
ui.painter().text(pos2(x(r.min.x + 20.0), r.center().y), align, tr("Preview"), regular(11.0), t.text);
|
||||
if resp.clicked() {
|
||||
open = !open;
|
||||
}
|
||||
|
||||
@@ -150,18 +150,23 @@ pub fn left_panel(app: &mut FigApp, ui: &mut Ui) {
|
||||
let full = ui.max_rect();
|
||||
// Header: file name (or "Assets") + drafts + collapse.
|
||||
let (head, _) = ui.allocate_exact_size(vec2(full.width(), 64.0), Sense::hover());
|
||||
// Laid out left to right, mirrored inside the header in a right-to-left window.
|
||||
let rtl = crate::widgets::rtl(ui);
|
||||
let align = if rtl { Align2::RIGHT_CENTER } else { Align2::LEFT_CENTER };
|
||||
let fx = |x: f32| crate::widgets::flip_x(rtl, head, x);
|
||||
if app.ui.left_tab == LeftTab::Assets {
|
||||
ui.painter().text(pos2(head.min.x + 16.0, head.min.y + 24.0), Align2::LEFT_CENTER, tr("Assets"), semibold(13.0), t.text);
|
||||
ui.painter().text(pos2(fx(head.min.x + 16.0), head.min.y + 24.0), align, tr("Assets"), semibold(13.0), t.text);
|
||||
} else {
|
||||
let name = app.session.doc().map(|d| d.name.clone()).unwrap_or_default();
|
||||
let nr = Rect::from_min_max(pos2(head.min.x + 14.0, head.min.y + 14.0), pos2(head.max.x - 48.0, head.min.y + 34.0));
|
||||
let nr = crate::widgets::flip_rect(rtl, head, nr);
|
||||
let start = std::mem::take(&mut app.ui.rename_file);
|
||||
if let (Some(new), _) = crate::widgets::rename_field(ui, Id::unique("filename"), &name, nr, semibold(13.0), start) {
|
||||
app.run("file.rename", json!({"name": new}));
|
||||
}
|
||||
ui.painter().text(pos2(head.min.x + 16.0, head.min.y + 46.0), Align2::LEFT_CENTER, tr("Drafts"), regular(11.0), t.text_secondary);
|
||||
ui.painter().text(pos2(fx(head.min.x + 16.0), head.min.y + 46.0), align, tr("Drafts"), regular(11.0), t.text_secondary);
|
||||
}
|
||||
let hr = Rect::from_center_size(pos2(head.max.x - 24.0, head.min.y + 24.0), vec2(24.0, 24.0));
|
||||
let hr = Rect::from_center_size(pos2(fx(head.max.x - 24.0), head.min.y + 24.0), vec2(24.0, 24.0));
|
||||
// Minimize, by the file name: "click Minimize next to the file name to collapse the
|
||||
// navigation bar, left sidebar, and right sidebar" (Explore the navigation bar and left sidebar).
|
||||
let hresp = ui.interact(hr, ui.scope_id().with("hideui"), Sense::click()).tip(tr("Minimize"));
|
||||
@@ -193,13 +198,17 @@ fn pages(app: &mut FigApp, ui: &mut Ui) {
|
||||
}
|
||||
let w = ui.available_width();
|
||||
let (hr, _) = ui.allocate_exact_size(vec2(w, 40.0), Sense::hover());
|
||||
let tresp = ui.interact(Rect::from_min_size(hr.min, vec2(w - 40.0, 40.0)), ui.scope_id().with("pages_toggle"), Sense::click());
|
||||
let rtl = crate::widgets::rtl(ui);
|
||||
let fx = |x: f32| crate::widgets::flip_x(rtl, hr, x);
|
||||
let toggle = crate::widgets::flip_rect(rtl, hr, Rect::from_min_size(hr.min, vec2(w - 40.0, 40.0)));
|
||||
let tresp = ui.interact(toggle, ui.scope_id().with("pages_toggle"), Sense::click());
|
||||
a11y::toggle(&tresp, tr("Pages"), app.ui.pages_open);
|
||||
ui.painter().text(pos2(hr.min.x + 16.0, hr.center().y), Align2::LEFT_CENTER, tr("Pages"), semibold(11.0), t.text);
|
||||
let start = if rtl { Align2::RIGHT_CENTER } else { Align2::LEFT_CENTER };
|
||||
ui.painter().text(pos2(fx(hr.min.x + 16.0), hr.center().y), start, tr("Pages"), semibold(11.0), t.text);
|
||||
if tresp.clicked() {
|
||||
app.ui.pages_open = !app.ui.pages_open;
|
||||
}
|
||||
let sr = Rect::from_center_size(pos2(hr.max.x - 50.0, hr.center().y), vec2(24.0, 24.0));
|
||||
let sr = Rect::from_center_size(pos2(fx(hr.max.x - 50.0), hr.center().y), vec2(24.0, 24.0));
|
||||
let sresp = ui.interact(sr, ui.scope_id().with("lsearch"), Sense::click()).tip(tr("Search pages"));
|
||||
if sresp.hovered() || app.ui.page_search {
|
||||
ui.painter().rect_filled(sr, CornerRadius::same(5), t.hover);
|
||||
@@ -213,7 +222,7 @@ fn pages(app: &mut FigApp, ui: &mut Ui) {
|
||||
app.ui.pages_open = true;
|
||||
}
|
||||
}
|
||||
let ar = Rect::from_center_size(pos2(hr.max.x - 22.0, hr.center().y), vec2(24.0, 24.0));
|
||||
let ar = Rect::from_center_size(pos2(fx(hr.max.x - 22.0), hr.center().y), vec2(24.0, 24.0));
|
||||
let aresp = ui.interact(ar, ui.scope_id().with("addpage"), Sense::click()).tip(tr("Add new page"));
|
||||
if aresp.hovered() {
|
||||
ui.painter().rect_filled(ar, CornerRadius::same(5), t.hover);
|
||||
@@ -294,6 +303,7 @@ fn pages(app: &mut FigApp, ui: &mut Ui) {
|
||||
}
|
||||
if renaming {
|
||||
let tr = Rect::from_min_max(pos2(r.min.x + 8.0, r.min.y + 4.0), pos2(r.max.x - 4.0, r.max.y - 4.0));
|
||||
let tr = crate::widgets::flip_rect(rtl, r, tr);
|
||||
let start = ui.data_mut(|d| d.remove_temp::<bool>(page_rename_start_id())).unwrap_or(false);
|
||||
let font = if id == cur { semibold(11.0) } else { regular(11.0) };
|
||||
let (out, open) = crate::widgets::rename_field(ui, Id::unique(("pagename", id)), &name, tr, font, start);
|
||||
@@ -306,7 +316,8 @@ fn pages(app: &mut FigApp, ui: &mut Ui) {
|
||||
}
|
||||
} else if !divider {
|
||||
let font = if id == cur { semibold(11.0) } else { regular(11.0) };
|
||||
crate::bidi::paint_name(ui.painter(), pos2(r.min.x + 10.0, r.center().y), &name, font, t.text, r.width() - 14.0);
|
||||
let at = pos2(crate::widgets::flip_x(rtl, r, r.min.x + 10.0), r.center().y);
|
||||
crate::bidi::paint_name_from(ui.painter(), at, rtl, &name, font, t.text, r.width() - 14.0);
|
||||
}
|
||||
if resp.clicked() && !divider {
|
||||
select = Some(id);
|
||||
@@ -766,6 +777,7 @@ fn row_x0(rr: Rect, depth: usize) -> f32 {
|
||||
fn rename_field(app: &mut FigApp, ui: &mut Ui, id: NodeId, depth: usize, name: &str, r: Rect) -> Option<String> {
|
||||
let rr = r.shrink2(vec2(8.0, 0.0));
|
||||
let rect = Rect::from_min_max(pos2(row_x0(rr, depth) + 32.0, r.min.y + 4.0), pos2(rr.max.x - 4.0, r.max.y - 4.0));
|
||||
let rect = crate::widgets::flip_rect(crate::widgets::rtl(ui), rr, rect);
|
||||
let start = app.ui.rename.is_some_and(|x| x.start);
|
||||
let (out, open) = crate::widgets::rename_field(ui, rename_id(id), name, rect, regular(11.0), start);
|
||||
app.ui.rename = open.then_some(Rename { id, start: false });
|
||||
@@ -869,7 +881,9 @@ fn drop_zone(ui: &mut Ui, p: egui::Pos2, rects: [Rect; 2], x0: f32, id: NodeId,
|
||||
ui.ctx().request_repaint_after(std::time::Duration::from_millis(100));
|
||||
}
|
||||
} else {
|
||||
crate::widgets::insertion_line(ui.painter(), x0, rr.max.x, y);
|
||||
// From the row's indent to its end: mirrored, from its end on the left to the indent.
|
||||
let (a, b) = if crate::widgets::rtl(ui) { (rr.min.x, crate::widgets::flip_x(true, rr, x0)) } else { (x0, rr.max.x) };
|
||||
crate::widgets::insertion_line(ui.painter(), a, b, y);
|
||||
}
|
||||
(zone, open, ui.input(|i| i.pointer.any_released()))
|
||||
}
|
||||
@@ -1012,8 +1026,10 @@ fn eye_lock(
|
||||
// In Dev Mode they only show what is set.
|
||||
let show_lock = over || locked || row.locked_above;
|
||||
let show_eye = over || hidden;
|
||||
let er = Rect::from_center_size(pos2(rr.max.x - 14.0, r.center().y), vec2(20.0, 20.0));
|
||||
let lr = Rect::from_center_size(pos2(rr.max.x - 36.0, r.center().y), vec2(20.0, 20.0));
|
||||
// At the row's end: its left in a mirrored panel.
|
||||
let fx = |x: f32| crate::widgets::flip_x(crate::widgets::rtl(ui), rr, x);
|
||||
let er = Rect::from_center_size(pos2(fx(rr.max.x - 14.0), r.center().y), vec2(20.0, 20.0));
|
||||
let lr = Rect::from_center_size(pos2(fx(rr.max.x - 36.0), r.center().y), vec2(20.0, 20.0));
|
||||
if show_eye {
|
||||
icons::paint(ui.painter(), er.shrink(3.0), if hidden { Icon::EyeOff } else { Icon::Eye }, t.icon_secondary);
|
||||
}
|
||||
@@ -1111,8 +1127,11 @@ fn layers(app: &mut FigApp, ui: &mut Ui) {
|
||||
}
|
||||
let w = ui.available_width();
|
||||
let (hr, _) = ui.allocate_exact_size(vec2(w, 40.0), Sense::hover());
|
||||
ui.painter().text(pos2(hr.min.x + 16.0, hr.center().y), Align2::LEFT_CENTER, tr("Layers"), semibold(11.0), t.text);
|
||||
let sr = Rect::from_center_size(pos2(hr.max.x - 22.0, hr.center().y), vec2(24.0, 24.0));
|
||||
let rtl = crate::widgets::rtl(ui);
|
||||
let fx = |x: f32| crate::widgets::flip_x(rtl, hr, x);
|
||||
let start = if rtl { Align2::RIGHT_CENTER } else { Align2::LEFT_CENTER };
|
||||
ui.painter().text(pos2(fx(hr.min.x + 16.0), hr.center().y), start, tr("Layers"), semibold(11.0), t.text);
|
||||
let sr = Rect::from_center_size(pos2(fx(hr.max.x - 22.0), hr.center().y), vec2(24.0, 24.0));
|
||||
let sresp = ui.interact(sr, ui.scope_id().with("layer_search_btn"), Sense::click()).tip(tr("Search layers"));
|
||||
if sresp.hovered() || app.ui.layer_search {
|
||||
ui.painter().rect_filled(sr, CornerRadius::same(5), t.hover);
|
||||
@@ -1183,7 +1202,9 @@ fn layers(app: &mut FigApp, ui: &mut Ui) {
|
||||
// The drag is over a row that takes no drop: the not-allowed cursor shows.
|
||||
let mut refused = false;
|
||||
// Only the rows in view are laid out and drawn; the rest is empty scroll space.
|
||||
egui::ScrollArea::both().auto_shrink([false, false]).show_viewport(ui, |ui, viewport| {
|
||||
// A mirrored list starts scrolled to its right end, where its rows start (#1904's wide rows);
|
||||
// its own scroll state, so switching the UI language doesn't leave it at the left end.
|
||||
egui::ScrollArea::both().id_salt(("layer_list", rtl)).auto_shrink([false, false]).stick_to_right(rtl).show_viewport(ui, |ui, viewport| {
|
||||
let pitch = ROW + ui.spacing().item_spacing.y;
|
||||
let top = ui.max_rect().top();
|
||||
let left = ui.max_rect().left();
|
||||
@@ -1251,12 +1272,13 @@ fn layers(app: &mut FigApp, ui: &mut Ui) {
|
||||
}
|
||||
let x0 = row_x0(rr, row.depth);
|
||||
// Expand triangle.
|
||||
let fx = |x: f32| crate::widgets::flip_x(rtl, rr, x);
|
||||
if row.has_kids {
|
||||
let tri = Rect::from_center_size(pos2(x0 + 6.0, r.center().y), vec2(14.0, 14.0));
|
||||
let tri = Rect::from_center_size(pos2(fx(x0 + 6.0), r.center().y), vec2(14.0, 14.0));
|
||||
let tresp = ui.interact(tri, ui.scope_id().with(("tri", row.id)), Sense::click());
|
||||
let open = app.ui.expanded.contains(&row.id);
|
||||
a11y::button(&tresp, if open { tr("Collapse") } else { tr("Expand") });
|
||||
icons::paint(ui.painter(), tri.shrink(1.0), if open { Icon::Chevron } else { Icon::ChevronRight }, t.icon_secondary);
|
||||
icons::paint(ui.painter(), tri.shrink(1.0), crate::widgets::disclosure_icon(open, rtl), t.icon_secondary);
|
||||
if tresp.clicked() {
|
||||
if ui.input(|i| i.modifiers.alt) {
|
||||
deep = Some((row.id, !open));
|
||||
@@ -1268,7 +1290,7 @@ fn layers(app: &mut FigApp, ui: &mut Ui) {
|
||||
let icon = node_icon(&doc, row.id);
|
||||
let shown = n.visible && !row.dimmed;
|
||||
let icon_col = row_color(&t, is_comp || icon == Icon::Slot, shown, t.icon, t.text_tertiary);
|
||||
let icon_rect = Rect::from_center_size(pos2(x0 + 22.0, r.center().y), vec2(14.0, 14.0));
|
||||
let icon_rect = Rect::from_center_size(pos2(fx(x0 + 22.0), r.center().y), vec2(14.0, 14.0));
|
||||
icons::paint(ui.painter(), icon_rect, icon, icon_col);
|
||||
let name_x = x0 + 36.0;
|
||||
if app.ui.rename.is_some_and(|rn| rn.id == row.id) {
|
||||
@@ -1279,10 +1301,10 @@ fn layers(app: &mut FigApp, ui: &mut Ui) {
|
||||
let col = row_color(&t, is_comp, shown, t.text, t.text_tertiary);
|
||||
let font = name_font(&doc, page, n);
|
||||
let name = row_name(n).to_string();
|
||||
// Room left of the lock and eye buttons (the row is wide enough for the whole
|
||||
// Room before the lock and eye buttons (the row is wide enough for the whole
|
||||
// name, up to `NAME_ROOM`: a row widened by a deeper name gives no more).
|
||||
let max_w = (rr.max.x - 56.0 - name_x).clamp(20.0, NAME_ROOM);
|
||||
crate::bidi::paint_name(ui.painter(), pos2(name_x, r.center().y), &name, font, col, max_w);
|
||||
crate::bidi::paint_name_from(ui.painter(), pos2(fx(name_x), r.center().y), rtl, &name, font, col, max_w);
|
||||
}
|
||||
let (v, l) = eye_lock(ui, &t, [r, rr], row, n, over && !dev, dev, &mut sweep);
|
||||
vis = v.or(vis);
|
||||
|
||||
@@ -460,6 +460,9 @@ fn header(app: &mut FigApp, ui: &mut Ui, doc: &Document, sel: &[NodeId]) {
|
||||
};
|
||||
let w = ui.available_width();
|
||||
let (r, _) = ui.allocate_exact_size(vec2(w, 40.0), Sense::hover());
|
||||
// Laid out left to right, then mirrored inside the header in a right-to-left window.
|
||||
let rtl = widgets::rtl(ui);
|
||||
let flip = |rect: Rect| widgets::flip_rect(rtl, r, rect);
|
||||
// Keep the type menu and frame actions together. A short label must not leave
|
||||
// the orientation icon floating in the middle of the header.
|
||||
// The handoff icon also fits beside the frame controls at the panel minimum.
|
||||
@@ -479,33 +482,34 @@ fn header(app: &mut FigApp, ui: &mut Ui, doc: &Document, sel: &[NodeId]) {
|
||||
None if elided => text_width() + 28.0,
|
||||
None => 120.0,
|
||||
};
|
||||
let lr = Rect::from_min_size(pos2(r.min.x + 8.0, r.center().y - 12.0), vec2(label_width, 24.0));
|
||||
let lr_ltr = Rect::from_min_size(pos2(r.min.x + 8.0, r.center().y - 12.0), vec2(label_width, 24.0));
|
||||
let lr = flip(lr_ltr);
|
||||
let resp = ui.interact(lr, ui.scope_id().with("typedd"), Sense::click());
|
||||
if resp.hovered() {
|
||||
ui.painter().rect_filled(lr, CornerRadius::same(5), t.hover);
|
||||
}
|
||||
let resp = label_hover(resp, named.map(|(n, _)| n), &shown, &label);
|
||||
// The component icon at the label's start, the text after it: from the right when mirrored.
|
||||
let fx = |x: f32| widgets::flip_x(rtl, lr, x);
|
||||
let text_x = match named {
|
||||
Some((_, icon)) => {
|
||||
icons::paint(ui.painter(), Rect::from_center_size(pos2(lr.min.x + 14.0, lr.center().y), vec2(14.0, 14.0)), icon, COMPONENT);
|
||||
icons::paint(ui.painter(), Rect::from_center_size(pos2(fx(lr.min.x + 14.0), lr.center().y), vec2(14.0, 14.0)), icon, COMPONENT);
|
||||
lr.min.x + 26.0
|
||||
}
|
||||
None => lr.min.x + 8.0,
|
||||
};
|
||||
let label_rect = ui.painter().text(pos2(text_x, lr.center().y), Align2::LEFT_CENTER, &shown, semibold(13.0), t.text);
|
||||
let align = if rtl { Align2::RIGHT_CENTER } else { Align2::LEFT_CENTER };
|
||||
let label_rect = ui.painter().text(pos2(fx(text_x), lr.center().y), align, &shown, semibold(13.0), t.text);
|
||||
if is_frame || is_group {
|
||||
icons::paint(
|
||||
ui.painter(),
|
||||
Rect::from_center_size(pos2(label_rect.right() + 8.0, lr.center().y), vec2(10.0, 10.0)),
|
||||
Icon::Chevron,
|
||||
t.icon_secondary,
|
||||
);
|
||||
let chevron_x = if rtl { label_rect.left() - 8.0 } else { label_rect.right() + 8.0 };
|
||||
icons::paint(ui.painter(), Rect::from_center_size(pos2(chevron_x, lr.center().y), vec2(10.0, 10.0)), Icon::Chevron, t.icon_secondary);
|
||||
}
|
||||
if is_group {
|
||||
menu_popup(&resp).width(180.0).show(|ui| kind_items(app, ui, false));
|
||||
}
|
||||
if is_frame {
|
||||
let sr = Rect::from_min_size(pos2(lr.max.x + 2.0, r.center().y - 12.0), vec2(24.0, 24.0));
|
||||
let sr_ltr = Rect::from_min_size(pos2(lr_ltr.max.x + 2.0, r.center().y - 12.0), vec2(24.0, 24.0));
|
||||
let sr = flip(sr_ltr);
|
||||
let sresp = ui.interact(sr, ui.scope_id().with("swap_orient"), Sense::click()).tip(tr("Swap orientation"));
|
||||
if sresp.hovered() {
|
||||
ui.painter().rect_filled(sr, CornerRadius::same(5), t.hover);
|
||||
@@ -514,13 +518,14 @@ fn header(app: &mut FigApp, ui: &mut Ui, doc: &Document, sel: &[NodeId]) {
|
||||
if sresp.clicked() {
|
||||
app.run("frame.swapOrientation", json!({"ids": sel}));
|
||||
}
|
||||
let fit_r = sr.translate(vec2(26.0, 0.0));
|
||||
let fit_ltr = sr_ltr.translate(vec2(26.0, 0.0));
|
||||
let fit_r = flip(fit_ltr);
|
||||
let fit_tip = crate::shortcuts::tip(tr("Fit to contents"), "object.resizeToFit");
|
||||
if widgets::icon_button_at(ui, ui.scope_id().with("frame_fit_contents"), fit_r, Icon::FitContents, fit_tip) {
|
||||
app.run("object.resizeToFit", json!({"ids": sel}));
|
||||
}
|
||||
if figcraft_engine::devinspect::has_status(doc, sel[0]) {
|
||||
crate::section_panel::status_icon(app, ui, doc, sel, fit_r.translate(vec2(26.0, 0.0)));
|
||||
crate::section_panel::status_icon(app, ui, doc, sel, flip(fit_ltr.translate(vec2(26.0, 0.0))));
|
||||
}
|
||||
let ids: Vec<NodeId> = sel.to_vec();
|
||||
menu_popup(&resp).width(260.0).show(|ui| {
|
||||
@@ -554,7 +559,7 @@ fn header(app: &mut FigApp, ui: &mut Ui, doc: &Document, sel: &[NodeId]) {
|
||||
// With several layers the component button is a dropdown: a small chevron sits beside its icon.
|
||||
let dropdown = cmd == "component.create" && sel.len() > 1;
|
||||
let bw = if dropdown { 34.0 } else { 24.0 };
|
||||
let br = Rect::from_min_size(pos2(x - bw, r.center().y - 12.0), vec2(bw, 24.0));
|
||||
let br = flip(Rect::from_min_size(pos2(x - bw, r.center().y - 12.0), vec2(bw, 24.0)));
|
||||
let tip = if cmd == "bool.union" { label } else { crate::shortcuts::tip(label, cmd) };
|
||||
let bresp = ui.interact(br, ui.scope_id().with(("qa", cmd)), Sense::click()).tip(tip);
|
||||
if bresp.hovered() {
|
||||
|
||||
@@ -10,7 +10,9 @@ pub(crate) fn inspect_section(app: &mut FigApp, ui: &mut Ui, s: &figcraft_engine
|
||||
let t = Tokens::get(ui.ctx());
|
||||
widgets::separator(ui);
|
||||
let (hr, _) = ui.allocate_exact_size(vec2(ui.available_width(), 32.0), Sense::hover());
|
||||
ui.painter().text(pos2(hr.min.x + PAD, hr.center().y), Align2::LEFT_CENTER, tr(s.title), semibold(11.0), t.text);
|
||||
let rtl = widgets::rtl(ui);
|
||||
let align = if rtl { Align2::RIGHT_CENTER } else { Align2::LEFT_CENTER };
|
||||
ui.painter().text(pos2(widgets::flip_x(rtl, hr, hr.min.x + PAD), hr.center().y), align, tr(s.title), semibold(11.0), t.text);
|
||||
for p in &s.rows {
|
||||
prop_row(app, ui, p);
|
||||
}
|
||||
|
||||
@@ -175,9 +175,14 @@ pub(crate) fn row_target(ui: &mut Ui, h: f32, fill: Option<Color32>, add: impl F
|
||||
|
||||
/// Add a row's controls in `r`, on the section's grid, inset `inset_y` from its top and bottom.
|
||||
fn lay_out(ui: &mut Ui, r: Rect, inset_y: f32, add: impl FnOnce(&mut Ui)) {
|
||||
// The section's grid: 16 in from the left, 8 from the right (not 16 on both sides).
|
||||
let inner = Rect::from_min_max(pos2(r.min.x + PAD, r.min.y + inset_y), pos2(r.max.x - crate::widgets::PAD_RIGHT, r.max.y - inset_y));
|
||||
let mut child = ui.new_child(egui::UiBuilder::new().max_rect(inner).layout(egui::Layout::left_to_right(egui::Align::Center)));
|
||||
// The section's grid: 16 in from the start, 8 from the end (not 16 on both sides). Mirrored,
|
||||
// the row starts on the right and its controls run from right to left.
|
||||
let (start, end) = (PAD, crate::widgets::PAD_RIGHT);
|
||||
let rtl = crate::widgets::rtl(ui);
|
||||
let (left, right) = if rtl { (end, start) } else { (start, end) };
|
||||
let inner = Rect::from_min_max(pos2(r.min.x + left, r.min.y + inset_y), pos2(r.max.x - right, r.max.y - inset_y));
|
||||
let layout = if rtl { egui::Layout::right_to_left(egui::Align::Center) } else { egui::Layout::left_to_right(egui::Align::Center) };
|
||||
let mut child = ui.new_child(egui::UiBuilder::new().max_rect(inner).layout(layout));
|
||||
child.spacing_mut().item_spacing = vec2(crate::widgets::GUTTER, 0.0);
|
||||
add(&mut child);
|
||||
}
|
||||
|
||||
@@ -991,18 +991,46 @@ fn segments(
|
||||
/// clicked.
|
||||
pub fn disclosure(ui: &mut Ui, label: &str, open: bool) -> bool {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let rtl = rtl(ui);
|
||||
let galley = ui.painter().layout_no_wrap(label.to_string(), regular(11.0), t.text_secondary);
|
||||
let (rect, resp) = ui.allocate_exact_size(vec2(galley.size().x + 22.0, FIELD_H), Sense::click());
|
||||
a11y::disclosure(&resp, label, open);
|
||||
if resp.hovered() {
|
||||
ui.painter().rect_filled(rect, CornerRadius::same(4), t.hover);
|
||||
}
|
||||
let chevron = Rect::from_center_size(pos2(rect.min.x + 8.0, rect.center().y), vec2(10.0, 10.0));
|
||||
icons::paint(ui.painter(), chevron, if open { Icon::Chevron } else { Icon::ChevronRight }, t.icon_secondary);
|
||||
ui.painter().galley(pos2(rect.min.x + 18.0, rect.center().y - galley.size().y / 2.0), galley, t.text_secondary);
|
||||
let chevron = Rect::from_center_size(pos2(flip_x(rtl, rect, rect.min.x + 8.0), rect.center().y), vec2(10.0, 10.0));
|
||||
icons::paint(ui.painter(), chevron, disclosure_icon(open, rtl), t.icon_secondary);
|
||||
let x = if rtl { rect.max.x - 18.0 - galley.size().x } else { rect.min.x + 18.0 };
|
||||
ui.painter().galley(pos2(x, rect.center().y - galley.size().y / 2.0), galley, t.text_secondary);
|
||||
resp.clicked()
|
||||
}
|
||||
|
||||
/// A disclosure's chevron: down when open, else pointing to the end, right (left when `rtl`).
|
||||
pub fn disclosure_icon(open: bool, rtl: bool) -> Icon {
|
||||
match (open, rtl) {
|
||||
(true, _) => Icon::Chevron,
|
||||
(false, true) => Icon::ChevronLeft,
|
||||
(false, false) => Icon::ChevronRight,
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the panels lay out right to left: a mirrored window (a right-to-left UI language sets
|
||||
/// egui's `Style::right_to_left`), where a row starts at its right end.
|
||||
pub fn rtl(ui: &Ui) -> bool {
|
||||
ui.style().right_to_left
|
||||
}
|
||||
|
||||
/// `x`, measured from `within`'s left edge, mirrored to the same distance from its right edge
|
||||
/// when `rtl`.
|
||||
pub fn flip_x(rtl: bool, within: Rect, x: f32) -> f32 {
|
||||
if rtl { within.min.x + within.max.x - x } else { x }
|
||||
}
|
||||
|
||||
/// `r` mirrored inside `within` when `rtl` (see [`flip_x`]).
|
||||
pub fn flip_rect(rtl: bool, within: Rect, r: Rect) -> Rect {
|
||||
if rtl { Rect::from_x_y_ranges(flip_x(true, within, r.max.x)..=flip_x(true, within, r.min.x), r.y_range()) } else { r }
|
||||
}
|
||||
|
||||
/// A section header ("Fill", "Stroke"…) with optional right-side icon buttons; returns which
|
||||
/// button was clicked. `dim` greys the title (empty sections).
|
||||
pub fn section_header(ui: &mut Ui, title: &str, buttons: &[(Icon, &str)], dim: bool) -> Option<usize> {
|
||||
@@ -1012,6 +1040,7 @@ pub fn section_header(ui: &mut Ui, title: &str, buttons: &[(Icon, &str)], dim: b
|
||||
/// [`section_header`], with the header's own response for a right-click menu.
|
||||
pub fn section_header_resp(ui: &mut Ui, title: &str, buttons: &[(Icon, &str)], dim: bool) -> (Option<usize>, egui::Response) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let rtl = rtl(ui);
|
||||
let w = ui.available_width();
|
||||
let (rect, resp) = ui.allocate_exact_size(vec2(w, 40.0), Sense::click());
|
||||
// Only an empty section's header acts as its `+` button; elsewhere it is a right-click target
|
||||
@@ -1020,8 +1049,8 @@ pub fn section_header_resp(ui: &mut Ui, title: &str, buttons: &[(Icon, &str)], d
|
||||
ui.ctx().set_cursor_icon(egui::CursorIcon::Default);
|
||||
}
|
||||
ui.painter().text(
|
||||
pos2(rect.min.x + PAD, rect.center().y),
|
||||
Align2::LEFT_CENTER,
|
||||
pos2(flip_x(rtl, rect, rect.min.x + PAD), rect.center().y),
|
||||
if rtl { Align2::RIGHT_CENTER } else { Align2::LEFT_CENTER },
|
||||
title,
|
||||
semibold(11.0),
|
||||
if dim { t.text_secondary } else { t.text },
|
||||
@@ -1029,7 +1058,7 @@ pub fn section_header_resp(ui: &mut Ui, title: &str, buttons: &[(Icon, &str)], d
|
||||
let mut out = None;
|
||||
let mut x = rect.max.x - PAD_RIGHT;
|
||||
for (i, (icon, tip)) in buttons.iter().enumerate().rev() {
|
||||
let r = Rect::from_min_size(pos2(x - 24.0, rect.center().y - 12.0), vec2(24.0, 24.0));
|
||||
let r = flip_rect(rtl, rect, Rect::from_min_size(pos2(x - 24.0, rect.center().y - 12.0), vec2(24.0, 24.0)));
|
||||
let resp = ui.interact(r, ui.scope_id().with(("hdr", title, i)), Sense::click()).tip(*tip);
|
||||
if resp.hovered() {
|
||||
ui.painter().rect_filled(r, CornerRadius::same(5), t.hover);
|
||||
@@ -1058,8 +1087,13 @@ pub fn tight_end<R>(ui: &mut Ui, add: impl FnOnce(&mut Ui) -> R) -> R {
|
||||
pub fn tight_end_n<R>(ui: &mut Ui, count: usize, add: impl FnOnce(&mut Ui) -> R) -> R {
|
||||
let group = 24.0 * count as f32 + 4.0 * count.saturating_sub(1) as f32;
|
||||
let avail = ui.available_rect_before_wrap();
|
||||
let rect = Rect::from_min_max(pos2((avail.max.x - group).max(avail.min.x), avail.min.y), avail.max);
|
||||
let mut child = ui.new_child(egui::UiBuilder::new().max_rect(rect).layout(egui::Layout::left_to_right(egui::Align::Center)));
|
||||
// Mirrored, the row ends on the left and its buttons run from right to left.
|
||||
let (rect, layout) = if rtl(ui) {
|
||||
(Rect::from_min_max(avail.min, pos2((avail.min.x + group).min(avail.max.x), avail.max.y)), egui::Layout::right_to_left(egui::Align::Center))
|
||||
} else {
|
||||
(Rect::from_min_max(pos2((avail.max.x - group).max(avail.min.x), avail.min.y), avail.max), egui::Layout::left_to_right(egui::Align::Center))
|
||||
};
|
||||
let mut child = ui.new_child(egui::UiBuilder::new().max_rect(rect).layout(layout));
|
||||
child.spacing_mut().item_spacing.x = 4.0;
|
||||
// The row already gave the group its height (`block` allocated it): the cursor moves on only
|
||||
// past the group's width, so the next row keeps the row's own height.
|
||||
@@ -1314,14 +1348,16 @@ pub fn checkbox_tri(ui: &mut Ui, state: Option<bool>, label: &str) -> bool {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width().min(200.0), FIELD_H), Sense::click());
|
||||
a11y::checkbox_tri(&resp, label, state);
|
||||
let b = Rect::from_min_size(pos2(rect.min.x, rect.center().y - 7.0), vec2(14.0, 14.0));
|
||||
let rtl = rtl(ui);
|
||||
let b = flip_rect(rtl, rect, Rect::from_min_size(pos2(rect.min.x, rect.center().y - 7.0), vec2(14.0, 14.0)));
|
||||
if state != Some(false) {
|
||||
ui.painter().rect_filled(b, CornerRadius::same(3), t.accent);
|
||||
icons::paint(ui.painter(), b.shrink(1.5), if state.is_some() { Icon::Check } else { Icon::Minus }, t.accent_on);
|
||||
} else {
|
||||
ui.painter().rect_stroke(b, CornerRadius::same(3), Stroke::new(1.0, t.border_strong), StrokeKind::Inside);
|
||||
}
|
||||
ui.painter().text(pos2(b.max.x + 8.0, rect.center().y), Align2::LEFT_CENTER, label, regular(11.0), t.text);
|
||||
let (x, align) = if rtl { (b.min.x - 8.0, Align2::RIGHT_CENTER) } else { (b.max.x + 8.0, Align2::LEFT_CENTER) };
|
||||
ui.painter().text(pos2(x, rect.center().y), align, label, regular(11.0), t.text);
|
||||
resp.clicked()
|
||||
}
|
||||
|
||||
@@ -1330,14 +1366,16 @@ pub fn radio(ui: &mut Ui, on: bool, label: &str) -> bool {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width().min(240.0), FIELD_H), Sense::click());
|
||||
a11y::radio(&resp, label, on);
|
||||
let c = pos2(rect.min.x + 7.0, rect.center().y);
|
||||
let rtl = rtl(ui);
|
||||
let c = pos2(flip_x(rtl, rect, rect.min.x + 7.0), rect.center().y);
|
||||
if on {
|
||||
ui.painter().circle_filled(c, 7.0, t.accent);
|
||||
ui.painter().circle_filled(c, 2.5, t.accent_on);
|
||||
} else {
|
||||
ui.painter().circle_stroke(c, 6.5, Stroke::new(1.0, if resp.hovered() { crate::theme::ACCENT } else { t.border_strong }));
|
||||
}
|
||||
ui.painter().text(pos2(rect.min.x + 22.0, rect.center().y), Align2::LEFT_CENTER, label, regular(11.0), t.text);
|
||||
let align = if rtl { Align2::RIGHT_CENTER } else { Align2::LEFT_CENTER };
|
||||
ui.painter().text(pos2(flip_x(rtl, rect, rect.min.x + 22.0), rect.center().y), align, label, regular(11.0), t.text);
|
||||
resp.clicked()
|
||||
}
|
||||
|
||||
@@ -1421,7 +1459,9 @@ pub fn text_field_inline(ui: &mut Ui, id: Id, value: &str, rect: Rect, font: egu
|
||||
if resp.hovered() {
|
||||
ui.painter().rect_filled(rect.expand(2.0), CornerRadius::same(4), t.hover);
|
||||
}
|
||||
crate::bidi::paint_name(ui.painter(), rect.left_center(), value, font, t.text, rect.width());
|
||||
let rtl = rtl(ui);
|
||||
let start = if rtl { rect.right_center() } else { rect.left_center() };
|
||||
crate::bidi::paint_name_from(ui.painter(), start, rtl, value, font, t.text, rect.width());
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -1474,7 +1514,9 @@ pub fn sublabels(ui: &mut Ui, a: &str, b: Option<&str>) {
|
||||
for (i, (text, x, max_w)) in [(a, PAD, a_w)].into_iter().chain(b.map(|b| (b, PAD + col + GUTTER, w - col - GUTTER - PAD - PAD_RIGHT))).enumerate()
|
||||
{
|
||||
let shown = elide_font(ui, text, max_w, regular(10.0));
|
||||
let at = ui.painter().text(pos2(r.min.x + x, r.max.y), Align2::LEFT_BOTTOM, &shown, regular(10.0), t.text_secondary);
|
||||
// Mirrored, each label starts at its column's right edge.
|
||||
let align = if rtl(ui) { Align2::RIGHT_BOTTOM } else { Align2::LEFT_BOTTOM };
|
||||
let at = ui.painter().text(pos2(flip_x(rtl(ui), r, r.min.x + x), r.max.y), align, &shown, regular(10.0), t.text_secondary);
|
||||
if shown != text {
|
||||
ui.interact(at, ui.scope_id().with(("sublabel", i)), Sense::hover()).on_hover_text(text);
|
||||
}
|
||||
|
||||
+4
-6
@@ -18,7 +18,7 @@ No alpha blockers: the alpha gate in [`roadmap.md`](roadmap.md#alpha-gate) passe
|
||||
| 2 | Multiplayer and sharing are a preview, without accounts (**beta blocker**) | Feature | 42–84 | [collaboration-parity](collaboration-parity.md) |
|
||||
| 3 | No representative corpus checked against real Figma files | Fidelity | 15–30 | [target-app-parity](target-app-parity.md) |
|
||||
| 4 | Interaction fidelity not compared tool by tool | UI/UX | 40–60 | [ui-parity](ui-parity.md) |
|
||||
| 5 | Localization: English, reviewed Russian and Turkish, plus unreviewed Spanish (and Latin American Spanish), French, German, Brazilian Portuguese, Japanese, Korean, Simplified Chinese, Indonesian and Czech drafts; Turkish and Swedish catalogs; Arabic draft: 2,508 entries, native review and mirrored panel rows pending (the window mirrors) | Localization | 29–51 | [localization-parity](localization-parity.md) |
|
||||
| 5 | Localization: English, reviewed Russian and Turkish, plus unreviewed Spanish (and Latin American Spanish), French, German, Brazilian Portuguese, Japanese, Korean, Simplified Chinese, Indonesian and Czech drafts; Turkish and Swedish catalogs; Arabic draft: 2,508 entries, native review and the rest of the mirroring pending (the window, Design rows and layers mirror) | Localization | 29–51 | [localization-parity](localization-parity.md) |
|
||||
| 6 | Plugins: widgets without timers, a self-hosted directory but no public catalogue; Figma's plugins don't run | Ecosystem | 6–22 | [target-app-parity](target-app-parity.md) |
|
||||
| 7 | CPU canvas where Figma uses the GPU | Hardware/performance | 30–60 | [hardware-parity](hardware-parity.md) |
|
||||
| 8 | Platform QA: Linux and the browser left (Windows pass done 2026-10-11) | Stability/platforms | 10–20 | [hardware-parity](hardware-parity.md) |
|
||||
@@ -208,13 +208,11 @@ No alpha blockers: the alpha gate in [`roadmap.md`](roadmap.md#alpha-gate) passe
|
||||
|
||||
### 5. Localization: English, reviewed Russian and Turkish, plus unreviewed drafts
|
||||
- **Missing:** native reviews of the Spanish, French, German, Brazilian Portuguese, Japanese,
|
||||
Korean, Simplified Chinese, Indonesian and Czech drafts and the Latin American Spanish
|
||||
overlay, the strings added since each catalog was drafted (1–5% of each), the Arabic draft's native review and mirrored rows inside the panels (the window mirrors since 2026-10-31), Hindi and
|
||||
Vietnamese, localized engine messages and number formatting; CJK UI text on the web without the
|
||||
craft-fonts CJK build.
|
||||
Korean, Simplified Chinese, Traditional Chinese, Indonesian and Czech drafts and the Latin
|
||||
American Spanish overlay, the strings added since each catalog was drafted (1–5% of each), the
|
||||
Arabic draft's native review and panel mirroring, Hindi and Vietnamese, localized engine
|
||||
Arabic draft's native review and the rest of its mirroring (the Assets panel, Dev Mode, the
|
||||
toolbar, the tab bar and the home screen; the window mirrors since 2026-10-31, the Design
|
||||
panel's rows and the layers since 2026-11-18), Hindi and Vietnamese, localized engine
|
||||
messages and number formatting; CJK UI text on the web without the craft-fonts CJK build.
|
||||
- **Evidence (measured from source):** the layer landed 2026-10-11: catalogs in
|
||||
`crates/ui-egui/locales/` (measured 2026-11-03: 1,975 UI keys plus 641 command labels and 31
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Localization parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-07 · **Change:** minor (a right-to-left UI language (Arabic) mirrors the window: the icon rail and layers panel on the right, the Design panel on the left, popovers beside it over the canvas, egui's scroll bars, submenus and checkboxes mirrored; web builds with craft-fonts embed Noto Sans Arabic Regular by default, and required web builds reject catalogs without it, so Persian and Arabic documents draw without extra build flags (#1902); other scripts remain opt-in with `FIGCRAFT_EMBED_SCRIPTS`; documents: a paragraph's base direction can be forced with Text ▸ Text direction, as Add right-to-left text says (#1830); Bosnian draft catalog, one/few/other plurals; German terminology corrections (M10): gradient stops, OpenType stylistic sets and the Home-screen preference; partial review, catalog remains a draft; Arabic draft catalog, count-neutral plurals and web font gate; Thai draft catalog and Thai UI fonts; a missing translation fails no check: `cargo xtask i18n-report` lists them; Vietnamese draft catalog; string counts re-measured: 2,352 entries; Russian and Turkish catalogs reviewed by native speakers, Russian one/few/many plurals; Czech and Indonesian drafts; the Japanese draft completed; counts re-measured; Windows UI language from the first preferred language; draft catalogs catch up: every draft translates every string again; Simplified Chinese draft catalog; macOS finds its downloadable CJK system fonts (#406); string counts re-measured: 2,272 entries, the drafts at 95–99%; Swedish command labels and menu wordings; Russian, Swedish, Turkish, Czech and Indonesian listed; a duplicated paragraph removed) · **Target:** Figma Design (desktop app 126.10.7)
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-18 · **Change:** minor (a right-to-left UI language mirrors the rows of the Design panel (controls from the right, section buttons, sub-labels, checkboxes, radios and disclosures, the selection header) and the layers and pages lists (indent, disclosure, icon and name from the right, eye and padlock on the left, names and rename fields aligned to their start); a right-to-left UI language (Arabic) mirrors the window: the icon rail and layers panel on the right, the Design panel on the left, popovers beside it over the canvas, egui's scroll bars, submenus and checkboxes mirrored; web builds with craft-fonts embed Noto Sans Arabic Regular by default, and required web builds reject catalogs without it, so Persian and Arabic documents draw without extra build flags (#1902); other scripts remain opt-in with `FIGCRAFT_EMBED_SCRIPTS`; documents: a paragraph's base direction can be forced with Text ▸ Text direction, as Add right-to-left text says (#1830); Bosnian draft catalog, one/few/other plurals; German terminology corrections (M10): gradient stops, OpenType stylistic sets and the Home-screen preference; partial review, catalog remains a draft; Arabic draft catalog, count-neutral plurals and web font gate; Thai draft catalog and Thai UI fonts; a missing translation fails no check: `cargo xtask i18n-report` lists them; Vietnamese draft catalog; string counts re-measured: 2,352 entries; Russian and Turkish catalogs reviewed by native speakers, Russian one/few/many plurals; Czech and Indonesian drafts; the Japanese draft completed; counts re-measured; Windows UI language from the first preferred language; draft catalogs catch up: every draft translates every string again; Simplified Chinese draft catalog; macOS finds its downloadable CJK system fonts (#406); string counts re-measured: 2,272 entries, the drafts at 95–99%; Swedish command labels and menu wordings; Russian, Swedish, Turkish, Czech and Indonesian listed; a duplicated paragraph removed) · **Target:** Figma Design (desktop app 126.10.7)
|
||||
|
||||
FigCraft's interface has a localization layer with an English catalog, a Russian catalog reviewed
|
||||
by a native speaker, and Spanish (with a Latin American overlay), French, German, Brazilian
|
||||
@@ -74,8 +74,14 @@ supported by both apps (CJK, Arabic and Devanagari shaping, IME); Figma has no v
|
||||
the left with its edge and its popovers (colour picker, style picker, interaction editor) on the
|
||||
canvas side, the panel edges dragged the other way (same widths in the preferences), and egui's
|
||||
own chrome mirrored (scroll bars on the left, submenus opening left, checkbox labels on the left;
|
||||
`Style::right_to_left` in the egui fork). The rows inside the panels keep their left-to-right
|
||||
order (labels on the left, values on the right) and the toolbar and tab bar keep theirs. Cyrillic, Turkish and Czech letters draw from the UI fonts
|
||||
`Style::right_to_left` in the egui fork). The rows mirror too: the Design panel's rows run
|
||||
from the right (the shared row, section header, sub-label, checkbox, radio and disclosure
|
||||
helpers, and the selection header), and the layers and pages lists indent from the right with
|
||||
the disclosure, icon and name there and the eye and padlock on the left; names and rename
|
||||
fields align to their start. Inside a control nothing turns round: number fields, swatches and
|
||||
their values, and buttons for physical directions (align left, align right) stay as they are.
|
||||
Still left to right: the Assets panel, version history, Dev Mode's own layouts, the colour
|
||||
picker, the toolbar, the tab bar and the home screen. Cyrillic, Turkish and Czech letters draw from the UI fonts
|
||||
(no font added; Russian checked in screenshots). CJK translations are shorter than English; the same ellipsis
|
||||
and tooltip cover the few that don't fit (the sizing dropdowns).
|
||||
- **CJK UI fonts:** egui's fonts and Inter have no CJK glyphs. Once the UI language, the open
|
||||
@@ -114,7 +120,7 @@ supported by both apps (CJK, Arabic and Devanagari shaping, IME); Figma has no v
|
||||
| Traditional Chinese (Taiwan) | zh-Hant | 2,647 / 2,647 (100%: 1,975 UI strings, 641 command labels, 31 menu wordings; draft, counted 2026-11-03) | yes | CJK text and IME in documents; UI text in an installed Noto Sans CJK TC, then Microsoft JhengHei, PingFang TC or Heiti TC (web: only with a built-in TC face); zh-TW, zh-HK, zh-MO and zh-Hant read it, an explicit Hans stays Simplified | no | draft | 1–2 (after native review) |
|
||||
| Spanish | es, es-419 | 2,352 / 2,352 (100%, draft); es-419 overlays 104 Latin American wordings (draft) | yes | Latin | no | draft | 0–1 (after native review) |
|
||||
| Hindi | hi | 0 (0%) | no | Devanagari shaping works in documents; the desktop UI takes an installed Devanagari face (Nirmala UI, Kohinoor Devanagari, Noto Sans Devanagari, Lohit) for names and values (#2014); no UI catalog | no | none | 4–7 |
|
||||
| Arabic | ar | 1,857 / 1,857 UI strings, 620 command labels, 31 menu wordings (draft, counted 2026-10-28) | catalog complete; native review pending | Existing bidi/shaping and Arabic system fallback; web builds with craft-fonts embed Noto Sans Arabic by default for documents and the Arabic UI (#1902); the window mirrors (panels swap sides), rows inside the panels do not | no | draft | review + mirrored panel rows (not re-estimated) |
|
||||
| Arabic | ar | 1,857 / 1,857 UI strings, 620 command labels, 31 menu wordings (draft, counted 2026-10-28) | catalog complete; native review pending | Existing bidi/shaping and Arabic system fallback; web builds with craft-fonts embed Noto Sans Arabic by default for documents and the Arabic UI (#1902); the window and the Design panel's and layers' rows mirror; the Assets panel, Dev Mode, the toolbar and tab bar do not | no | draft | review + the rest of the mirroring (not re-estimated) |
|
||||
| French | fr | 2,328 / 2,352 (99.0%, draft) | yes | Latin | no | draft | 1–2 (after native review) |
|
||||
| Portuguese | pt-BR | 2,331 / 2,352 (99.1%, draft) | yes | Latin | no | draft | 1–2 (after native review) |
|
||||
| Indonesian | id | 2,292 / 2,352 (97.4%, draft) | yes | Latin | no | draft | 1–2 (after native review) |
|
||||
@@ -136,8 +142,9 @@ The layer is done. Per-language hours above are agent hours for a catalog of ~1,
|
||||
(a machine draft, then a pass over the panels for overflow), plus each language's plural rule where
|
||||
it isn't one/other; every language also needs a native speaker's review (human). Left before full
|
||||
parity besides the languages: localizing engine messages and number formatting (4–6 h);
|
||||
right-to-left mirroring of the rows inside the panels is in Arabic's hours (the window itself
|
||||
mirrors since 2026-10-31). Total: **29–51 h** (kept on
|
||||
the rest of the right-to-left mirroring (Assets, Dev Mode, the toolbar, the tab bar, the home
|
||||
screen) is in Arabic's hours (the window mirrors since 2026-10-31, the Design panel's rows and
|
||||
the layers since 2026-11-18). Total: **29–51 h** (kept on
|
||||
2026-10-17: Indonesian's draft takes 2–3 h off, about what bringing the drafts back from 95% to
|
||||
every string adds).
|
||||
|
||||
@@ -149,6 +156,7 @@ Hindi and Arabic.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-18 | minor | Mirrored panel rows: in a right-to-left UI the shared panel row (`right::block`) lays its controls out from the right, and the section header, `tight_end`, sub-labels, checkbox, radio and disclosure helpers, the selection header and the Dev Mode and export section titles mirror; the layers and pages lists and the left panel's header mirror (indent, disclosure, icon and name from the right, eye and padlock on the left, `bidi::paint_name_from`), and name fields align to their start; the layers list, as wide as its widest name (#1904), starts scrolled to its right end. Evidence: `crates/ui-egui/src/mirror_tests.rs`. The Assets panel, version history, Dev Mode's layouts, the colour picker, the toolbar, the tab bar and the home screen stay left to right. No grade change |
|
||||
| 2026-11-13 | patch | Rows that recent merges had duplicated or garbled are merged back into one row each (no behaviour change): Hindi, Arabic. |
|
||||
| 2026-11-07 | patch | M10, #1902: Noto Sans Arabic Regular joins the default web font catalog, so Persian and Arabic documents no longer need `FIGCRAFT_EMBED_SCRIPTS=Arab`. Required web builds fail if the face is missing; web fonts are packed losslessly and restored once at runtime to preserve the WASM size budget. Failed decoding reports the face once; generated catalog initialization is covered by a compiler regression. Other script fonts stay optional. Exact Iran Sans rendering requires that installed font through supported browsers' local font access. Existing duplicate Arabic rows and the repeated web-font paragraph are consolidated, preserving the mirrored window and pending panel-row mirroring. Grades and estimates unchanged. |
|
||||
| 2026-11-03 | minor | Traditional Chinese (Taiwan) (`zh-Hant`, 繁體中文(台灣)) draft catalog: every UI string (1,975), command label (641) and menu wording (31), translated clean-room from the English source and marked as a draft awaiting native review. `zh-TW`, `zh-HK`, `zh-MO` and `zh-Hant` read it; an explicit Hans still reads Simplified Chinese. The desktop UI prefers an installed Noto Sans CJK TC, then Microsoft JhengHei, PingFang TC and Heiti TC; no font is bundled. No plural forms. Localization grade and estimates unchanged |
|
||||
|
||||
+3
-2
@@ -123,8 +123,9 @@ with craft-fonts include Noto Sans Arabic by default and offer Arabic. This fall
|
||||
and Arabic text readable; matching Iran Sans exactly still requires that installed font. In a
|
||||
browser that supports local font access, choose “Use fonts installed on this computer…” in the
|
||||
Design panel's font menu and grant the browser's permission. No font is added to this repository.
|
||||
The window mirrors (the panels swap sides), but rows inside the panels keep their left-to-right
|
||||
order. Native review and representative in-app checks remain required.
|
||||
The window mirrors (the panels swap sides), and so do the Design panel's rows and the layers; the
|
||||
Assets panel, Dev Mode, the toolbar and the tab bar keep their left-to-right order. Native review
|
||||
and representative in-app checks remain required.
|
||||
|
||||
## Tamil draft
|
||||
|
||||
|
||||
Reference in new issue
Block a user