organizing ezgui into subdirectories

This commit is contained in:
Dustin Carlino 2019-02-01 09:30:26 -08:00
parent 06b8c26716
commit e4b95c936b
15 changed files with 29 additions and 23 deletions

View File

@ -88,8 +88,8 @@
- undo the y inversion hacks at last!
- ezgui passes EventCtx and DrawCtx with appropriate things exposed.
- maybe move glyph ownership out of canvas entirely. dont need RefCell.
- need to pass around a NonDrawCtx very uniformly first for this to work
- canvas owning text-drawing is maybe a bit weird, at least API-wise
- organize into directories
- hide stuff inside the ctx's? canvas and prerender shouldnt even be known outside of crate
- generic World with quadtree should have actions on objects
- more speculative performance ideas

View File

@ -1,6 +1,5 @@
use crate::menu::{Menu, Position};
use crate::top_menu::TopMenu;
use crate::{Canvas, Event, InputResult, Key, ScreenPt, Text};
use crate::widgets::{Menu, Position};
use crate::{Canvas, Event, InputResult, Key, ScreenPt, Text, TopMenu};
use std::collections::{BTreeMap, HashMap, HashSet};
// As we check for user input, record the input and the thing that would happen. This will let us

View File

@ -4,16 +4,10 @@ mod drawing;
mod event;
mod event_ctx;
mod input;
mod log_scroller;
mod menu;
mod runner;
mod screen_geom;
mod screenshot;
mod scrolling_menu;
mod text;
mod text_box;
mod top_menu;
mod wizard;
mod widgets;
pub use crate::canvas::{Canvas, HorizontalAlignment, VerticalAlignment, BOTTOM_LEFT, CENTERED};
pub use crate::color::Color;
@ -21,14 +15,12 @@ pub use crate::drawing::GfxCtx;
pub use crate::event::{Event, Key};
pub use crate::event_ctx::{Drawable, EventCtx, Prerender};
pub use crate::input::{ModalMenu, UserInput};
pub use crate::log_scroller::LogScroller;
pub use crate::runner::{run, EventLoopMode, GUI};
pub use crate::screen_geom::ScreenPt;
pub use crate::scrolling_menu::ScrollingMenu;
pub use crate::text::Text;
pub use crate::text_box::TextBox;
pub use crate::top_menu::{Folder, TopMenu};
pub use crate::wizard::{Wizard, WrappedWizard};
pub use crate::widgets::{
Folder, LogScroller, ScrollingMenu, TextBox, TopMenu, Wizard, WrappedWizard,
};
pub struct ToggleableLayer {
layer_name: String,

View File

@ -1,6 +1,6 @@
use crate::input::{ContextMenu, ModalMenuState};
use crate::{
screenshot, text, Canvas, Event, EventCtx, GfxCtx, ModalMenu, Prerender, TopMenu, UserInput,
text, widgets, Canvas, Event, EventCtx, GfxCtx, ModalMenu, Prerender, TopMenu, UserInput,
};
use glium::glutin;
use glium_glyph::glyph_brush::rusttype::Font;
@ -162,11 +162,11 @@ pub fn run<T, G: GUI<T>, F: FnOnce(&mut Canvas, &Prerender) -> G>(
let program = glium::Program::new(
&display,
glium::program::ProgramCreationInput::SourceCode {
vertex_shader: include_str!("vertex.glsl"),
vertex_shader: include_str!("assets/vertex.glsl"),
tessellation_control_shader: None,
tessellation_evaluation_shader: None,
geometry_shader: None,
fragment_shader: include_str!("fragment.glsl"),
fragment_shader: include_str!("assets/fragment.glsl"),
transform_feedback_varyings: None,
// Without this, SRGB gets enabled and post-processes the color from the fragment
// shader.
@ -176,7 +176,7 @@ pub fn run<T, G: GUI<T>, F: FnOnce(&mut Canvas, &Prerender) -> G>(
)
.unwrap();
let dejavu: &[u8] = include_bytes!("DejaVuSans.ttf");
let dejavu: &[u8] = include_bytes!("assets/DejaVuSans.ttf");
let fonts = vec![Font::from_bytes(dejavu).unwrap()];
let vmetrics = fonts[0].v_metrics(Scale::uniform(text::FONT_SIZE));
// TODO This works for this font, but could be more paranoid with abs()
@ -225,7 +225,7 @@ fn loop_forever<T, G: GUI<T>>(
state = new_state;
wait_for_events = mode == EventLoopMode::InputOnly;
if let EventLoopMode::ScreenCaptureEverything { zoom, max_x, max_y } = mode {
state = screenshot::screenshot_everything(
state = widgets::screenshot_everything(
state, &display, &program, zoom, max_x, max_y,
);
}

15
ezgui/src/widgets/mod.rs Normal file
View File

@ -0,0 +1,15 @@
mod log_scroller;
mod menu;
mod screenshot;
mod scrolling_menu;
mod text_box;
mod top_menu;
mod wizard;
pub use self::log_scroller::LogScroller;
pub use self::menu::{Menu, Position};
pub(crate) use self::screenshot::screenshot_everything;
pub use self::scrolling_menu::ScrollingMenu;
pub use self::text_box::TextBox;
pub use self::top_menu::{Folder, TopMenu};
pub use self::wizard::{Wizard, WrappedWizard};

View File

@ -1,6 +1,6 @@
use crate::menu::{Menu, Position};
use crate::screen_geom::ScreenRectangle;
use crate::text;
use crate::widgets::{Menu, Position};
use crate::{Canvas, GfxCtx, InputResult, Key, ScreenPt, Text, UserInput};
use geom::{Polygon, Pt2D};
use std::collections::{HashMap, HashSet};

View File

@ -1,4 +1,4 @@
use crate::menu::{Menu, Position};
use crate::widgets::{Menu, Position};
use crate::{Canvas, GfxCtx, InputResult, Key, LogScroller, TextBox, UserInput};
use abstutil::Cloneable;
use log::warn;