From 744656cfd9a7fffe4dede1a97d331427f1c3f74a Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 15 Feb 2023 01:33:22 -0500 Subject: [PATCH] remove imgui (we're not using it) --- Cargo.lock | 230 +----------------- crates/programs/aichatbot-sidecar/Cargo.toml | 6 - .../src/gui/imgui_support.rs | 172 ------------- .../aichatbot-sidecar/src/gui/launch_imgui.rs | 31 --- .../programs/aichatbot-sidecar/src/gui/mod.rs | 4 +- 5 files changed, 5 insertions(+), 438 deletions(-) delete mode 100644 crates/programs/aichatbot-sidecar/src/gui/imgui_support.rs delete mode 100644 crates/programs/aichatbot-sidecar/src/gui/launch_imgui.rs diff --git a/Cargo.lock b/Cargo.lock index aa9265626b..39b391b404 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -677,15 +677,6 @@ dependencies = [ "errors", ] -[[package]] -name = "addr2line" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" -dependencies = [ - "gimli", -] - [[package]] name = "adler" version = "1.0.2" @@ -758,13 +749,9 @@ dependencies = [ "errors", "fakeyou_client", "files", - "glium", "hashing", "http_server_common", "idempotency", - "imgui", - "imgui-glium-renderer", - "imgui-winit-support", "log", "once_cell", "path-absolutize", @@ -1091,21 +1078,6 @@ dependencies = [ "tokio 1.25.0", ] -[[package]] -name = "backtrace" -version = "0.3.67" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" -dependencies = [ - "addr2line", - "cc", - "cfg-if 1.0.0", - "libc", - "miniz_oxide 0.6.2", - "object", - "rustc-demangle", -] - [[package]] name = "base-x" version = "0.2.8" @@ -1443,12 +1415,6 @@ dependencies = [ "libc", ] -[[package]] -name = "chlorine" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75476fe966a8af7c0ceae2a3e514afa87d4451741fcdfab8bfaa07ad301842ec" - [[package]] name = "chrono" version = "0.4.19" @@ -2421,7 +2387,7 @@ dependencies = [ "egui-winit", "egui_glow", "glow", - "glutin 0.30.3", + "glutin", "js-sys", "percent-encoding 2.2.0", "raw-window-handle 0.5.0", @@ -3008,12 +2974,6 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] -[[package]] -name = "gimli" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "221996f774192f0f718773def8201c4ae31f02616a54ccfc2d358bb0e5cefdec" - [[package]] name = "gl_generator" version = "0.14.0" @@ -3025,22 +2985,6 @@ dependencies = [ "xml-rs", ] -[[package]] -name = "glium" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2766728ecb86014b91d3d687614b32d65aacbbdc887f424a7b03cba3ab593bf" -dependencies = [ - "backtrace", - "fnv", - "gl_generator", - "glutin 0.29.1", - "lazy_static", - "memoffset", - "smallvec 1.10.0", - "takeable-option", -] - [[package]] name = "glow" version = "0.11.2" @@ -3053,32 +2997,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "glutin" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444c9ad294fdcaf20ccf6726b78f380b5450275540c9b68ab62f49726ad1c713" -dependencies = [ - "cgl", - "cocoa", - "core-foundation", - "glutin_egl_sys 0.1.6", - "glutin_gles2_sys", - "glutin_glx_sys 0.1.8", - "glutin_wgl_sys 0.1.5", - "libloading", - "log", - "objc", - "once_cell", - "osmesa-sys", - "parking_lot 0.12.1", - "raw-window-handle 0.5.0", - "wayland-client", - "wayland-egl", - "winapi 0.3.9", - "winit", -] - [[package]] name = "glutin" version = "0.30.3" @@ -3090,9 +3008,9 @@ dependencies = [ "cgl", "cocoa", "core-foundation", - "glutin_egl_sys 0.3.1", - "glutin_glx_sys 0.3.0", - "glutin_wgl_sys 0.3.0", + "glutin_egl_sys", + "glutin_glx_sys", + "glutin_wgl_sys", "libloading", "objc", "once_cell", @@ -3102,16 +3020,6 @@ dependencies = [ "x11-dl", ] -[[package]] -name = "glutin_egl_sys" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68900f84b471f31ea1d1355567eb865a2cf446294f06cef8d653ed7bcf5f013d" -dependencies = [ - "gl_generator", - "winapi 0.3.9", -] - [[package]] name = "glutin_egl_sys" version = "0.3.1" @@ -3122,26 +3030,6 @@ dependencies = [ "windows-sys 0.36.1", ] -[[package]] -name = "glutin_gles2_sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8094e708b730a7c8a1954f4f8a31880af00eb8a1c5b5bf85d28a0a3c6d69103" -dependencies = [ - "gl_generator", - "objc", -] - -[[package]] -name = "glutin_glx_sys" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d93d0575865098580c5b3a423188cd959419912ea60b1e48e8b3b526f6d02468" -dependencies = [ - "gl_generator", - "x11-dl", -] - [[package]] name = "glutin_glx_sys" version = "0.3.0" @@ -3152,15 +3040,6 @@ dependencies = [ "x11-dl", ] -[[package]] -name = "glutin_wgl_sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3da5951a1569dbab865c6f2a863efafff193a93caf05538d193e9e3816d21696" -dependencies = [ - "gl_generator", -] - [[package]] name = "glutin_wgl_sys" version = "0.3.0" @@ -3617,51 +3496,6 @@ dependencies = [ "uuid 0.8.2", ] -[[package]] -name = "imgui" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cea19ca90247d9c994663a9f68edd9792b26ad0af390ceb8b43e881c90121bc" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "imgui-sys", - "mint", - "parking_lot 0.12.1", -] - -[[package]] -name = "imgui-glium-renderer" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e25883dd9f02125af7167a07effe4aab4072e9f3857a63fb3c3f5572f7af5ac" -dependencies = [ - "glium", - "imgui", -] - -[[package]] -name = "imgui-sys" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "612ceabf43b8c293b165f987539018b3fe6e30dd8af0c890dee1461c75250adb" -dependencies = [ - "cc", - "cfg-if 1.0.0", - "chlorine", - "mint", -] - -[[package]] -name = "imgui-winit-support" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fde5f2092b5852a838ef13eb5dfbd58c18aa8754bbea45cffabd53efb584f3a" -dependencies = [ - "imgui", - "winit", -] - [[package]] name = "indexmap" version = "1.9.2" @@ -4227,12 +4061,6 @@ dependencies = [ "adler", ] -[[package]] -name = "mint" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e53debba6bda7a793e5f99b8dacf19e626084f525f7829104ba9898f367d85ff" - [[package]] name = "mio" version = "0.6.23" @@ -4723,15 +4551,6 @@ dependencies = [ "objc", ] -[[package]] -name = "object" -version = "0.30.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.17.0" @@ -4809,15 +4628,6 @@ dependencies = [ "hashbrown", ] -[[package]] -name = "osmesa-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b" -dependencies = [ - "shared_library", -] - [[package]] name = "owned_ttf_parser" version = "0.18.1" @@ -5715,12 +5525,6 @@ dependencies = [ "url 2.3.1", ] -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - [[package]] name = "rustc-serialize" version = "0.3.24" @@ -6132,16 +5936,6 @@ dependencies = [ "digest 0.10.3", ] -[[package]] -name = "shared_library" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" -dependencies = [ - "lazy_static", - "libc", -] - [[package]] name = "signal-hook-registry" version = "1.3.0" @@ -6866,12 +6660,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "takeable-option" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ae8932fcfea38b7d3883ae2ab357b0d57a02caaa18ebb4f5ece08beaec4aa0" - [[package]] name = "tempdir" version = "0.3.7" @@ -8145,16 +7933,6 @@ dependencies = [ "xcursor", ] -[[package]] -name = "wayland-egl" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402de949f81a012926d821a2d659f930694257e76dd92b6e0042ceb27be4107d" -dependencies = [ - "wayland-client", - "wayland-sys 0.29.5", -] - [[package]] name = "wayland-protocols" version = "0.29.5" diff --git a/crates/programs/aichatbot-sidecar/Cargo.toml b/crates/programs/aichatbot-sidecar/Cargo.toml index 304475b5d2..67ed3a958d 100644 --- a/crates/programs/aichatbot-sidecar/Cargo.toml +++ b/crates/programs/aichatbot-sidecar/Cargo.toml @@ -73,11 +73,5 @@ serde_yaml = "0.9.1" eframe = "0.20.1" egui = "0.20.1" -# Gui (Imgui) -imgui = "0.10.0" -glium = { version = "0.32.1", default-features = true } -imgui-glium-renderer = "0.10.0" -imgui-winit-support = "0.10.0" - # API integrations async-openai = "0.6.0" diff --git a/crates/programs/aichatbot-sidecar/src/gui/imgui_support.rs b/crates/programs/aichatbot-sidecar/src/gui/imgui_support.rs deleted file mode 100644 index 5b4e4f74b2..0000000000 --- a/crates/programs/aichatbot-sidecar/src/gui/imgui_support.rs +++ /dev/null @@ -1,172 +0,0 @@ -//! -//! Taken from https://github.com/imgui-rs/imgui-rs/blob/main/imgui-examples/examples/support/mod.rs -//! - -use glium::glutin::event::{Event, WindowEvent}; -use glium::glutin::event_loop::{ControlFlow, EventLoop}; -use glium::glutin::window::WindowBuilder; -use glium::glutin; -use glium::{Display, Surface}; -use imgui::{Context, FontConfig, FontGlyphRanges, FontSource, Ui}; -use imgui_glium_renderer::Renderer; -use imgui_winit_support::{HiDpiMode, WinitPlatform}; -use std::path::Path; -use std::time::Instant; - -//mod clipboard; - -pub struct System { - pub event_loop: EventLoop<()>, - pub display: glium::Display, - pub imgui: Context, - pub platform: WinitPlatform, - pub renderer: Renderer, - pub font_size: f32, -} - -pub fn init(title: &str) -> System { - let title = match Path::new(&title).file_name() { - Some(file_name) => file_name.to_str().unwrap(), - None => title, - }; - let event_loop = EventLoop::new(); - let context = glutin::ContextBuilder::new().with_vsync(true); - let builder = WindowBuilder::new() - .with_title(title.to_owned()) - .with_inner_size(glutin::dpi::LogicalSize::new(1024f64, 768f64)); - let display = - Display::new(builder, context, &event_loop).expect("Failed to initialize display"); - - let mut imgui = Context::create(); - imgui.set_ini_filename(None); - - //if let Some(backend) = clipboard::init() { - // imgui.set_clipboard_backend(backend); - //} else { - // eprintln!("Failed to initialize clipboard"); - //} - - let mut platform = WinitPlatform::init(&mut imgui); - { - let gl_window = display.gl_window(); - let window = gl_window.window(); - - let dpi_mode = if let Ok(factor) = std::env::var("IMGUI_EXAMPLE_FORCE_DPI_FACTOR") { - // Allow forcing of HiDPI factor for debugging purposes - match factor.parse::() { - Ok(f) => HiDpiMode::Locked(f), - Err(e) => panic!("Invalid scaling factor: {}", e), - } - } else { - HiDpiMode::Default - }; - - platform.attach_window(imgui.io_mut(), window, dpi_mode); - } - - // Fixed font size. Note imgui_winit_support uses "logical - // pixels", which are physical pixels scaled by the devices - // scaling factor. Meaning, 13.0 pixels should look the same size - // on two different screens, and thus we do not need to scale this - // value (as the scaling is handled by winit) - let font_size = 13.0; - - imgui.fonts().add_font(&[ - FontSource::TtfData { - data: include_bytes!("../../../../../assets/fonts/FiraSans-Regular.ttf"), - size_pixels: font_size, - config: Some(FontConfig { - // As imgui-glium-renderer isn't gamma-correct with - // it's font rendering, we apply an arbitrary - // multiplier to make the font a bit "heavier". With - // default imgui-glow-renderer this is unnecessary. - rasterizer_multiply: 1.5, - // Oversampling font helps improve text rendering at - // expense of larger font atlas texture. - oversample_h: 4, - oversample_v: 4, - ..FontConfig::default() - }), - }, - //FontSource::TtfData { - // data: include_bytes!("../../../resources/mplus-1p-regular.ttf"), - // size_pixels: font_size, - // config: Some(FontConfig { - // // Oversampling font helps improve text rendering at - // // expense of larger font atlas texture. - // oversample_h: 4, - // oversample_v: 4, - // // Range of glyphs to rasterize - // glyph_ranges: FontGlyphRanges::japanese(), - // ..FontConfig::default() - // }), - //}, - ]); - - let renderer = Renderer::init(&mut imgui, &display).expect("Failed to initialize renderer"); - - System { - event_loop, - display, - imgui, - platform, - renderer, - font_size, - } -} - -impl System { - pub fn main_loop(self, mut run_ui: F) { - let System { - event_loop, - display, - mut imgui, - mut platform, - mut renderer, - .. - } = self; - let mut last_frame = Instant::now(); - - event_loop.run(move |event, _, control_flow| match event { - Event::NewEvents(_) => { - let now = Instant::now(); - imgui.io_mut().update_delta_time(now - last_frame); - last_frame = now; - } - Event::MainEventsCleared => { - let gl_window = display.gl_window(); - platform - .prepare_frame(imgui.io_mut(), gl_window.window()) - .expect("Failed to prepare frame"); - gl_window.window().request_redraw(); - } - Event::RedrawRequested(_) => { - let ui = imgui.frame(); - - let mut run = true; - run_ui(&mut run, ui); - if !run { - *control_flow = ControlFlow::Exit; - } - - let gl_window = display.gl_window(); - let mut target = display.draw(); - target.clear_color_srgb(1.0, 1.0, 1.0, 1.0); - platform.prepare_render(ui, gl_window.window()); - let draw_data = imgui.render(); - renderer - .render(&mut target, draw_data) - .expect("Rendering failed"); - target.finish().expect("Failed to swap buffers"); - } - Event::WindowEvent { - event: WindowEvent::CloseRequested, - .. - } => *control_flow = ControlFlow::Exit, - event => { - let gl_window = display.gl_window(); - platform.handle_event(imgui.io_mut(), gl_window.window(), &event); - } - }) - } -} diff --git a/crates/programs/aichatbot-sidecar/src/gui/launch_imgui.rs b/crates/programs/aichatbot-sidecar/src/gui/launch_imgui.rs deleted file mode 100644 index 880952bb4e..0000000000 --- a/crates/programs/aichatbot-sidecar/src/gui/launch_imgui.rs +++ /dev/null @@ -1,31 +0,0 @@ -use imgui::*; -use crate::gui::imgui_support::init; - -pub fn launch_imgui() { - - let system = init(file!()); - - let mut value = 0; - let choices = ["test test this is 1", "test test this is 2"]; - - system.main_loop(move |_, ui| { - ui.window("Hello world") - .size([300.0, 110.0], Condition::FirstUseEver) - .build(|| { - ui.text_wrapped("Hello world!"); - ui.text_wrapped("こんにちは世界!"); - if ui.button(choices[value]) { - value += 1; - value %= 2; - } - - ui.button("This...is...imgui-rs!"); - ui.separator(); - let mouse_pos = ui.io().mouse_pos; - ui.text(format!( - "Mouse Position: ({:.1},{:.1})", - mouse_pos[0], mouse_pos[1] - )); - }); - }); -} \ No newline at end of file diff --git a/crates/programs/aichatbot-sidecar/src/gui/mod.rs b/crates/programs/aichatbot-sidecar/src/gui/mod.rs index f7cbba04ae..536f4bcab1 100644 --- a/crates/programs/aichatbot-sidecar/src/gui/mod.rs +++ b/crates/programs/aichatbot-sidecar/src/gui/mod.rs @@ -1,4 +1,2 @@ pub mod gui; -pub mod launch_gui; -pub mod imgui_support; -pub mod launch_imgui; \ No newline at end of file +pub mod launch_gui; \ No newline at end of file