[refactor] minor code cleanup
This commit is contained in:
parent
48bad68257
commit
bf19eb2ec5
9 changed files with 16 additions and 35 deletions
|
@ -1,5 +1,3 @@
|
||||||
#![allow(unused_variables)] // TODO
|
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
|
|
@ -191,7 +191,7 @@ impl Context {
|
||||||
let paint_commands = self.drain_paint_lists();
|
let paint_commands = self.drain_paint_lists();
|
||||||
let num_primitives = paint_commands.len();
|
let num_primitives = paint_commands.len();
|
||||||
let paint_jobs =
|
let paint_jobs =
|
||||||
mesher::paint_commands_into_triangles(paint_options, self.fonts(), paint_commands);
|
tessellator::tessellate_paint_commands(paint_options, self.fonts(), paint_commands);
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut stats = PaintStats::default();
|
let mut stats = PaintStats::default();
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
// #![allow(dead_code, unused_variables)] // should be commented out
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::{color::*, containers::*, examples::FractalClock, widgets::*, *};
|
use crate::{color::*, containers::*, examples::FractalClock, widgets::*, *};
|
||||||
|
@ -37,10 +36,6 @@ impl ExampleApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn windows(&mut self, ctx: &Arc<Context>) {
|
pub fn windows(&mut self, ctx: &Arc<Context>) {
|
||||||
// TODO: Make it even simpler to show a window
|
|
||||||
|
|
||||||
// TODO: window manager for automatic positioning?
|
|
||||||
|
|
||||||
let ExampleApp {
|
let ExampleApp {
|
||||||
open_windows,
|
open_windows,
|
||||||
example_window,
|
example_window,
|
||||||
|
|
|
@ -8,8 +8,6 @@ const MAX_CLICK_DELAY: f64 = 0.3;
|
||||||
/// What the integration gives to the gui.
|
/// What the integration gives to the gui.
|
||||||
/// All coordinates in egui is in point/logical coordinates.
|
/// All coordinates in egui is in point/logical coordinates.
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize))]
|
|
||||||
#[cfg_attr(feature = "with_serde", serde(default))]
|
|
||||||
pub struct RawInput {
|
pub struct RawInput {
|
||||||
/// Is the button currently down?
|
/// Is the button currently down?
|
||||||
pub mouse_down: bool,
|
pub mouse_down: bool,
|
||||||
|
@ -154,8 +152,6 @@ impl Default for MouseInput {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize))]
|
|
||||||
#[cfg_attr(feature = "with_serde", serde(rename_all = "snake_case"))]
|
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
Copy,
|
Copy,
|
||||||
Cut,
|
Cut,
|
||||||
|
@ -168,8 +164,6 @@ pub enum Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize))]
|
|
||||||
#[cfg_attr(feature = "with_serde", serde(rename_all = "snake_case"))]
|
|
||||||
pub enum Key {
|
pub enum Key {
|
||||||
Alt,
|
Alt,
|
||||||
Backspace,
|
Backspace,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{math::*, style::Style};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
|
#[cfg_attr(feature = "with_serde", serde(rename_all = "snake_case"))]
|
||||||
pub enum Direction {
|
pub enum Direction {
|
||||||
Horizontal,
|
Horizontal,
|
||||||
Vertical,
|
Vertical,
|
||||||
|
@ -56,7 +56,7 @@ pub fn align_rect(rect: Rect, align: (Align, Align)) -> Rect {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
// #[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct Layout {
|
pub struct Layout {
|
||||||
/// Lay out things horizontally or vertically?
|
/// Lay out things horizontally or vertically?
|
||||||
dir: Direction,
|
dir: Direction,
|
||||||
|
|
|
@ -2,13 +2,13 @@ pub mod color;
|
||||||
pub mod command;
|
pub mod command;
|
||||||
pub mod font;
|
pub mod font;
|
||||||
pub mod fonts;
|
pub mod fonts;
|
||||||
pub mod mesher;
|
pub mod tessellator;
|
||||||
mod texture_atlas;
|
mod texture_atlas;
|
||||||
|
|
||||||
pub use {
|
pub use {
|
||||||
color::Color,
|
color::Color,
|
||||||
command::{LineStyle, PaintCmd},
|
command::{LineStyle, PaintCmd},
|
||||||
fonts::{FontDefinitions, Fonts, TextStyle},
|
fonts::{FontDefinitions, Fonts, TextStyle},
|
||||||
mesher::{PaintJobs, PaintOptions, Path, Triangles, Vertex},
|
tessellator::{PaintJobs, PaintOptions, Path, Triangles, Vertex},
|
||||||
texture_atlas::Texture,
|
texture_atlas::Texture,
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@ use super::{
|
||||||
|
|
||||||
/// TODO: rename
|
/// TODO: rename
|
||||||
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
// #[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub enum TextStyle {
|
pub enum TextStyle {
|
||||||
Body,
|
Body,
|
||||||
Button,
|
Button,
|
||||||
|
@ -22,7 +22,7 @@ pub enum TextStyle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
// #[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub enum FontFamily {
|
pub enum FontFamily {
|
||||||
Monospace,
|
Monospace,
|
||||||
VariableWidth,
|
VariableWidth,
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
// TODO: rename tessellator
|
|
||||||
|
|
||||||
#![allow(clippy::identity_op)]
|
|
||||||
|
|
||||||
/// Outputs render info in a format suitable for e.g. OpenGL.
|
/// Outputs render info in a format suitable for e.g. OpenGL.
|
||||||
use {
|
use {
|
||||||
super::{
|
super::{
|
||||||
|
@ -15,7 +11,6 @@ use {
|
||||||
const WHITE_UV: (u16, u16) = (1, 1);
|
const WHITE_UV: (u16, u16) = (1, 1);
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[derive(Clone, Copy, Debug, Default)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
|
||||||
pub struct Vertex {
|
pub struct Vertex {
|
||||||
/// Pixel coordinates
|
/// Pixel coordinates
|
||||||
pub pos: Pos2,
|
pub pos: Pos2,
|
||||||
|
@ -26,7 +21,6 @@ pub struct Vertex {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
|
||||||
pub struct Triangles {
|
pub struct Triangles {
|
||||||
/// Draw as triangles (i.e. the length is a multiple of three)
|
/// Draw as triangles (i.e. the length is a multiple of three)
|
||||||
pub indices: Vec<u32>,
|
pub indices: Vec<u32>,
|
||||||
|
@ -558,7 +552,7 @@ fn mul_color(color: Color, factor: f32) -> Color {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// `reused_path`: only used to reuse memory
|
/// `reused_path`: only used to reuse memory
|
||||||
pub fn paint_command_into_triangles(
|
pub fn tessellate_paint_command(
|
||||||
reused_path: &mut Path,
|
reused_path: &mut Path,
|
||||||
options: PaintOptions,
|
options: PaintOptions,
|
||||||
fonts: &Fonts,
|
fonts: &Fonts,
|
||||||
|
@ -675,7 +669,7 @@ pub fn paint_command_into_triangles(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Turns `PaintCmd`:s into sets of triangles
|
/// Turns `PaintCmd`:s into sets of triangles
|
||||||
pub fn paint_commands_into_triangles(
|
pub fn tessellate_paint_commands(
|
||||||
options: PaintOptions,
|
options: PaintOptions,
|
||||||
fonts: &Fonts,
|
fonts: &Fonts,
|
||||||
commands: Vec<(Rect, PaintCmd)>,
|
commands: Vec<(Rect, PaintCmd)>,
|
||||||
|
@ -691,12 +685,12 @@ pub fn paint_commands_into_triangles(
|
||||||
}
|
}
|
||||||
|
|
||||||
let out = &mut jobs.last_mut().unwrap().1;
|
let out = &mut jobs.last_mut().unwrap().1;
|
||||||
paint_command_into_triangles(&mut reused_path, options, fonts, cmd, out);
|
tessellate_paint_command(&mut reused_path, options, fonts, cmd, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.debug_paint_clip_rects {
|
if options.debug_paint_clip_rects {
|
||||||
for (clip_rect, triangles) in &mut jobs {
|
for (clip_rect, triangles) in &mut jobs {
|
||||||
paint_command_into_triangles(
|
tessellate_paint_command(
|
||||||
&mut reused_path,
|
&mut reused_path,
|
||||||
options,
|
options,
|
||||||
fonts,
|
fonts,
|
|
@ -5,7 +5,7 @@ use crate::{math::Rect, Context, Ui};
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Serialize))]
|
// #[cfg_attr(feature = "with_serde", derive(serde::Serialize))]
|
||||||
pub struct Output {
|
pub struct Output {
|
||||||
pub cursor_icon: CursorIcon,
|
pub cursor_icon: CursorIcon,
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ pub struct Output {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Serialize))]
|
// #[cfg_attr(feature = "with_serde", derive(serde::Serialize))]
|
||||||
#[cfg_attr(feature = "with_serde", serde(rename_all = "snake_case"))]
|
// #[cfg_attr(feature = "with_serde", serde(rename_all = "snake_case"))]
|
||||||
pub enum CursorIcon {
|
pub enum CursorIcon {
|
||||||
Default,
|
Default,
|
||||||
/// Pointing hand, used for e.g. web links
|
/// Pointing hand, used for e.g. web links
|
||||||
|
@ -44,7 +44,7 @@ impl Default for CursorIcon {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Serialize))]
|
// #[cfg_attr(feature = "with_serde", derive(serde::Serialize))]
|
||||||
pub struct InteractInfo {
|
pub struct InteractInfo {
|
||||||
/// The senses (click or drag) that the widget is interested in (if any).
|
/// The senses (click or drag) that the widget is interested in (if any).
|
||||||
pub sense: Sense,
|
pub sense: Sense,
|
||||||
|
@ -147,7 +147,7 @@ impl Into<InteractInfo> for GuiResponse {
|
||||||
|
|
||||||
/// What sort of interaction is a widget sensitive to?
|
/// What sort of interaction is a widget sensitive to?
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Serialize))]
|
// #[cfg_attr(feature = "with_serde", derive(serde::Serialize))]
|
||||||
pub struct Sense {
|
pub struct Sense {
|
||||||
/// buttons, sliders, windows ...
|
/// buttons, sliders, windows ...
|
||||||
pub click: bool,
|
pub click: bool,
|
||||||
|
|
Loading…
Reference in a new issue