Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panel with recent notifications #8465

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
596706c
wip
jprochazk Dec 15, 2024
abd712b
wip
jprochazk Dec 15, 2024
01f1591
basic functionality
jprochazk Dec 16, 2024
b48b299
Merge branch 'main' into jan/error-notification-panel
jprochazk Dec 16, 2024
9453818
trigger ci again
jprochazk Dec 16, 2024
19b94ee
try enable `js` feature for `jiff`
jprochazk Dec 16, 2024
8fbb134
add clear all + escape key
jprochazk Dec 16, 2024
0163757
Merge branch 'main' into jan/error-notification-panel
jprochazk Dec 16, 2024
8b08563
Merge branch 'main' into jan/error-notification-panel
jprochazk Dec 17, 2024
bd37a43
properly consume escape for notifications
jprochazk Dec 17, 2024
35b5fd6
fix scroll area max height
jprochazk Dec 17, 2024
2a8ad39
sort
jprochazk Dec 17, 2024
12e5f85
remove `jiff` usage
jprochazk Dec 17, 2024
eeea461
fix comment
jprochazk Dec 17, 2024
4b800e3
fix filtering and notification api
jprochazk Dec 17, 2024
c2816d7
docstring ttl
jprochazk Dec 17, 2024
cd8c26c
wording: clear -> dismiss
jprochazk Dec 17, 2024
9bb9c10
fix
jprochazk Dec 17, 2024
4829d79
move toast repaint
jprochazk Dec 17, 2024
b490615
copy
jprochazk Dec 17, 2024
e7b14da
no hardcoded `hex_color`
jprochazk Dec 17, 2024
aa6d96f
choose color based on unread notification level
jprochazk Dec 17, 2024
9535ada
rename `data` -> `notifications`
jprochazk Dec 17, 2024
36937dc
close on outside click
jprochazk Dec 17, 2024
c10d380
simplify things
jprochazk Dec 17, 2024
80a58db
improve naming
jprochazk Dec 17, 2024
6de032c
undo click outside
jprochazk Dec 17, 2024
f15162d
close on click outside
jprochazk Dec 17, 2024
13a2d8f
set width
jprochazk Dec 17, 2024
7b25504
keep track of unread notifications
jprochazk Dec 17, 2024
746a02c
track num of notifications
jprochazk Dec 17, 2024
7016886
fix height + unread
jprochazk Dec 17, 2024
3cc47f4
fix toast bg + unread
jprochazk Dec 17, 2024
65ed1aa
random sized
jprochazk Dec 17, 2024
7d10250
try fix width sizing
jprochazk Dec 17, 2024
666e87b
Merge branch 'main' into jan/error-notification-panel
jprochazk Dec 19, 2024
7ef6533
remove `jiff` dependency
jprochazk Dec 19, 2024
f6d73f1
fix open/close behavior using popup logic
jprochazk Dec 20, 2024
ff866d1
Merge branch 'main' into jan/error-notification-panel
jprochazk Dec 20, 2024
b4383e9
fix double space
jprochazk Dec 20, 2024
7ff684e
remove dead code
jprochazk Dec 20, 2024
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
28 changes: 28 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3665,6 +3665,33 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"

[[package]]
name = "jiff"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db69f08d4fb10524cacdb074c10b296299d71274ddbc830a8ee65666867002e9"
dependencies = [
"jiff-tzdb-platform",
"js-sys",
"wasm-bindgen",
"windows-sys 0.59.0",
]

[[package]]
name = "jiff-tzdb"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91335e575850c5c4c673b9bd467b0e025f164ca59d0564f69d0c2ee0ffad4653"

[[package]]
name = "jiff-tzdb-platform"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9835f0060a626fe59f160437bc725491a6af23133ea906500027d1bd2f8f4329"
dependencies = [
"jiff-tzdb",
]

