Skip to content

Commit

Permalink
Merge branch 'budde25:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
superyu1337 authored Jul 6, 2022
2 parents 072f285 + 57e1f5a commit db69eee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ clap = { version = "3.2.8", features = ["derive"] }
color-eyre = "0.6.1"
dirs = "4.0.0"
eframe = { version = "0.18.0", features = ["dark-light"], optional = true }
egui = { version = "0.18.1", optional = true }
egui_extras = { version = "0.18.0", features = ["svg"], optional = true }
native-dialog = { version = "0.6.3", optional = true }
tegra-rcm = { version = "0.2.0", path = "crates/tegra-rcm" }
Expand All @@ -26,7 +25,7 @@ clap_complete = "3.2.3"

[features]
default = ["gui"]
gui = ["dep:egui", "dep:egui_extras", "dep:eframe", "dep:native-dialog"]
gui = ["dep:egui_extras", "dep:eframe", "dep:native-dialog"]

[workspace]
members = ["crates/tegra-rcm"]
Expand Down
35 changes: 17 additions & 18 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use std::sync::{Arc, Mutex};
use color_eyre::eyre::Result;

use super::favorites::Favorites;
use egui::{Button, Color32, RichText, Ui};
use eframe::egui::{
style, widgets, Button, CentralPanel, Color32, Context, RichText, TopBottomPanel, Ui,
};
use image::Images;
use native_dialog::FileDialog;
use tegra_rcm::{Error, Payload, Rcm};
Expand All @@ -29,8 +31,8 @@ pub fn gui() -> Result<()> {
"Switcheroo",
options,
Box::new(|cc| {
let mut style = egui::style::Style::default();
style.visuals = egui::style::Visuals::dark();
let mut style = style::Style::default();
style.visuals = style::Visuals::dark();
cc.egui_ctx.set_style(style);

usb::spawn_thread(rcm.clone(), cc.egui_ctx.clone());
Expand Down Expand Up @@ -137,8 +139,8 @@ impl MyApp {
}
}

fn main_tab(&mut self, ctx: &egui::Context) {
egui::CentralPanel::default().show(ctx, |ui| {
fn main_tab(&mut self, ctx: &Context) {
CentralPanel::default().show(ctx, |ui| {
ui.group(|ui| {
ui.add_space(10.0);
if let Some(payload_data) = &self.payload_data {
Expand Down Expand Up @@ -240,10 +242,7 @@ impl MyApp {
}

if ui
.add_enabled(
should_enabled,
egui::Button::new(RichText::new("♥").size(50.0)),
)
.add_enabled(should_enabled, Button::new(RichText::new("♥").size(50.0)))
.on_hover_text("Add currently loaded payload to favorites")
.clicked()
{
Expand Down Expand Up @@ -358,14 +357,14 @@ impl PayloadData {
}

impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
fn update(&mut self, ctx: &Context, _frame: &mut eframe::Frame) {
TopBottomPanel::top("top_panel").show(ctx, |ui| {
ui.horizontal(|ui| {
// Title
ui.label(RichText::new("Switcheroo").size(24.0).strong());

ui.separator();
egui::widgets::global_dark_light_mode_switch(ui);
widgets::global_dark_light_mode_switch(ui);

/*
ui.separator();
Expand Down Expand Up @@ -430,18 +429,18 @@ fn create_error_from_error(ui: &mut Ui, error: Error) {
}

/// Preview hovering files
fn preview_files_being_dropped(ctx: &egui::Context) {
use egui::*;
fn preview_files_being_dropped(ctx: &Context) {
use eframe::egui::{Align2, Id, LayerId, Order, TextStyle};

if !ctx.input().raw.hovered_files.is_empty() {
let mut text = "Dropping payload:\n".to_owned();
let mut text = "Dropping payload:\n\n".to_owned();
for file in &ctx.input().raw.hovered_files {
if let Some(path) = &file.path {
text += &format!("\n{}", path.display());
text += &path.as_os_str().to_string_lossy();
} else if !file.mime.is_empty() {
text += &format!("\n{}", file.mime);
text += &file.mime;
} else {
text += "\n???";
text += "???";
}
}

Expand Down
7 changes: 2 additions & 5 deletions src/gui/usb.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use std::thread;

use crate::Error;

use eframe::egui::Context;
use std::thread;
use tegra_rcm::{create_hotplug, Actions, Rcm};

use egui::Context;

use super::ThreadSwitchResult;

struct HotplugHandler {
Expand Down

0 comments on commit db69eee

Please sign in to comment.