Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions crates/ui-egui/src/analysispane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1828,10 +1828,9 @@ fn trend(app: &mut RustGisApp, ui: &mut Ui, rasters: &[String]) {
});
} else {
let was_stack = f.stack;
ui.horizontal(|ui| {
ui.radio_value(&mut f.stack, true, tl!("Layers, a date each"));
ui.radio_value(&mut f.stack, false, tl!("One layer: a Zarr variable or a raster's bands"));
});
// One under the other: the second is too long to share a line in a narrow pane.
ui.radio_value(&mut f.stack, true, tl!("Layers, a date each"));
ui.radio_value(&mut f.stack, false, tl!("One layer: a Zarr variable or a raster's bands"));
// Dates typed for one kind of series don't carry over to the other.
if f.stack != was_stack {
f.dates.clear();
Expand Down Expand Up @@ -1871,7 +1870,7 @@ fn trend(app: &mut RustGisApp, ui: &mut Ui, rasters: &[String]) {
// A catalog's cube takes its dates from its items or its store.
if f.cube.is_none() {
let input_label = ui.label(tl!("Dates"));
ui.add(egui::TextEdit::singleline(&mut f.dates).hint_text(tl!("from the names")).desired_width(240.0))
ui.add(egui::TextEdit::singleline(&mut f.dates).hint_text(tl!("from the names")).desired_width(crate::widgets::fit(ui, 240.0)))
.labelled_by(input_label.id);
ui.end_row();
}
Expand All @@ -1885,7 +1884,8 @@ fn trend(app: &mut RustGisApp, ui: &mut Ui, rasters: &[String]) {
let shown = tests.iter().find(|t| t.0 == f.test).map_or("", |t| t.1);
egui::ComboBox::from_id_salt("trend_test")
.selected_text(tl!(shown))
.width(240.0)
.width(crate::widgets::fit(ui, 240.0))
.truncate()
.show_ui(ui, |ui| {
for (code, label) in tests {
ui.selectable_value(&mut f.test, code.to_string(), tl!(label));
Expand Down Expand Up @@ -2307,7 +2307,14 @@ fn script_below(app: &RustGisApp, ui: &Ui) -> f32 {
let results = if app.workflow.script_out.is_empty() { 0.0 } else { script_out_height(ui) + gap };
// The row that says where the cursor is (#2831).
let cursor = script_cursor_height(ui) + gap;
ui.spacing().interact_size.y + gap * 3.0 + cursor + last + results
// The buttons' row: as tall as it was last drawn, which is more than a row where it wraps.
let actions = ui.data(|d| d.get_temp::<f32>(script_actions_key())).unwrap_or(0.0).max(ui.spacing().interact_size.y);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The buttons' row height is read from last frame's measurement. On the frame the row starts or stops wrapping (for example when the pane is resized), the box is sized with the previous height for one frame, so the wrapped row can sit past the pane's bottom edge until the next frame is drawn. egui repaints on resize, so this probably settles at once and is not a lasting clip. Worth a note in the comment, or a test that resizes the pane between two frames and checks the row's position in the second. This is a new point, not the earlier concern about the fixed budget, which this change addresses.

Category: quality

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left for the release quality pass: egui draws the next frame at once on a resize, so the row settles there.

actions + gap * 3.0 + cursor + last + results
}

/// Where the Script pane keeps how tall its buttons' row was last drawn.
fn script_actions_key() -> egui::Id {
egui::Id::unique("script_actions_height")
}

/// Runs the Script pane's `script`: on the desktop its tools on a thread of their own first, the
Expand Down Expand Up @@ -2579,7 +2586,7 @@ fn script(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, fit: bool) {
.on_hover_text(tl!("The cursor's line and column, and how many characters are selected"));
}
});
ui.horizontal(|ui| {
let actions = ui.horizontal_wrapped(|ui| {
// As egui reads the keys: ⌘ on a Mac, the browser's too (from its user agent).
let mac = ui.ctx().os().is_mac();
let shortcut = if mac { "⌘+Enter" } else { "Ctrl+Enter" };
Expand Down Expand Up @@ -2615,6 +2622,8 @@ fn script(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, fit: bool) {
clear_keeping_undo(app, ui, box_id);
}
});
// How tall the buttons' row was: it wraps in a narrow pane, and the box leaves it room.
ui.data_mut(|d| d.insert_temp(script_actions_key(), actions.response.rect.height()));
// Above the results' scroll, so it stays in view: its number and how long it took, and on
// the right when it started, as the Geoprocessing History tells it (UTC: the app has no time
// zone).
Expand Down
19 changes: 15 additions & 4 deletions crates/ui-egui/src/assistantpane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) {
.id_salt("assistant_settings_scroll")
.auto_shrink([false, true])
.min_scrolled_height(0.0)
.max_height((ui.available_height() - 8.0).max(0.0))
// The conversation keeps room for a few lines below, where it scrolls; in a short pane,
// less, so the settings keep most of it.
.max_height((ui.available_height() - 8.0 - CONVERSATION_ROOM.min(ui.available_height() * 0.3)).max(0.0))
.show(ui, |ui| {
egui::Frame::NONE.inner_margin(egui::Margin::symmetric(12, 4)).show(ui, |ui| settings(app, ui, t));
});
Expand All @@ -95,6 +97,9 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) {
});
}

/// The height the conversation keeps under open settings, at most: never over 30% of the pane.
const CONVERSATION_ROOM: f32 = 96.0;

fn composer_panel(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, busy: bool, ctx: &egui::Context) {
egui::Panel::bottom("assistant_composer")
.frame(egui::Frame::NONE.fill(t.pane).inner_margin(egui::Margin::symmetric(10, 8)))
Expand Down Expand Up @@ -260,13 +265,14 @@ fn provider_settings(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, cfg: &mut Co
.labelled_by(address_label.id);
ui.end_row();
let key_label = ui.label(tl!("API key"));
ui.horizontal(|ui| {
ui.horizontal_wrapped(|ui| {
let hint = if preset.is_some_and(|p| p.keyless) { tl!("not needed") } else { tl!("paste your key") };
let width = crate::widgets::fit(ui, 150.0);
ui.add(
egui::TextEdit::singleline(&mut cfg.key)
.id(egui::Id::unique(FIELDS[2]))
.password(!app.assistant.show_key)
.desired_width(150.0)
.desired_width(width)
.hint_text(hint),
)
.labelled_by(key_label.id);
Expand Down Expand Up @@ -870,7 +876,8 @@ fn transcript(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, ctx: &egui::Context
ui.add_space(8.0);
let mut chosen = None;
for s in SUGGESTIONS {
let b = egui::Button::new(RichText::new(tl!(s)).small()).corner_radius(12);
// Wrapped: a suggestion is wider than a narrow pane.
let b = egui::Button::new(RichText::new(tl!(s)).small()).corner_radius(12).wrap();
if ui.add(b).clicked() {
chosen = Some(tl!(s).to_string());
}
Expand Down Expand Up @@ -1480,6 +1487,10 @@ pub(crate) mod tests {
);
h.run_steps(4);
h.get_by_label("Tokens for this message: 1 234 in, 5 out");
// Below the provider's settings, which leave the conversation its room: folded, they make
// room for it.
h.get_by_label("AI provider").click();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new click folds the provider settings, but nothing asserts that it did. The test would pass if this click did nothing, so the comment above it ("folded, they make room for it") isn't checked. Add an assertion after the fold that a control inside the provider settings is gone, or that the conversation's line is now reachable, so the test fails without the fold.

Category: quality

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left for the release quality pass.

h.run_steps(4);
h.get_by_label("Show the tokens each message uses").click();
h.run_steps(4);
assert!(h.query_by_label("Tokens for this message: 1 234 in, 5 out").is_none());
Expand Down
5 changes: 3 additions & 2 deletions crates/ui-egui/src/backstage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ fn start(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) {
ui.add_space(24.0);
ui.label(egui::RichText::new(tl!("New Project")).font(semibold(15.0)));
ui.add_space(8.0);
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing = vec2(18.0, 0.0);
// The cards wrap to another row where the window is narrow.
ui.horizontal_wrapped(|ui| {
ui.spacing_mut().item_spacing = vec2(18.0, 18.0);
if card(ui, t, "Map", "A blank map with a basemap", "new_map") {
let _ = app.run_by_user("project.new", Value::Null);
if !crate::saveprompt::waiting(app) {
Expand Down
5 changes: 3 additions & 2 deletions crates/ui-egui/src/catalogsui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,10 @@ pub fn sourcecoop(app: &mut RustGisApp, ui: &mut egui::Ui) {
let busy = app.ui.catalogs.waiting.is_some();
let mut ask = None;
if !locked {
ui.horizontal(|ui| {
ui.horizontal_wrapped(|ui| {
let input_label = ui.label(tl!("Account"));
ui.add(egui::TextEdit::singleline(&mut app.ui.catalogs.account).hint_text(tl!("featured products")).desired_width(220.0))
let width = crate::widgets::fit(ui, 220.0);
ui.add(egui::TextEdit::singleline(&mut app.ui.catalogs.account).hint_text(tl!("featured products")).desired_width(width))
.labelled_by(input_label.id);
if ui.add_enabled(!busy, egui::Button::new(tl!("List Products"))).clicked() {
let a = app.ui.catalogs.account.trim().to_string();
Expand Down
24 changes: 15 additions & 9 deletions crates/ui-egui/src/editpanes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,18 @@ fn layer_names(app: &RustGisApp, pred: impl Fn(&rustgis_engine::map::Layer) -> b
app.session.map().layers.iter().filter(|l| pred(l)).map(|l| l.name.clone()).collect()
}

fn combo(ui: &mut Ui, id: &str, name: &str, value: &mut String, options: &[String]) {
/// A box choosing `value` from `options`, named `name` for its tooltip and screen readers.
fn combo(ui: &mut Ui, id: &str, name: &str, value: &mut String, options: &[String]) -> egui::Response {
egui::ComboBox::from_id_salt(id)
.selected_text(value.as_str())
.width(170.0)
.width(crate::widgets::fit(ui, 170.0))
.show_ui(ui, |ui| {
for o in options {
ui.selectable_value(value, o.clone(), o.as_str());
}
})
.response
.on_hover_text(tl!(name));
.on_hover_text(tl!(name))
}

pub fn editing(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) {
Expand Down Expand Up @@ -610,13 +611,18 @@ pub fn design(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) {
app.session.map().layer_by_name(n).map(|l| l.dataset.fields.iter().map(|f| f.name.clone()).collect()).unwrap_or_default()
};
let (of, df) = (fields_of(app, &app.forms.rel_origin), fields_of(app, &app.forms.rel_dest));
// A row each: two boxes side by side don't fit a narrow pane.
egui::Grid::new("rel").num_columns(2).spacing(vec2(6.0, 4.0)).show(ui, |ui| {
combo(ui, "rel_o", "Origin", &mut app.forms.rel_origin, &layers);
combo(ui, "rel_ok", "Origin key", &mut app.forms.rel_origin_key, &of);
ui.end_row();
combo(ui, "rel_d", "Destination", &mut app.forms.rel_dest, &layers);
combo(ui, "rel_dk", "Destination key", &mut app.forms.rel_dest_key, &df);
ui.end_row();
for (id, name, value, options) in [
("rel_o", "Origin", &mut app.forms.rel_origin, &layers),
("rel_ok", "Origin key", &mut app.forms.rel_origin_key, &of),
("rel_d", "Destination", &mut app.forms.rel_dest, &layers),
("rel_dk", "Destination key", &mut app.forms.rel_dest_key, &df),
] {
let label = ui.label(tl!(name));
combo(ui, id, name, value, options).labelled_by(label.id);
ui.end_row();
}
});
ui.add(egui::TextEdit::singleline(&mut app.forms.rel_name).hint_text(tl!("Relationship name")).desired_width(180.0));
if ui.button(tl!("Relate")).clicked() {
Expand Down
8 changes: 6 additions & 2 deletions crates/ui-egui/src/labelpane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ fn classes(app: &mut RustGisApp, ui: &mut Ui, l: &Layer, c: &Class, t: &Tokens)
ui.add_enabled_ui(!editing, |ui| {
let count = extras(l).count();
let at = c.name.and_then(|n| extras(l).position(|k| k.name == n));
ui.horizontal(|ui| {
ui.horizontal_wrapped(|ui| {
let full = l.labels.classes.len() >= MAX_LABEL_CLASSES;
let max = MAX_LABEL_CLASSES.to_string();
let new = ui
Expand Down Expand Up @@ -331,7 +331,11 @@ fn classes(app: &mut RustGisApp, ui: &mut Ui, l: &Layer, c: &Class, t: &Tokens)
}
}
// At the far end and in red: it is the one that deletes, and its name is close to
// Rename's.
// Rename's. On a row of its own where the pane is too narrow for it beside the rest.
let font = egui::TextStyle::Button.resolve(ui.style());
if ui.available_size_before_wrap().x < crate::widgets::text_w(ui, tl!("Remove"), font) + 2.0 * ui.spacing().button_padding.x {
ui.end_row();
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
let remove = ui
.add_enabled(at.is_some(), egui::Button::new(RichText::new(tl!("Remove")).color(t.red)))
Expand Down
Loading
Loading