Editor layout fixes from a visual check
No fog while painting, readable tool bars, a two-row spawn block, a dialog that keeps the clicks to itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
abe01ff23e
commit
aacc6a00b2
3 files changed
+77
-41
No files matched your search
+23
-9
@@ -169,7 +169,6 @@ impl BlockEdit {
|
||||
if im.button(gfx, Rect::new(CW(), CH() * 0.7, CW() * 12.0, CH() * 1.7), &tr("ed.back")) || (is_key_pressed(KeyCode::Escape) && !im.typing && self.drag.is_none()) {
|
||||
back = true;
|
||||
}
|
||||
gfx.text(&title, CW() * 14.0, CH() * 1.0, S(), FRAME_HI);
|
||||
let mut bx = w - CW();
|
||||
let buttons = [tr("ed.delete"), tr("ed.paste"), tr("ed.copy"), tr("ed.redo"), tr("ed.undo")];
|
||||
let mut pressed_btn = None;
|
||||
@@ -184,6 +183,10 @@ impl BlockEdit {
|
||||
let sw_ = CW() * 18.0;
|
||||
bx -= sw_ + CW();
|
||||
im.text_field(gfx, id("bsearch", 0), Rect::new(bx, CH() * 0.7, sw_, CH() * 1.7), &mut self.search, 24);
|
||||
// the script's name, as much as fits before the search field
|
||||
let room = ((bx - CW() * 15.0) / CW()).max(4.0) as usize;
|
||||
let title: String = title.chars().take(room).collect();
|
||||
gfx.text(&title, CW() * 14.0, CH() * 1.0, S(), FRAME_HI);
|
||||
if self.search.is_empty() && im.focus != Some(id("bsearch", 0)) {
|
||||
gfx.text(&tr("ed.search"), bx + CW() * 0.5, CH() * 1.0, S(), DIM);
|
||||
}
|
||||
@@ -294,7 +297,9 @@ impl BlockEdit {
|
||||
}
|
||||
y += CH() * 2.2;
|
||||
}
|
||||
gfx.text(&tr("ed.blocks_hint"), CW() * 0.5, h - CH() * 6.0, SMALL(), DIM);
|
||||
for (k, l) in wrap(&tr("ed.blocks_hint"), ((pal_w - CW()) / (GW * SMALL())) as usize).iter().enumerate() {
|
||||
gfx.text(l, CW() * 0.5, h - CH() * 6.0 + k as f32 * GH * SMALL() * 1.2, SMALL(), DIM);
|
||||
}
|
||||
|
||||
// ---- the script
|
||||
let ws = Rect::new(pal_w, top, w - pal_w, h - top - CH() * 2.0);
|
||||
@@ -418,13 +423,15 @@ impl BlockEdit {
|
||||
path.push(k);
|
||||
let cat = list[k].category();
|
||||
let col = cat_color(cat);
|
||||
let header = Rect::new(x, y, w, CH() * ROW);
|
||||
// the spawn block has many fields: two rows
|
||||
let rows = if matches!(list[k], Block::Spawn { .. }) { 2.0 } else { 1.0 };
|
||||
let header = Rect::new(x, y, w, CH() * ROW * rows);
|
||||
let problem = ctx.problems.iter().find(|(p, _)| *p == path).map(|(_, k)| *k);
|
||||
let selected = self.selected.as_ref() == Some(&path);
|
||||
let found = !ctx.search.is_empty() && (tr(&format!("blk.{}", list[k].kind_name())).to_lowercase().contains(&ctx.search) || block_text(&list[k]).to_lowercase().contains(&ctx.search));
|
||||
// slots: upper half before this block, lower half after it
|
||||
slots.push((Rect::new(x, y - CH() * 0.3, w, CH() * ROW * 0.5 + CH() * 0.3), lp.to_vec(), k));
|
||||
slots.push((Rect::new(x, y + CH() * ROW * 0.5, w, CH() * ROW * 0.5), lp.to_vec(), k + 1));
|
||||
slots.push((Rect::new(x, y - CH() * 0.3, w, header.h * 0.5 + CH() * 0.3), lp.to_vec(), k));
|
||||
slots.push((Rect::new(x, y + header.h * 0.5, w, header.h * 0.5), lp.to_vec(), k + 1));
|
||||
let nested = matches!(list[k], Block::If { .. } | Block::Repeat { .. });
|
||||
// the block: header row with its fields
|
||||
draw_block_shape(header, col, selected, found);
|
||||
@@ -433,7 +440,7 @@ impl BlockEdit {
|
||||
im.tip(header, &tr(p));
|
||||
}
|
||||
// grip: drag the block from here
|
||||
let grip = Rect::new(x, y, CW() * 1.4, CH() * ROW);
|
||||
let grip = Rect::new(x, y, CW() * 1.4, header.h);
|
||||
gfx.text("≡", x + CW() * 0.3, y + CH() * 0.6, S(), Color::new(1.0, 1.0, 1.0, 0.6));
|
||||
if im.pressed && im.over(grip) {
|
||||
im.pressed = false;
|
||||
@@ -441,7 +448,7 @@ impl BlockEdit {
|
||||
}
|
||||
let fy = y + (CH() * ROW - CH() * 1.5) * 0.5;
|
||||
let mut cx = x + CW() * 1.8;
|
||||
self.block_fields(im, gfx, &mut list[k], &path, &mut cx, fy, ctx);
|
||||
self.block_fields(im, gfx, &mut list[k], &path, &mut cx, fy, x + CW() * 3.0, ctx);
|
||||
// a click on the block's free area selects it
|
||||
if im.clicked(header) {
|
||||
ops.push(Op::Select(path.clone()));
|
||||
@@ -455,7 +462,7 @@ impl BlockEdit {
|
||||
}
|
||||
self.help = tr(&format!("blk.help.{}", list[k].kind_name()));
|
||||
}
|
||||
y += CH() * ROW;
|
||||
y += header.h;
|
||||
if nested {
|
||||
// the C shape: bodies indented, with an "else" bar for if
|
||||
let inner_x = x + CW() * 2.5;
|
||||
@@ -496,7 +503,7 @@ impl BlockEdit {
|
||||
|
||||
// the fields inside a block's header row
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn block_fields(&mut self, im: &mut Im, gfx: &Gfx, b: &mut Block, path: &[usize], cx: &mut f32, y: f32, ctx: &Ctx) {
|
||||
fn block_fields(&mut self, im: &mut Im, gfx: &Gfx, b: &mut Block, path: &[usize], cx: &mut f32, y: f32, x2: f32, ctx: &Ctx) {
|
||||
let word = |cx: &mut f32, s: &str| {
|
||||
gfx.text(s, *cx, y + CH() * 0.25, S(), TXT);
|
||||
*cx += gfx.measure(s, S()) + CW() * 0.6;
|
||||
@@ -517,6 +524,13 @@ impl BlockEdit {
|
||||
word(cx, &tr("blk.w_level"));
|
||||
self.value(im, gfx, level, Ty::Num, path, 3, cx, y, ctx);
|
||||
self.side_dd(im, gfx, side, false, path, 4, cx, y);
|
||||
// second row: where, and the name
|
||||
let y = y + CH() * ROW;
|
||||
*cx = x2;
|
||||
let word = |cx: &mut f32, s: &str| {
|
||||
gfx.text(s, *cx, y + CH() * 0.25, S(), TXT);
|
||||
*cx += gfx.measure(s, S()) + CW() * 0.6;
|
||||
};
|
||||
word(cx, &tr("blk.w_at"));
|
||||
let mut opts = vec![tr("blk.place_core"), tr("blk.place_event")];
|
||||
opts.extend(ctx.zones.iter().map(|z| trf("blk.place_zone", &[z.clone()])));
|
||||
|
||||
Reference in new issue
Block a user