summaryrefslogtreecommitdiffstats
path: root/glow
diff options
context:
space:
mode:
Diffstat (limited to 'glow')
-rw-r--r--glow/Cargo.toml15
-rw-r--r--glow/src/backend.rs9
-rw-r--r--glow/src/lib.rs2
-rw-r--r--glow/src/program.rs4
-rw-r--r--glow/src/settings.rs22
-rw-r--r--glow/src/shader/quad.vert5
-rw-r--r--glow/src/text.rs8
-rw-r--r--glow/src/widget.rs14
-rw-r--r--glow/src/widget/button.rs3
-rw-r--r--glow/src/widget/canvas.rs3
-rw-r--r--glow/src/widget/pane_grid.rs13
-rw-r--r--glow/src/widget/progress_bar.rs2
-rw-r--r--glow/src/widget/qr_code.rs2
-rw-r--r--glow/src/widget/slider.rs3
-rw-r--r--glow/src/widget/text_input.rs3
-rw-r--r--glow/src/widget/toggler.rs9
-rw-r--r--glow/src/widget/tooltip.rs6
17 files changed, 84 insertions, 39 deletions
diff --git a/glow/Cargo.toml b/glow/Cargo.toml
index 11ca80e2..e40b8ba8 100644
--- a/glow/Cargo.toml
+++ b/glow/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "iced_glow"
-version = "0.1.0"
+version = "0.2.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
description = "A glow renderer for iced"
@@ -9,25 +9,26 @@ repository = "https://github.com/hecrj/iced"
[features]
canvas = ["iced_graphics/canvas"]
+qr_code = ["iced_graphics/qr_code"]
default_system_font = ["iced_graphics/font-source"]
# Not supported yet!
image = []
svg = []
[dependencies]
-glow = "0.5"
-glow_glyph = "0.3"
+glow = "0.6"
+glow_glyph = "0.4"
glyph_brush = "0.7"
-euclid = "0.20"
-bytemuck = "1.2"
+euclid = "0.22"
+bytemuck = "1.4"
log = "0.4"
[dependencies.iced_native]
-version = "0.2"
+version = "0.4"
path = "../native"
[dependencies.iced_graphics]
-version = "0.1"
+version = "0.2"
path = "../graphics"
features = ["font-fallback", "font-icons", "opengl"]
diff --git a/glow/src/backend.rs b/glow/src/backend.rs
index e1685816..1680fc00 100644
--- a/glow/src/backend.rs
+++ b/glow/src/backend.rs
@@ -23,10 +23,13 @@ pub struct Backend {
impl Backend {
/// Creates a new [`Backend`].
- ///
- /// [`Backend`]: struct.Backend.html
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/lib.rs b/glow/src/lib.rs
index 5011da8e..98faf24c 100644
--- a/glow/src/lib.rs
+++ b/glow/src/lib.rs
@@ -1,5 +1,7 @@
//! A [`glow`] renderer for [`iced_native`].
//!
+//! ![The native path of the Iced ecosystem](https://github.com/hecrj/iced/blob/0525d76ff94e828b7b21634fa94a747022001c83/docs/graphs/native.png?raw=true)
+//!
//! [`glow`]: https://github.com/grovesNL/glow
//! [`iced_native`]: https://github.com/hecrj/iced/tree/master/native
#![deny(missing_docs)]
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 c2c605ef..f3dddfaf 100644
--- a/glow/src/settings.rs
+++ b/glow/src/settings.rs
@@ -1,9 +1,9 @@
//! Configure a renderer.
pub use iced_graphics::Antialiasing;
-/// The settings of a [`Renderer`].
+/// The settings of a [`Backend`].
///
-/// [`Renderer`]: ../struct.Renderer.html
+/// [`Backend`]: crate::Backend
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Settings {
/// The bytes of the font that will be used by default.
@@ -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/shader/quad.vert b/glow/src/shader/quad.vert
index d37b5c8d..82417856 100644
--- a/glow/src/shader/quad.vert
+++ b/glow/src/shader/quad.vert
@@ -29,6 +29,11 @@ void main() {
vec2 p_Pos = i_Pos * u_Scale;
vec2 p_Scale = i_Scale * u_Scale;
+ float i_BorderRadius = min(
+ i_BorderRadius,
+ min(i_Scale.x, i_Scale.y) / 2.0
+ );
+
mat4 i_Transform = mat4(
vec4(p_Scale.x + 1.0, 0.0, 0.0, 0.0),
vec4(0.0, p_Scale.y + 1.0, 0.0, 0.0),
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 0e33909d..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")))]
@@ -52,6 +58,14 @@ pub mod canvas;
#[doc(no_inline)]
pub use canvas::Canvas;
+#[cfg(feature = "qr_code")]
+#[cfg_attr(docsrs, doc(cfg(feature = "qr_code")))]
+pub mod qr_code;
+
+#[cfg(feature = "qr_code")]
+#[doc(no_inline)]
+pub use qr_code::QRCode;
+
pub use iced_native::{Image, Space};
/// A container that distributes its contents vertically.
diff --git a/glow/src/widget/button.rs b/glow/src/widget/button.rs
index fee7a7f8..fc729cd5 100644
--- a/glow/src/widget/button.rs
+++ b/glow/src/widget/button.rs
@@ -1,9 +1,6 @@
//! Allow your users to perform actions by pressing a button.
//!
//! A [`Button`] has some local [`State`].
-//!
-//! [`Button`]: type.Button.html
-//! [`State`]: struct.State.html
use crate::Renderer;
pub use iced_graphics::button::{Style, StyleSheet};
diff --git a/glow/src/widget/canvas.rs b/glow/src/widget/canvas.rs
index bef34857..399dd19c 100644
--- a/glow/src/widget/canvas.rs
+++ b/glow/src/widget/canvas.rs
@@ -3,7 +3,4 @@
//! A [`Canvas`] widget can be used to draw different kinds of 2D shapes in a
//! [`Frame`]. It can be used for animation, data visualization, game graphics,
//! and more!
-//!
-//! [`Canvas`]: struct.Canvas.html
-//! [`Frame`]: struct.Frame.html
pub use iced_graphics::canvas::*;
diff --git a/glow/src/widget/pane_grid.rs b/glow/src/widget/pane_grid.rs
index 3c47b562..fc36862c 100644
--- a/glow/src/widget/pane_grid.rs
+++ b/glow/src/widget/pane_grid.rs
@@ -6,13 +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.1/examples/pane_grid
-//! [`PaneGrid`]: type.PaneGrid.html
+//! [`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, Focus, KeyPressEvent, 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
@@ -24,13 +23,9 @@ pub use iced_native::pane_grid::{
pub type PaneGrid<'a, Message> = iced_native::PaneGrid<'a, Message, Renderer>;
/// The content of a [`Pane`].
-///
-/// [`Pane`]: struct.Pane.html
pub type Content<'a, Message> =
iced_native::pane_grid::Content<'a, Message, Renderer>;
/// The title bar of a [`Pane`].
-///
-/// [`Pane`]: struct.Pane.html
pub type TitleBar<'a, Message> =
iced_native::pane_grid::TitleBar<'a, Message, Renderer>;
diff --git a/glow/src/widget/progress_bar.rs b/glow/src/widget/progress_bar.rs
index a636a3a6..45a25d00 100644
--- a/glow/src/widget/progress_bar.rs
+++ b/glow/src/widget/progress_bar.rs
@@ -2,8 +2,6 @@
//!
//! A [`ProgressBar`] has a range of possible values and a current value,
//! as well as a length, height and style.
-//!
-//! [`ProgressBar`]: type.ProgressBar.html
use crate::Renderer;
pub use iced_graphics::progress_bar::{Style, StyleSheet};
diff --git a/glow/src/widget/qr_code.rs b/glow/src/widget/qr_code.rs
new file mode 100644
index 00000000..7b1c2408
--- /dev/null
+++ b/glow/src/widget/qr_code.rs
@@ -0,0 +1,2 @@
+//! Encode and display information in a QR code.
+pub use iced_graphics::qr_code::*;
diff --git a/glow/src/widget/slider.rs b/glow/src/widget/slider.rs
index 3a8c2595..9a269858 100644
--- a/glow/src/widget/slider.rs
+++ b/glow/src/widget/slider.rs
@@ -1,9 +1,6 @@
//! Display an interactive selector of a single value from a range of values.
//!
//! A [`Slider`] has some local [`State`].
-//!
-//! [`Slider`]: struct.Slider.html
-//! [`State`]: struct.State.html
use crate::Renderer;
pub use iced_graphics::slider::{Handle, HandleShape, Style, StyleSheet};
diff --git a/glow/src/widget/text_input.rs b/glow/src/widget/text_input.rs
index 1da3fbe6..db18b1cc 100644
--- a/glow/src/widget/text_input.rs
+++ b/glow/src/widget/text_input.rs
@@ -1,9 +1,6 @@
//! Display fields that can be filled with text.
//!
//! A [`TextInput`] has some local [`State`].
-//!
-//! [`TextInput`]: struct.TextInput.html
-//! [`State`]: struct.State.html
use crate::Renderer;
pub use iced_graphics::text_input::{Style, StyleSheet};
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;