some more ui changes
This commit is contained in:
+24
-22
@@ -9,7 +9,6 @@ use crate::{
|
|||||||
util::{
|
util::{
|
||||||
consts::{ENHANCED, LEGACY},
|
consts::{ENHANCED, LEGACY},
|
||||||
elevation,
|
elevation,
|
||||||
ui_ext::UiExt,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
@@ -25,6 +24,7 @@ use sysinfo::System;
|
|||||||
use windows::Win32::Foundation::HANDLE;
|
use windows::Win32::Foundation::HANDLE;
|
||||||
|
|
||||||
const THEME: catppuccin_egui::Theme = catppuccin_egui::MOCHA;
|
const THEME: catppuccin_egui::Theme = catppuccin_egui::MOCHA;
|
||||||
|
const WINDOW_SIZE: [f32; 2] = [267.0, 237.0];
|
||||||
static CONFIG_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
|
static CONFIG_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
|
||||||
let mut config_path = dirs::config_local_dir().unwrap();
|
let mut config_path = dirs::config_local_dir().unwrap();
|
||||||
config_path.push("GTA Tools");
|
config_path.push("GTA Tools");
|
||||||
@@ -94,21 +94,23 @@ impl eframe::App for App {
|
|||||||
self.initialized = true;
|
self.initialized = true;
|
||||||
}
|
}
|
||||||
self.run_timers();
|
self.run_timers();
|
||||||
egui::TopBottomPanel::bottom("bottom_panel").show(ctx, |ui| {
|
egui::TopBottomPanel::bottom("bottom_panel")
|
||||||
ui.horizontal(|ui| {
|
.exact_height(25.0)
|
||||||
ui.selectable_value(&mut self.stage, Stage::Main, "Main");
|
.show(ctx, |ui| {
|
||||||
ui.selectable_value(&mut self.stage, Stage::About, "About");
|
ui.with_layout(egui::Layout::left_to_right(egui::Align::Center), |ui| {
|
||||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
ui.selectable_value(&mut self.stage, Stage::Main, "Main");
|
||||||
let button = ui
|
ui.selectable_value(&mut self.stage, Stage::About, "About");
|
||||||
.add_enabled(!self.elevated, egui::Button::new("Elevate"))
|
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||||
.on_hover_text("Relaunch ourselves as administrator.")
|
let button = ui
|
||||||
.on_disabled_hover_text("We are already running elevated.");
|
.add_enabled(!self.elevated, egui::Button::new("Elevate"))
|
||||||
if button.clicked() {
|
.on_hover_text("Relaunch ourselves as administrator.")
|
||||||
elevation::elevate(&mut self.closing);
|
.on_disabled_hover_text("We are already running elevated.");
|
||||||
}
|
if button.clicked() {
|
||||||
|
elevation::elevate(&mut self.closing);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
egui::ScrollArea::both()
|
egui::ScrollArea::both()
|
||||||
.auto_shrink([false, false])
|
.auto_shrink([false, false])
|
||||||
@@ -141,7 +143,7 @@ impl eframe::App for App {
|
|||||||
.with_title("GTA Tools Debug")
|
.with_title("GTA Tools Debug")
|
||||||
.with_minimize_button(false)
|
.with_minimize_button(false)
|
||||||
.with_maximize_button(false)
|
.with_maximize_button(false)
|
||||||
.with_inner_size([256.0, 232.0])
|
.with_inner_size(WINDOW_SIZE)
|
||||||
.with_position(position)
|
.with_position(position)
|
||||||
.with_icon(load_icon()),
|
.with_icon(load_icon()),
|
||||||
|ctx, _class| {
|
|ctx, _class| {
|
||||||
@@ -214,8 +216,8 @@ impl App {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
let force_close_button = ui.add_sized_left_aligned(
|
let force_close_button = ui.add_sized(
|
||||||
[105.0, 0.0],
|
[104.0, 0.0],
|
||||||
egui::Button::new(&self.force_close.button_text),
|
egui::Button::new(&self.force_close.button_text),
|
||||||
);
|
);
|
||||||
if force_close_button.clicked() && !self.force_close.prompting {
|
if force_close_button.clicked() && !self.force_close.prompting {
|
||||||
@@ -282,9 +284,9 @@ impl App {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
response
|
response.response.on_disabled_hover_text(
|
||||||
.response
|
"This requires administrator.\nUse the Elevate button.",
|
||||||
.on_disabled_hover_text("This requires administrator.\nUse the Elevate button.")
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +307,7 @@ impl App {
|
|||||||
));
|
));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ui.add(egui::Image::new(egui::include_image!("../assets/icon.png")))
|
ui.add(egui::Image::new(egui::include_image!("../assets/icon.png")));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,7 +378,7 @@ pub fn run() {
|
|||||||
viewport: egui::ViewportBuilder::default()
|
viewport: egui::ViewportBuilder::default()
|
||||||
.with_resizable(false)
|
.with_resizable(false)
|
||||||
.with_maximize_button(false)
|
.with_maximize_button(false)
|
||||||
.with_inner_size([256.0, 232.0])
|
.with_inner_size(WINDOW_SIZE)
|
||||||
.with_icon(load_icon()),
|
.with_icon(load_icon()),
|
||||||
centered: true,
|
centered: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
pub mod consts;
|
pub mod consts;
|
||||||
pub mod countdown;
|
pub mod countdown;
|
||||||
pub mod elevation;
|
pub mod elevation;
|
||||||
pub mod ui_ext;
|
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
use eframe::egui;
|
|
||||||
|
|
||||||
pub trait UiExt {
|
|
||||||
fn add_sized_left_aligned(
|
|
||||||
&mut self,
|
|
||||||
max_size: impl Into<egui::Vec2>,
|
|
||||||
widget: impl egui::Widget,
|
|
||||||
) -> egui::Response;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl UiExt for egui::Ui {
|
|
||||||
fn add_sized_left_aligned(
|
|
||||||
&mut self,
|
|
||||||
max_size: impl Into<egui::Vec2>,
|
|
||||||
widget: impl egui::Widget,
|
|
||||||
) -> egui::Response {
|
|
||||||
let layout = egui::Layout::top_down_justified(egui::Align::LEFT);
|
|
||||||
self.allocate_ui_with_layout(max_size.into(), layout, |ui| ui.add(widget))
|
|
||||||
.inner
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user