Initial commit.
commit
7813edebf6
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "file_touch"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
eframe = "0.19.0" # Gives us egui, epi and web+native backends
|
||||
egui-winit = "0.19.0"
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
utime = "0.3.1"
|
|
@ -0,0 +1,85 @@
|
|||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::{egui::{self}, HardwareAcceleration, Theme};
|
||||
use eframe::Theme::Light;
|
||||
use egui_winit::winit::window;
|
||||
use crate::egui::{Event, Vec2};
|
||||
|
||||
fn main() {
|
||||
let options = eframe::NativeOptions {
|
||||
always_on_top: false,
|
||||
maximized: false,
|
||||
decorated: true,
|
||||
default_theme: Theme::Light,
|
||||
drag_and_drop_support: true,
|
||||
icon_data: None,
|
||||
initial_window_pos: None,
|
||||
resizable: true,
|
||||
transparent: false,
|
||||
vsync: false,
|
||||
multisampling: 0,
|
||||
depth_buffer: 0,
|
||||
stencil_buffer: 0,
|
||||
hardware_acceleration: HardwareAcceleration::Preferred,
|
||||
renderer: Default::default(),
|
||||
min_window_size: Option::from(Vec2 { x: 400.0, y: 300.0 }),
|
||||
fullscreen: false,
|
||||
initial_window_size: Option::from(Vec2 { x: 600.0, y: 400.0 }),
|
||||
max_window_size: None,
|
||||
follow_system_theme: false,
|
||||
run_and_return: false
|
||||
};
|
||||
|
||||
eframe::run_native(
|
||||
"Touch Files",
|
||||
options,
|
||||
Box::new(|_cc| Box::new(MyApp::default())),
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct MyApp {
|
||||
allowed_to_close: bool,
|
||||
show_confirmation_dialog: bool,
|
||||
files_to_touch: Vec<String>
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn on_close_event(&mut self) -> bool {
|
||||
self.show_confirmation_dialog = true;
|
||||
self.allowed_to_close
|
||||
}
|
||||
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("Try to close the window");
|
||||
});
|
||||
|
||||
if self.show_confirmation_dialog {
|
||||
// Show confirmation dialog:
|
||||
egui::Window::new("Do you want to quit?")
|
||||
.collapsible(false)
|
||||
.resizable(false)
|
||||
.show(ctx, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("Cancel").clicked() {
|
||||
self.show_confirmation_dialog = false;
|
||||
}
|
||||
|
||||
if ui.button("Yes!").clicked() {
|
||||
self.allowed_to_close = true;
|
||||
frame.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if !ctx.input().raw.hovered_files.is_empty() {
|
||||
// Do a thing
|
||||
println!("Files are hovering");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue