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

fix(dashboard): 🐛 Fix tooltips width #2297

Merged
merged 1 commit into from
Jul 30, 2024
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
2 changes: 2 additions & 0 deletions alvr/dashboard/src/dashboard/basic_components/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mod button_group;
mod switch;
mod tooltip;

pub use button_group::*;
pub use switch::*;
pub use tooltip::*;
5 changes: 5 additions & 0 deletions alvr/dashboard/src/dashboard/basic_components/tooltip.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use eframe::egui::{self, popup, Ui};

pub fn tooltip(ui: &mut Ui, id: &str, text: &str) {
popup::show_tooltip_text(ui.ctx(), ui.layer_id(), egui::Id::new(id), text);
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
use std::collections::{HashMap, HashSet};

use super::schema::{HigherOrderChoiceSchema, PresetModifierOperation};
use crate::dashboard::components::{self, NestingInfo, SettingControl, INDENTATION_STEP};
use crate::dashboard::{
basic_components,
components::{self, NestingInfo, SettingControl, INDENTATION_STEP},
};
use alvr_gui_common::theme::{
log_colors::{INFO_LIGHT, WARNING_LIGHT},
OK_GREEN,
};
use alvr_packets::{PathSegment, PathValuePair};
use eframe::egui::{self, popup, Ui};
use eframe::egui::Ui;
use serde_json as json;
use settings_schema::{SchemaEntry, SchemaNode};

const POPUP_ID: &str = "setpopup";

pub struct Control {
name: String,
help: Option<String>,
Expand Down Expand Up @@ -144,20 +145,14 @@ impl Control {

if let Some(string) = &self.help {
if ui.colored_label(INFO_LIGHT, "❓").hovered() {
popup::show_tooltip_text(
ui.ctx(),
ui.layer_id(),
egui::Id::new(POPUP_ID),
string,
);
basic_components::tooltip(ui, &format!("{}_help_tooltip", self.name), string);
}
}
if self.steamvr_restart_flag && ui.colored_label(WARNING_LIGHT, "⚠").hovered() {
popup::show_tooltip_text(
ui.ctx(),
ui.layer_id(),
egui::Id::new(POPUP_ID),
format!(
basic_components::tooltip(
ui,
"steamvr_restart_tooltip",
&format!(
"Changing this setting will make SteamVR restart!\n{}",
"Please save your in-game progress first"
),
Expand All @@ -166,10 +161,9 @@ impl Control {

// The emoji is blue but it will be green in the UI
if self.real_time_flag && ui.colored_label(OK_GREEN, "🔵").hovered() {
popup::show_tooltip_text(
ui.ctx(),
ui.layer_id(),
egui::Id::new(POPUP_ID),
basic_components::tooltip(
ui,
"real_time_tooltip",
"This setting can be changed in real-time during streaming!",
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use super::{collapsible, NestingInfo, SettingControl, INDENTATION_STEP};
use crate::dashboard::DisplayString;
use crate::dashboard::{basic_components, DisplayString};
use alvr_gui_common::theme::{
log_colors::{INFO_LIGHT, WARNING_LIGHT},
OK_GREEN,
};
use alvr_packets::PathValuePair;
use alvr_session::settings_schema::{SchemaEntry, SchemaNode};
use eframe::egui::{self, popup, Ui};
use eframe::egui::Ui;
use serde_json as json;

const POPUP_ID: &str = "setpopup";

struct Entry {
id: DisplayString,
help: Option<String>,
Expand Down Expand Up @@ -116,21 +114,19 @@ impl Control {

if let Some(string) = &entry.help {
if ui.colored_label(INFO_LIGHT, "❓").hovered() {
popup::show_tooltip_text(
ui.ctx(),
ui.layer_id(),
egui::Id::new(POPUP_ID),
basic_components::tooltip(
ui,
&format!("{}_help_tooltip", entry.id.display),
string,
);
}
}
if entry.steamvr_restart_flag && ui.colored_label(WARNING_LIGHT, "⚠").hovered()
{
popup::show_tooltip_text(
ui.ctx(),
ui.layer_id(),
egui::Id::new(POPUP_ID),
format!(
basic_components::tooltip(
ui,
"steamvr_restart_tooltip",
&format!(
"Changing this setting will make SteamVR restart!\n{}",
"Please save your in-game progress first"
),
Expand All @@ -139,10 +135,9 @@ impl Control {

// The emoji is blue but it will be green in the UI
if entry.real_time_flag && ui.colored_label(OK_GREEN, "🔵").hovered() {
popup::show_tooltip_text(
ui.ctx(),
ui.layer_id(),
egui::Id::new(POPUP_ID),
basic_components::tooltip(
ui,
"real_time_tooltip",
"This setting can be changed in real-time during streaming!",
);
}
Expand Down
11 changes: 7 additions & 4 deletions alvr/dashboard/src/dashboard/components/statistics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{dashboard::theme::graph_colors, dashboard::ServerRequest};
use crate::dashboard::{theme::graph_colors, ServerRequest};
use alvr_events::{GraphStatistics, StatisticsSummary};
use alvr_gui_common::theme;
use eframe::{
Expand Down Expand Up @@ -109,9 +109,12 @@ impl StatisticsTab {
RectTransform::from_to(canvas_response.response.rect, canvas_response.inner) * pos;
let history_index = (graph_pos.x as usize).clamp(0, GRAPH_HISTORY_SIZE - 1);

popup::show_tooltip(ui.ctx(), ui.layer_id(), Id::new("popup"), |ui| {
tooltip_content(ui, &self.history[history_index])
});
popup::show_tooltip(
ui.ctx(),
ui.layer_id(),
Id::new(format!("{title}_popup")),
|ui| tooltip_content(ui, &self.history[history_index]),
);
}
}

Expand Down
Loading