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