Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions zaplib/components/src/arrow_pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ impl ArrowPointerDirection {
}
}

#[derive(Clone, Copy)]
pub struct ArrowPointerIns {
pub base: QuadIns,
pub color: Vec4,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/components/src/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use zaplib::*;

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct BackgroundIns {
quad: QuadIns,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/components/src/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub enum ButtonEvent {
Up,
}

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct BgIns {
base: QuadIns,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/components/src/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ impl Chart {
&points,
dataset.point_background_color,
dataset.point_radius * current_dpi,
dataset.point_style.clone(),
dataset.point_style,
);
self.areas.push(area);
}
Expand Down
2 changes: 1 addition & 1 deletion zaplib/components/src/checkbox.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use zaplib::*;

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct CheckboxIns {
base: QuadIns,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/components/src/drawlines3d.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use zaplib::*;

#[repr(C)]
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub struct DrawLines3dInstance {
/// Starting point for the previous line segment. We use this to compute
/// the corner between the previous line segment and the current one.
Expand Down
4 changes: 2 additions & 2 deletions zaplib/components/src/drawpoints3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static SHADER: Shader = Shader {
};

#[repr(C)]
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub struct DrawPoints3dInstance {
pub position: Vec3,
pub color: Vec3,
Expand All @@ -80,7 +80,7 @@ struct DrawPoints3dUniforms {
vertex_transform: Mat4,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub enum DrawPoints3dStyle {
Quad,
Circle,
Expand Down
4 changes: 2 additions & 2 deletions zaplib/components/src/floatslider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static KNOB_SHADER: Shader = Shader {
..Shader::DEFAULT
};

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct FloatSliderIns {
base: QuadIns,
Expand Down Expand Up @@ -106,7 +106,7 @@ const DEFAULT_BACKGROUND_RANGES: &[FloatSliderBackgroundRange] = &[FloatSliderBa
height_pixels: 8.,
}];

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct FloatSliderBackgroundRangeIns {
base: QuadIns,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/components/src/foldcaption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl FoldOpenState {
}
}

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct FoldCaptionIns {
base: QuadIns,
Expand Down
1 change: 1 addition & 0 deletions zaplib/components/src/geometry3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::f32::consts::PI;
use zaplib::*;

/// Represents a single vertex used in 3d objects.
#[derive(Clone, Copy)]
#[repr(C)]
pub struct Geometry3d {
/// Vertex position.
Expand Down
2 changes: 1 addition & 1 deletion zaplib/components/src/internal/desktopbutton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl DesktopButtonType {
}
}

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct DesktopButtonIns {
base: QuadIns,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/components/src/internal/scrollbar.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{axis::*, ScrollBarConfig};
use zaplib::*;

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct ScrollBarIns {
base: QuadIns,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/components/src/internal/tabclose.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::button::*;
use zaplib::*;

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct TabCloseIns {
base: QuadIns,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/components/src/scrollshadow.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use zaplib::*;

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct ScrollShadowIns {
base: QuadIns,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/components/src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use zaplib::*;

use crate::{internal::tabclose::TabClose, ButtonEvent};

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct TabIns {
base: QuadIns,
Expand Down
8 changes: 4 additions & 4 deletions zaplib/components/src/texteditor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static SHADER_MESSAGE_MARKER: Shader = Shader {
/// drawn as the background by default. You pass in your own [`Shader`].
///
/// Currently only used within [`TextEditor`].
#[derive(Clone)]
#[derive(Clone, Copy)]
#[repr(C)]
struct ColorBackgroundIns {
quad: QuadIns,
Expand All @@ -189,7 +189,7 @@ impl ColorBackground {
}
}

#[derive(Clone)]
#[derive(Clone, Copy)]
#[repr(C)]
struct IndentLinesIns {
quad: QuadIns,
Expand Down Expand Up @@ -225,7 +225,7 @@ impl IndentLines {
}
}

#[derive(Clone)]
#[derive(Clone, Copy)]
#[repr(C)]
pub struct CursorIns {
base: QuadIns,
Expand Down Expand Up @@ -258,7 +258,7 @@ impl Cursor {
}
}

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
pub struct SelectionIns {
base: QuadIns,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/docs/src/basic_api_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Some Rust functions, particularly around IO, don't work in WebAssembly out-of-th
| [`println!`](https://doc.rust-lang.org/std/macro.println.html) | [`log!`](/target/doc/zaplib/macro.log.html) | Logs to the console (with line number). |
| [`thread`](https://doc.rust-lang.org/std/thread/) | [`universal_thread`](/target/doc/zaplib/universal_thread/index.html) | <ul><li><code><a href="/target/doc/zaplib/universal_thread/fn.spawn.html">spawn</a></code> (without <code><a href="https://doc.rust-lang.org/std/thread/struct.JoinHandle.html">JoinHandle</a></code>)</li><li><code><a href="/target/doc/zaplib/universal_thread/fn.sleep.html">sleep</a></code></li><li>We recommend using a thread pool, e.g. the <a href="https://docs.rs/rayon/latest/rayon/struct.ThreadPoolBuilder.html#method.spawn_handler">rayon's <code>ThreadPoolBuilder</code></a>.</li></ul> |
| [`Instant`](https://doc.rust-lang.org/std/time/struct.Instant.html) | [`UniversalInstant`](/target/doc/zaplib/universal_instant/struct.UniversalInstant.html) | `elapsed, now, duration_since, checked_add, checked_sub, +, -, +=, -=` |
| [`File`](https://doc.rust-lang.org/std/thread/) | [`UniversalFile`](/target/doc/zaplib/universal_file/struct.UniversalFile.html) | <ul><li><code><a href="/target/doc/zaplib/universal_file/struct.UniversalFile.html#method.open">open</a></code> (on WebAssembly this blocks until the whole file is loaded in memory)</li><li><code><a href="/target/doc/zaplib/universal_file/struct.UniversalFile.html#method.open_url">open_url</a></code> (non-standard; load an absolute URL)</li><li><code><a href="/target/doc/zaplib/universal_file/struct.UniversalFile.html#method.clone">clone</a></code> (cheap; clones just a handle to the data; doesn't preserve cursor)</li><li><code><a href="https://doc.rust-lang.org/std/io/trait.Read.html">std::io::Read</a></code></li><li><code><a href="https://doc.rust-lang.org/std/io/trait.Seek.html">std::io::Seek</a></code></li><li><code><a href="/target/doc/zaplib/read_seek/trait.ReadSeek.html">ReadSeek</a></code> (non-standard; convenient trait for <code>Read + Seek</code>)</li></ul> |
| [`File`](https://doc.rust-lang.org/stable/std/fs/struct.File.html) | [`UniversalFile`](/target/doc/zaplib/universal_file/struct.UniversalFile.html) | <ul><li><code><a href="/target/doc/zaplib/universal_file/struct.UniversalFile.html#method.open">open</a></code> (on WebAssembly this blocks until the whole file is loaded in memory)</li><li><code><a href="/target/doc/zaplib/universal_file/struct.UniversalFile.html#method.open_url">open_url</a></code> (non-standard; load an absolute URL)</li><li><code><a href="/target/doc/zaplib/universal_file/struct.UniversalFile.html#method.clone">clone</a></code> (cheap; clones just a handle to the data; doesn't preserve cursor)</li><li><code><a href="https://doc.rust-lang.org/std/io/trait.Read.html">std::io::Read</a></code></li><li><code><a href="https://doc.rust-lang.org/std/io/trait.Seek.html">std::io::Seek</a></code></li><li><code><a href="/target/doc/zaplib/read_seek/trait.ReadSeek.html">ReadSeek</a></code> (non-standard; convenient trait for <code>Read + Seek</code>)</li></ul> |
| non-standard | [`universal_http_stream`](/target/doc/zaplib/universal_http_stream/index.html) | <ul><li><code><a href="/target/doc/zaplib/universal_http_stream/fn.request.html">request</a></code> (returns data as it comes in; useful for large files)</li><li><code><a href="https://doc.rust-lang.org/std/io/trait.Read.html">std::io::Read</a></code></li></ul> |
| non-standard | [`universal_rand`](/target/doc/zaplib/universal_rand/index.html) | [`random_128`](/target/doc/zaplib/universal_rand/fn.random_128.html) |

Expand Down
4 changes: 2 additions & 2 deletions zaplib/docs/src/tutorial_2d_rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Define a `SHADER` object:
Define the struct to pass the color into the shader as an instance variable:

```rust,noplayground
#[derive(Clone)]
#[derive(Clone, Copy)]
#[repr(C)]
struct RectIns {
color: Vec4,
Expand Down Expand Up @@ -90,7 +90,7 @@ Now let's modify our example to draw 2 bordered rectangles of the given sizes on
Modify `RectIns` to include the top-left position of rectangle and its size:

```rust,noplayground
#[derive(Clone)]
#[derive(Clone, Copy)]
#[repr(C)]
struct RectIns {
color: Vec4,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/examples/example_bigedit/src/codeicon.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use zaplib::*;

#[derive(Clone)]
#[derive(Clone, Copy)]
#[repr(C)]
pub struct CodeIconIns {
base: QuadIns,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/examples/example_bigedit/src/colorpicker.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use zaplib::*;

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct ColorPickerIns {
base: QuadIns,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/examples/example_bigedit/src/filetree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::listanims::*;
use zaplib::*;
use zaplib_components::*;

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct FileTreeFillerIns {
base: QuadIns,
Expand Down
6 changes: 3 additions & 3 deletions zaplib/examples/example_lightning/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use zaplib_components::*;
mod mprstokenizer;
use mprstokenizer::*;

#[derive(Clone, Default)]
#[derive(Clone, Copy, Default)]
#[repr(C)]
struct ShaderQuadIns {
base: QuadIns,
Expand Down Expand Up @@ -264,7 +264,7 @@ impl LogoApp {
self.quad.knobs_mirror[0] = vec2(1. - self.quad.knobs[0].x, self.quad.knobs[2].y);
self.quad.knobs_mirror[2] = vec2(1. - self.quad.knobs[2].x, self.quad.knobs[0].y);
self.quad.time = ((cx.last_event_time / ANIMATION_LENGTH) % 1.0) as f32;
*self.quad_area.get_first_mut(cx) = self.quad.clone();
*self.quad_area.get_first_mut(cx) = self.quad;
}

fn draw_shader(&mut self, cx: &mut Cx) {
Expand All @@ -285,7 +285,7 @@ impl LogoApp {
cx.end_padding_box();
}
self.quad.base = QuadIns::from_rect(cx.get_box_rect()).with_draw_depth(1.0);
self.quad_area = cx.add_instances(&SHADER, &[self.quad.clone()]);
self.quad_area = cx.add_instances(&SHADER, &[self.quad]);
self.update_shader(cx);
}

Expand Down
4 changes: 2 additions & 2 deletions zaplib/examples/example_shader/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use zaplib::*;
use zaplib_components::*;

#[derive(Clone)]
#[derive(Clone, Copy)]
#[repr(C)]
struct ShaderQuadIns {
base: QuadIns,
Expand Down Expand Up @@ -255,7 +255,7 @@ impl ShaderEditor {
cx.move_draw_pos(cx.get_width_left() - quad_size, 0.);
self.quad.base = QuadIns::from_rect(Rect { pos: cx.get_draw_pos(), size: vec2(quad_size, quad_size) });

self.quad_area = cx.add_instances(&SHADER, &[self.quad.clone()]);
self.quad_area = cx.add_instances(&SHADER, &[self.quad]);

cx.end_row();
self.main_view.end_view(cx);
Expand Down
2 changes: 1 addition & 1 deletion zaplib/examples/test_many_quads/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static SHADER: Shader = Shader {
..Shader::DEFAULT
};

#[derive(Clone)]
#[derive(Clone, Copy)]
#[repr(C)]
struct CounterQuad {
quad: QuadIns,
Expand Down
2 changes: 1 addition & 1 deletion zaplib/examples/test_multithread/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::time::Duration;

use zaplib::*;

#[derive(Clone)]
#[derive(Clone, Copy)]
#[repr(C)]
struct ColorQuad {
base: QuadIns,
Expand Down
4 changes: 2 additions & 2 deletions zaplib/examples/test_shader_2d_primitives/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ static MAIN_SHADER: Shader = Shader {
..Shader::DEFAULT
};

#[derive(Clone)]
#[derive(Clone, Copy)]
#[repr(C)]
struct PrimitiveInsProps {
primitive_type: f32,
style: f32,
}

#[derive(Clone)]
#[derive(Clone, Copy)]
#[repr(C)]
struct PrimitiveIns {
base: QuadIns,
Expand Down
1 change: 1 addition & 0 deletions zaplib/examples/tutorial_2d_rendering/step1/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use zaplib::*;

#[derive(Clone, Copy)]
#[repr(C)]
struct RectIns {
color: Vec4,
Expand Down
1 change: 1 addition & 0 deletions zaplib/examples/tutorial_2d_rendering/step2/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use zaplib::*;

#[derive(Clone, Copy)]
#[repr(C)]
struct RectIns {
color: Vec4,
Expand Down
1 change: 1 addition & 0 deletions zaplib/examples/tutorial_2d_rendering/step3/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use zaplib::*;

#[derive(Clone, Copy)]
#[repr(C)]
struct RectIns {
quad: QuadIns,
Expand Down
2 changes: 2 additions & 0 deletions zaplib/examples/tutorial_3d_rendering/step3/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ use zaplib::{
};
use zaplib_components::*;

#[derive(Clone, Copy)]
#[repr(C)]
struct Vertex {
position: Vec3,
normal: Vec3,
}

#[derive(Clone, Copy)]
#[repr(C)]
struct Instance {
offset: f32,
Expand Down
3 changes: 3 additions & 0 deletions zaplib/main/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ repository = "https://github.com/Zaplib/zaplib"
readme = "README.md"
description = "⚡ Zaplib is a fast, cross-platform (web+native), GPU-based application framework, written in Rust."

[lib]
doctest = false # They are mostly a pain to maintain for limited benefit. TODO(JP): Some day look into turning this back on?

[features]
disable-fonts=[]
tls=["ureq/tls"] # TLS (for HTTPS) doesn't currently work with cross-compilation, so we allow disabling it.
Expand Down
Loading