mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Revert egui update due to a lot of issues arising from window closing
This commit is contained in:
@@ -107,7 +107,7 @@ impl eframe::App for RogApp {
|
||||
/// Called each time the UI needs repainting, which may be many times per
|
||||
/// second. Put your widgets into a `SidePanel`, `TopPanel`,
|
||||
/// `CentralPanel`, `Window` or `Area`.
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
fn update(&mut self, ctx: &eframe::egui::Context, frame: &mut eframe::Frame) {
|
||||
let states = self.states.clone();
|
||||
|
||||
if let Ok(mut states) = states.try_lock() {
|
||||
@@ -131,7 +131,7 @@ impl eframe::App for RogApp {
|
||||
return;
|
||||
}
|
||||
|
||||
self.top_bar(&mut states, ctx, frame);
|
||||
self.top_bar(ctx, frame);
|
||||
self.side_panel(ctx);
|
||||
}
|
||||
let page = self.page;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::RogApp;
|
||||
|
||||
impl RogApp {
|
||||
pub fn anime_page(&mut self, ctx: &egui::Context) {
|
||||
pub fn anime_page(&mut self, ctx: &eframe::egui::Context) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.label("In progress");
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::widgets::app_settings;
|
||||
use crate::RogApp;
|
||||
|
||||
impl RogApp {
|
||||
pub fn app_settings_page(&mut self, states: &mut SystemState, ctx: &egui::Context) {
|
||||
pub fn app_settings_page(&mut self, states: &mut SystemState, ctx: &eframe::egui::Context) {
|
||||
let Self { config, .. } = self;
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::widgets::{aura_modes_group, keyboard};
|
||||
use crate::RogApp;
|
||||
|
||||
impl RogApp {
|
||||
pub fn aura_page(&mut self, states: &mut SystemState, ctx: &egui::Context) {
|
||||
pub fn aura_page(&mut self, states: &mut SystemState, ctx: &eframe::egui::Context) {
|
||||
let Self {
|
||||
oscillator1,
|
||||
oscillator2,
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::widgets::fan_graphs;
|
||||
use crate::{RogApp, RogDbusClientBlocking};
|
||||
|
||||
impl RogApp {
|
||||
pub fn fan_curve_page(&mut self, states: &mut SystemState, ctx: &egui::Context) {
|
||||
pub fn fan_curve_page(&mut self, states: &mut SystemState, ctx: &eframe::egui::Context) {
|
||||
if let Some(mut throttle) = states.bios.throttle {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("Custom fan curves");
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::widgets::{anime_power_group, aura_power_group, platform_profile, rog_
|
||||
use crate::RogApp;
|
||||
|
||||
impl RogApp {
|
||||
pub fn system_page(&mut self, states: &mut SystemState, ctx: &egui::Context) {
|
||||
pub fn system_page(&mut self, states: &mut SystemState, ctx: &eframe::egui::Context) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("Laptop settings");
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use egui::plot::{Line, Plot, Points};
|
||||
use egui::Ui;
|
||||
use egui_plot::Points;
|
||||
use rog_platform::platform::PlatformPolicy;
|
||||
use rog_profiles::fan_curve_set::CurveData;
|
||||
use rog_profiles::FanCurvePU;
|
||||
@@ -60,8 +60,6 @@ pub fn fan_graphs(
|
||||
|
||||
let curve = curves.curves.get_mut(&curves.show_curve).unwrap();
|
||||
|
||||
use egui_plot::{Line, Plot};
|
||||
|
||||
let mut data = &mut CurveData::default();
|
||||
for c in curve {
|
||||
if c.fan == curves.show_graph {
|
||||
@@ -126,7 +124,7 @@ pub fn fan_graphs(
|
||||
}
|
||||
})
|
||||
.show(ui, |plot_ui| {
|
||||
if plot_ui.response().hovered() {
|
||||
if plot_ui.plot_hovered() {
|
||||
let mut idx = 0;
|
||||
|
||||
if let Some(point) = plot_ui.pointer_coordinate() {
|
||||
@@ -139,7 +137,7 @@ pub fn fan_graphs(
|
||||
}
|
||||
}
|
||||
|
||||
if plot_ui.response().clicked() {
|
||||
if plot_ui.plot_clicked() {
|
||||
data.temp[idx] = point.x as u8;
|
||||
data.pwm[idx] = (point.y * 255.0 / 100.0) as u8;
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{Page, RogApp};
|
||||
|
||||
impl RogApp {
|
||||
pub fn side_panel(&mut self, ctx: &egui::Context) {
|
||||
pub fn side_panel(&mut self, ctx: &eframe::egui::Context) {
|
||||
egui::SidePanel::left("side_panel")
|
||||
.resizable(false)
|
||||
.default_width(60.0) // TODO: set size to match icon buttons when done
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
use egui::{vec2, Align2, FontId};
|
||||
use egui::{vec2, Align2, FontId, Id, Sense};
|
||||
|
||||
use crate::system_state::SystemState;
|
||||
use crate::{RogApp, VERSION};
|
||||
|
||||
impl RogApp {
|
||||
pub fn top_bar(
|
||||
&mut self,
|
||||
_states: &mut SystemState,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
) {
|
||||
pub fn top_bar(&mut self, ctx: &eframe::egui::Context, frame: &mut eframe::Frame) {
|
||||
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
||||
// The top panel is often a good place for a menu bar:
|
||||
egui::menu::bar(ui, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
self.dark_light_mode_buttons(ui);
|
||||
egui::global_dark_light_mode_buttons(ui);
|
||||
egui::warn_if_debug_build(ui);
|
||||
});
|
||||
|
||||
@@ -22,12 +16,12 @@ impl RogApp {
|
||||
let text_color = ctx.style().visuals.text_color();
|
||||
let mut titlebar_rect = ui.available_rect_before_wrap();
|
||||
titlebar_rect.max.x -= titlebar_rect.height();
|
||||
// if ui
|
||||
// .interact(titlebar_rect, Id::new("title_bar"), Sense::drag())
|
||||
// .drag_started()
|
||||
// {
|
||||
// frame.drag_window();
|
||||
// }
|
||||
if ui
|
||||
.interact(titlebar_rect, Id::new("title_bar"), Sense::drag())
|
||||
.drag_started()
|
||||
{
|
||||
frame.drag_window();
|
||||
}
|
||||
|
||||
let height = titlebar_rect.height();
|
||||
|
||||
@@ -41,9 +35,9 @@ impl RogApp {
|
||||
);
|
||||
// // Add the close button:
|
||||
// let close_response = ui.put(
|
||||
// egui::Rect::from_min_size(titlebar_rect.right_top(),
|
||||
// egui::Vec2::splat(height)),
|
||||
// egui::Button::new(egui::RichText::new("❌").size(height -
|
||||
// Rect::from_min_size(titlebar_rect.right_top(),
|
||||
// Vec2::splat(height)),
|
||||
// Button::new(RichText::new("❌").size(height -
|
||||
// 4.0)).frame(false), );
|
||||
// if close_response.clicked() {
|
||||
// frame.close();
|
||||
@@ -51,34 +45,4 @@ impl RogApp {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn dark_light_mode_buttons(&mut self, ui: &mut egui::Ui) {
|
||||
let load_from_cfg = self.config.dark_mode != ui.ctx().style().visuals.dark_mode;
|
||||
|
||||
if ui
|
||||
.add(egui::SelectableLabel::new(
|
||||
!self.config.dark_mode,
|
||||
"☀ Light",
|
||||
))
|
||||
.clicked()
|
||||
|| (load_from_cfg && !self.config.dark_mode)
|
||||
{
|
||||
ui.ctx().set_visuals(egui::Visuals::light());
|
||||
}
|
||||
if ui
|
||||
.add(egui::SelectableLabel::new(self.config.dark_mode, "🌙 Dark"))
|
||||
.clicked()
|
||||
|| (load_from_cfg && self.config.dark_mode)
|
||||
{
|
||||
ui.ctx().set_visuals(egui::Visuals::dark());
|
||||
}
|
||||
|
||||
let applied_dark_mode = ui.ctx().style().visuals.dark_mode;
|
||||
|
||||
if self.config.dark_mode != applied_dark_mode {
|
||||
self.config.dark_mode = applied_dark_mode;
|
||||
let tmp = self.config.enabled_notifications.clone();
|
||||
self.config.save(&tmp).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user