Skip to content

Commit 3e2f71d

Browse files
committed
Native UI: Set Label to not selectable by default
* Labels should be not selectable by default making selecting a text an explicit opt-in configuration. * Change current labels removing code noise and applying selecting where it's needed
1 parent 552a4d7 commit 3e2f71d

File tree

20 files changed

+67
-59
lines changed

20 files changed

+67
-59
lines changed

application/apps/indexer/gui/application/src/common/modal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use egui::{
2-
Button, Context, Frame, Id, Label, ModalResponse, NumExt as _, Spinner, Ui, Widget as _, vec2,
2+
Button, Context, Frame, Id, ModalResponse, NumExt as _, Spinner, Ui, Widget as _, vec2,
33
};
44

55
/// Show standard modal dialog filled with the provided content.
@@ -31,7 +31,7 @@ where
3131
show_modal(ctx, "busy indicator", 200.0, |ui| {
3232
ui.vertical_centered(|ui| {
3333
if let Some(label) = label {
34-
Label::new(label).selectable(false).ui(ui);
34+
ui.label(label);
3535
ui.add_space(5.);
3636
}
3737
Spinner::new().size(25.).ui(ui);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use egui::Style;
2+
3+
/// Applies global style settings to the provided `style` object.
4+
pub fn global_styles(style: &mut Style) {
5+
// We expect the labels to be not selectable by default.
6+
style.interaction.selectable_labels = false;
7+
}

application/apps/indexer/gui/application/src/host/common/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod app_style;
12
pub mod colors;
23
pub mod dlt_stats;
34
pub mod file_utls;

application/apps/indexer/gui/application/src/host/ui/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::time::Duration;
22

33
use anyhow::ensure;
44
use eframe::NativeOptions;
5-
use egui::{Align, CentralPanel, Context, Frame, Layout, TopBottomPanel, Ui, Widget, vec2};
5+
use egui::{Align, CentralPanel, Context, Frame, Layout, TopBottomPanel, Ui, vec2};
66
use itertools::Itertools;
77
use log::{info, trace, warn};
88

@@ -11,6 +11,7 @@ use crate::{
1111
common::{modal::show_modal, phosphor},
1212
host::{
1313
command::{HostCommand, StartSessionParam},
14+
common::app_style,
1415
communication::{UiReceivers, UiSenders},
1516
message::HostMessage,
1617
service::HostService,
@@ -80,6 +81,8 @@ impl Host {
8081
ui_actions: UiActions::new(tokio_handle),
8182
};
8283

84+
ctx.egui_ctx.all_styles_mut(app_style::global_styles);
85+
8386
host.handle_cli(cli_cmds)?;
8487

8588
Ok(Box::new(host))
@@ -262,12 +265,10 @@ impl Host {
262265

263266
ui.add_space(6.);
264267

265-
egui::Label::new(
268+
ui.label(
266269
"A file picker is currently open.\
267270
If you don't see it, please check your taskbar or move this window",
268-
)
269-
.selectable(false)
270-
.ui(ui);
271+
);
271272
})
272273
});
273274
}

application/apps/indexer/gui/application/src/host/ui/multi_setup/main_table/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ mod table_columns;
1010

1111
pub fn render_content(ui: &mut Ui, state: &mut MultiFileState) {
1212
main_panel_group_frame(ui).show(ui, |ui| {
13-
Label::new(RichText::new("Multiple files").heading())
14-
.selectable(false)
15-
.ui(ui);
13+
ui.label(RichText::new("Multiple files").heading());
1614

1715
ui.add_space(10.);
1816

@@ -73,11 +71,9 @@ fn render_table(ui: &mut Ui, state: &mut MultiFileState) {
7371
}
7472

7573
fn table_header(ui: &mut Ui, column: TableColumn) {
76-
Label::new(RichText::new(column.header()).strong())
77-
.selectable(false)
78-
.ui(ui);
74+
ui.label(RichText::new(column.header()).strong());
7975
}
8076

8177
fn table_cell_text(ui: &mut Ui, content: String) {
82-
Label::new(content).selectable(false).truncate().ui(ui);
78+
Label::new(content).truncate().ui(ui);
8379
}

application/apps/indexer/gui/application/src/host/ui/multi_setup/side_panel.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ impl MultiSidePanel {
3737
}
3838

3939
fn render_summary(ui: &mut Ui, state: &mut MultiFileState) {
40-
Label::new(RichText::new("Summary").heading())
41-
.selectable(false)
42-
.ui(ui);
40+
ui.label(RichText::new("Summary").heading());
4341

4442
ui.add_space(6.);
4543

@@ -55,9 +53,7 @@ impl MultiSidePanel {
5553
}
5654

5755
fn render_overview(&mut self, ui: &mut Ui, state: &mut MultiFileState) {
58-
Label::new(RichText::new("Concat Overview").heading())
59-
.selectable(false)
60-
.ui(ui);
56+
ui.label(RichText::new("Concat Overview").heading());
6157
ui.add_space(6.);
6258

6359
// ------------------------------

application/apps/indexer/gui/application/src/host/ui/notification.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ impl NotificationUi {
257257
ui.add_space(8.);
258258

259259
ScrollArea::vertical().max_height(12.).show(ui, |ui| {
260-
let msg_lbl = Label::new(notification_msg).wrap_mode(egui::TextWrapMode::Wrap);
260+
let msg_lbl = Label::new(notification_msg)
261+
.selectable(true)
262+
.wrap_mode(egui::TextWrapMode::Wrap);
261263
ui.add(msg_lbl);
262264
});
263265
})

application/apps/indexer/gui/application/src/host/ui/session_setup/main_config/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn render_socket_address<C: ConfigBindAddress>(config: &mut C, ui: &mut Ui) -> R
9191
let mut outcome = RenderOutcome::None;
9292

9393
ui.vertical(|ui| {
94-
Label::new("Socket Address:").selectable(false).ui(ui);
94+
ui.label("Socket Address:");
9595

9696
let ip_txt_res = TextEdit::singleline(config.bind_addr())
9797
.vertical_align(Align::Center)
@@ -113,7 +113,7 @@ fn render_socket_address<C: ConfigBindAddress>(config: &mut C, ui: &mut Ui) -> R
113113
.size(10.5)
114114
.small()
115115
.color(ui.style().visuals.warn_fg_color);
116-
Label::new(err_txt).selectable(false).ui(ui);
116+
Label::new(err_txt).selectable(true).ui(ui);
117117
}
118118
});
119119
});

application/apps/indexer/gui/application/src/host/ui/session_setup/main_config/process.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ fn working_dir(config: &mut ProcessConfig, actions: &mut UiActions, ui: &mut Ui)
9595
egui::Sides::new().show(
9696
ui,
9797
|ui| {
98-
Label::new("Working Folder:").selectable(false).ui(ui);
99-
Label::new(path_txt).ui(ui);
98+
ui.label("Working Folder:");
99+
Label::new(path_txt).selectable(true).ui(ui);
100100
},
101101
|ui| {
102102
let btn_size = vec2(12., height);

application/apps/indexer/gui/application/src/host/ui/session_setup/main_config/serial.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use egui::{
2-
Align, Button, ComboBox, Frame, Label, Layout, Margin, Popup, RectAlign, RichText, TextEdit,
3-
Ui, Widget, vec2,
2+
Align, Button, ComboBox, Frame, Layout, Margin, Popup, RectAlign, RichText, TextEdit, Ui,
3+
Widget, vec2,
44
};
55

66
use crate::host::ui::session_setup::{
@@ -27,9 +27,7 @@ pub fn render_connection(config: &mut SerialConfig, ui: &mut Ui) -> RenderOutcom
2727
);
2828

2929
ui.separator();
30-
Label::new(RichText::new("Settings").heading().size(15.))
31-
.selectable(false)
32-
.ui(ui);
30+
ui.label(RichText::new("Settings").heading().size(15.));
3331

3432
ui.horizontal_wrapped(|ui| {
3533
ui.style_mut().spacing.combo_width = CONTROL_WIDTH;
@@ -201,7 +199,7 @@ fn labeled_field(ui: &mut Ui, label: &str, add_widget: impl FnOnce(&mut Ui)) {
201199
Frame::NONE
202200
.inner_margin(Margin::symmetric(CONTROL_GROUP_SIDE_MARGIN, 0))
203201
.show(ui, |ui| {
204-
Label::new(label).selectable(false).ui(ui);
202+
ui.label(label);
205203
add_widget(ui);
206204
});
207205
},

0 commit comments

Comments
 (0)