diff options
Diffstat (limited to 'glow/src')
| -rw-r--r-- | glow/src/backend.rs | 7 | ||||
| -rw-r--r-- | glow/src/program.rs | 4 | ||||
| -rw-r--r-- | glow/src/settings.rs | 18 | ||||
| -rw-r--r-- | glow/src/text.rs | 8 | ||||
| -rw-r--r-- | glow/src/widget.rs | 6 | ||||
| -rw-r--r-- | glow/src/widget/pane_grid.rs | 8 | ||||
| -rw-r--r-- | glow/src/widget/toggler.rs | 9 | ||||
| -rw-r--r-- | glow/src/widget/tooltip.rs | 6 | 
8 files changed, 57 insertions, 9 deletions
| diff --git a/glow/src/backend.rs b/glow/src/backend.rs index 92bb993e..1680fc00 100644 --- a/glow/src/backend.rs +++ b/glow/src/backend.rs @@ -24,7 +24,12 @@ pub struct Backend {  impl Backend {      /// Creates a new [`Backend`].      pub fn new(gl: &glow::Context, settings: Settings) -> Self { -        let text_pipeline = text::Pipeline::new(gl, settings.default_font); +        let text_pipeline = text::Pipeline::new( +            gl, +            settings.default_font, +            settings.text_multithreading, +        ); +          let quad_pipeline = quad::Pipeline::new(gl);          let triangle_pipeline = triangle::Pipeline::new(gl); diff --git a/glow/src/program.rs b/glow/src/program.rs index 489a194f..601f9ce6 100644 --- a/glow/src/program.rs +++ b/glow/src/program.rs @@ -17,7 +17,7 @@ pub unsafe fn create(          gl.compile_shader(shader);          if !gl.get_shader_compile_status(shader) { -            panic!(gl.get_shader_info_log(shader)); +            panic!("{}", gl.get_shader_info_log(shader));          }          gl.attach_shader(program, shader); @@ -27,7 +27,7 @@ pub unsafe fn create(      gl.link_program(program);      if !gl.get_program_link_status(program) { -        panic!(gl.get_program_info_log(program)); +        panic!("{}", gl.get_program_info_log(program));      }      for shader in shaders { diff --git a/glow/src/settings.rs b/glow/src/settings.rs index 524d91a9..f3dddfaf 100644 --- a/glow/src/settings.rs +++ b/glow/src/settings.rs @@ -16,7 +16,15 @@ pub struct Settings {      /// By default, it will be set to 20.      pub default_text_size: u16, +    /// If enabled, spread text workload in multiple threads when multiple cores +    /// are available. +    /// +    /// By default, it is disabled. +    pub text_multithreading: bool, +      /// The antialiasing strategy that will be used for triangle primitives. +    /// +    /// By default, it is `None`.      pub antialiasing: Option<Antialiasing>,  } @@ -25,7 +33,17 @@ impl Default for Settings {          Settings {              default_font: None,              default_text_size: 20, +            text_multithreading: false,              antialiasing: None,          }      }  } + +impl Settings { +    /// Creates new [`Settings`] using environment configuration. +    /// +    /// Currently, this is equivalent to calling [`Settings::default`]. +    pub fn from_env() -> Self { +        Self::default() +    } +} diff --git a/glow/src/text.rs b/glow/src/text.rs index 925c7287..a4c39dfe 100644 --- a/glow/src/text.rs +++ b/glow/src/text.rs @@ -11,7 +11,11 @@ pub struct Pipeline {  }  impl Pipeline { -    pub fn new(gl: &glow::Context, default_font: Option<&[u8]>) -> Self { +    pub fn new( +        gl: &glow::Context, +        default_font: Option<&[u8]>, +        multithreading: bool, +    ) -> Self {          let default_font = default_font.map(|slice| slice.to_vec());          // TODO: Font customization @@ -41,7 +45,7 @@ impl Pipeline {          let draw_brush =              glow_glyph::GlyphBrushBuilder::using_font(font.clone())                  .initial_cache_size((2048, 2048)) -                .draw_cache_multithread(false) // TODO: Expose as a configuration flag +                .draw_cache_multithread(multithreading)                  .build(&gl);          let measure_brush = diff --git a/glow/src/widget.rs b/glow/src/widget.rs index b5c84c56..a77511e8 100644 --- a/glow/src/widget.rs +++ b/glow/src/widget.rs @@ -20,6 +20,8 @@ pub mod rule;  pub mod scrollable;  pub mod slider;  pub mod text_input; +pub mod toggler; +pub mod tooltip;  #[doc(no_inline)]  pub use button::Button; @@ -43,6 +45,10 @@ pub use scrollable::Scrollable;  pub use slider::Slider;  #[doc(no_inline)]  pub use text_input::TextInput; +#[doc(no_inline)] +pub use toggler::Toggler; +#[doc(no_inline)] +pub use tooltip::Tooltip;  #[cfg(feature = "canvas")]  #[cfg_attr(docsrs, doc(cfg(feature = "canvas")))] diff --git a/glow/src/widget/pane_grid.rs b/glow/src/widget/pane_grid.rs index c26dde48..fc36862c 100644 --- a/glow/src/widget/pane_grid.rs +++ b/glow/src/widget/pane_grid.rs @@ -6,12 +6,12 @@  //! The [`pane_grid` example] showcases how to use a [`PaneGrid`] with resizing,  //! drag and drop, and hotkey support.  //! -//! [`pane_grid` example]: https://github.com/hecrj/iced/tree/0.2/examples/pane_grid +//! [`pane_grid` example]: https://github.com/hecrj/iced/tree/0.3/examples/pane_grid  use crate::Renderer; -pub use iced_native::pane_grid::{ -    Axis, Configuration, Direction, DragEvent, Node, Pane, ResizeEvent, Split, -    State, +pub use iced_graphics::pane_grid::{ +    Axis, Configuration, Direction, DragEvent, Line, Node, Pane, ResizeEvent, +    Split, State, StyleSheet,  };  /// A collection of panes distributed using either vertical or horizontal splits diff --git a/glow/src/widget/toggler.rs b/glow/src/widget/toggler.rs new file mode 100644 index 00000000..1cd8711b --- /dev/null +++ b/glow/src/widget/toggler.rs @@ -0,0 +1,9 @@ +//! Show toggle controls using togglers. +use crate::Renderer; + +pub use iced_graphics::toggler::{Style, StyleSheet}; + +/// A toggler that can be toggled. +/// +/// This is an alias of an `iced_native` checkbox with an `iced_wgpu::Renderer`. +pub type Toggler<Message> = iced_native::Toggler<Message, Renderer>; diff --git a/glow/src/widget/tooltip.rs b/glow/src/widget/tooltip.rs new file mode 100644 index 00000000..89ab3a15 --- /dev/null +++ b/glow/src/widget/tooltip.rs @@ -0,0 +1,6 @@ +//! Display a widget over another. +/// A widget allowing the selection of a single value from a list of options. +pub type Tooltip<'a, Message> = +    iced_native::Tooltip<'a, Message, crate::Renderer>; + +pub use iced_native::tooltip::Position; | 