[[package]]
name = "jni"
version = "0.21.1"
Expand Down Expand Up @@ -6491,6 +6518,7 @@ dependencies = [
"egui_extras",
"egui_kittest",
"egui_tiles",
"jiff",
"once_cell",
"parking_lot",
"rand",
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ indicatif = "0.17.7" # Progress bar
infer = "0.16" # infer MIME type by checking the magic number signaturefer MIME type by checking the magic number signature
insta = "1.23"
itertools = "0.13"
jiff = "0.1.15"
jprochazk marked this conversation as resolved.
Show resolved Hide resolved
js-sys = "0.3"
libc = "0.2"
linked-hash-map = { version = "0.5", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions crates/utils/re_log/src/channel_logger.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Capture log messages and send them to some receiver over a channel.

#[derive(Clone)]
pub struct LogMsg {
/// The verbosity level.
pub level: log::Level,
Expand Down
5 changes: 5 additions & 0 deletions crates/viewer/re_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ smallvec.workspace = true
strum_macros.workspace = true
strum.workspace = true
sublime_fuzzy.workspace = true
jiff.workspace = true
jprochazk marked this conversation as resolved.
Show resolved Hide resolved


[target.'cfg(target_arch = "wasm32")'.dependencies]
jiff = { workspace = true, features = ["js"] }


[dev-dependencies]
Expand Down
Binary file added crates/viewer/re_ui/data/icons/notification.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 32 additions & 40 deletions crates/viewer/re_ui/examples/re_ui_example/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ mod drag_and_drop;
mod hierarchical_drag_and_drop;
mod right_panel;

use re_ui::notifications;
use re_ui::{
list_item, toasts, CommandPalette, ContextExt as _, DesignTokens, UICommand, UICommandSender,
list_item, CommandPalette, ContextExt as _, DesignTokens, UICommand, UICommandSender,
UiExt as _,
};

Expand Down Expand Up @@ -64,7 +65,7 @@ fn main() -> eframe::Result {
}

pub struct ExampleApp {
toasts: toasts::Toasts,
notifications: notifications::NotificationUi,

/// Listens to the local text log stream
text_log_rx: std::sync::mpsc::Receiver<re_log::LogMsg>,
Expand All @@ -77,6 +78,7 @@ pub struct ExampleApp {
/// modal with full span mode
full_span_modal_handler: re_ui::modal::ModalHandler,

show_notification_panel: bool,
show_left_panel: bool,
show_right_panel: bool,
show_bottom_panel: bool,
Expand All @@ -103,13 +105,14 @@ impl ExampleApp {
let (command_sender, command_receiver) = command_channel();

Self {
toasts: Default::default(),
notifications: Default::default(),
text_log_rx,

tree,
modal_handler: Default::default(),
full_span_modal_handler: Default::default(),

show_notification_panel: false,
show_left_panel: true,
show_right_panel: true,
show_bottom_panel: true,
Expand All @@ -127,26 +130,8 @@ impl ExampleApp {

/// Show recent text log messages to the user as toast notifications.
fn show_text_logs_as_notifications(&mut self) {
while let Ok(re_log::LogMsg {
level,
target: _,
msg,
}) = self.text_log_rx.try_recv()
{
let kind = match level {
re_log::Level::Error => toasts::ToastKind::Error,
re_log::Level::Warn => toasts::ToastKind::Warning,
re_log::Level::Info => toasts::ToastKind::Info,
re_log::Level::Debug | re_log::Level::Trace => {
continue; // too spammy
}
};

self.toasts.add(toasts::Toast {
kind,
text: msg,
options: toasts::ToastOptions::with_ttl_in_seconds(4.0),
});
while let Ok(re_log::LogMsg { level, msg, .. }) = self.text_log_rx.try_recv() {
self.notifications.add(level, msg);
}
}
}
Expand All @@ -158,7 +143,8 @@ impl eframe::App for ExampleApp {

fn update(&mut self, egui_ctx: &egui::Context, _frame: &mut eframe::Frame) {
self.show_text_logs_as_notifications();
self.toasts.show(egui_ctx);
self.notifications
.ui(egui_ctx, &mut self.show_notification_panel);

self.top_bar(egui_ctx);

Expand All @@ -174,29 +160,29 @@ impl eframe::App for ExampleApp {
let left_panel_top_section_ui = |ui: &mut egui::Ui| {
ui.horizontal_centered(|ui| {
ui.strong("Left bar");
});

if ui.button("Log info").clicked() {
re_log::info!(
"A lot of text on info level.\nA lot of text in fact. So \
if ui.button("Log info").clicked() {
re_log::info!(
"A lot of text on info level.\nA lot of text in fact. So \
much that we should ideally be auto-wrapping it at some point, much \
earlier than this."
);
}
if ui.button("Log warn").clicked() {
re_log::warn!(
"A lot of text on warn level.\nA lot of text in fact. So \
);
}
if ui.button("Log warn").clicked() {
re_log::warn!(
"A lot of text on warn level.\nA lot of text in fact. So \
much that we should ideally be auto-wrapping it at some point, much \
earlier than this."
);
}
if ui.button("Log error").clicked() {
re_log::error!(
"A lot of text on error level.\nA lot of text in fact. \
);
}
if ui.button("Log error").clicked() {
re_log::error!(
"A lot of text on error level.\nA lot of text in fact. \
So much that we should ideally be auto-wrapping it at some point, much \
earlier than this."
);
}
);
}
});
};

// bottom section closure
Expand Down Expand Up @@ -431,6 +417,12 @@ impl ExampleApp {
&re_ui::icons::LEFT_PANEL_TOGGLE,
&mut self.show_left_panel,
);

notifications::notification_toggle_button(
ui,
&mut self.show_notification_panel,
self.notifications.has_unread_notifications(),
);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_ui/src/context_ext.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use egui::{emath::Float, pos2, Align2, Color32, Mesh, Rect, Shape, Vec2};

use crate::toasts::SUCCESS_COLOR;
use crate::SUCCESS_COLOR;
use crate::{DesignTokens, TopBarStyle};

/// Extension trait for [`egui::Context`].
Expand Down
1 change: 1 addition & 0 deletions crates/viewer/re_ui/src/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub const ARROW_RIGHT: Icon = icon_from_path!("../data/icons/arrow_right.png");
pub const ARROW_DOWN: Icon = icon_from_path!("../data/icons/arrow_down.png");
pub const LOOP: Icon = icon_from_path!("../data/icons/loop.png");

pub const NOTIFICATION: Icon = icon_from_path!("../data/icons/notification.png");
pub const RIGHT_PANEL_TOGGLE: Icon = icon_from_path!("../data/icons/right_panel_toggle.png");
pub const BOTTOM_PANEL_TOGGLE: Icon = icon_from_path!("../data/icons/bottom_panel_toggle.png");
pub const LEFT_PANEL_TOGGLE: Icon = icon_from_path!("../data/icons/left_panel_toggle.png");
Expand Down
6 changes: 5 additions & 1 deletion crates/viewer/re_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ pub mod icons;
pub mod list_item;
mod markdown_utils;
pub mod modal;
pub mod notifications;
mod section_collapsing_header;
pub mod syntax_highlighting;
pub mod toasts;
mod ui_ext;
pub mod zoom_pan_area;

use egui::Color32;
use egui::NumExt as _;

pub use self::{
Expand Down Expand Up @@ -46,6 +47,9 @@ pub const CUSTOM_WINDOW_DECORATIONS: bool = false; // !FULLSIZE_CONTENT; // TODO
/// close/maximize/minimize buttons and app title.
pub const NATIVE_WINDOW_BAR: bool = !FULLSIZE_CONTENT && !CUSTOM_WINDOW_DECORATIONS;

pub const INFO_COLOR: Color32 = Color32::from_rgb(0, 155, 255);
pub const SUCCESS_COLOR: Color32 = Color32::from_rgb(0, 240, 32);

// ----------------------------------------------------------------------------

pub struct TopBarStyle {
Expand Down
Loading
Loading