Skip to content

Commit

Permalink
Merge pull request #5 from paper-plane-developers/fix/0.8.0/compile-e…
Browse files Browse the repository at this point in the history
…rrors

Fix/0.8.0/compile-errors
  • Loading branch information
marhkb authored Apr 20, 2024
2 parents 1326260 + 9e2bb51 commit 861cfa7
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "demo"
version = "0.8.0"
version = "0.8.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
3 changes: 1 addition & 2 deletions demo/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
mod window;
use window::SpoilerWindow;

use adw::prelude::*;
use window::SpoilerWindow;

fn main() {
ori::init();
Expand Down
4 changes: 2 additions & 2 deletions demo/src/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ mod spoiler;

use adw::prelude::*;
use adw::subclass::prelude::*;
use gtk::{gio, glib};
use gtk::gio;
use gtk::glib;

mod imp {

use super::*;

#[derive(Debug, Default, gtk::CompositeTemplate)]
Expand Down
3 changes: 2 additions & 1 deletion demo/src/window/spoiler/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use adw::prelude::*;
use adw::subclass::prelude::*;
use glib::clone;
use gtk::{gdk, glib};
use gtk::gdk;
use gtk::glib;

mod imp {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion origami/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "origami"
version = "0.8.0"
version = "0.8.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
5 changes: 3 additions & 2 deletions origami/src/loading_indicator/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use gtk::glib;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use std::cell::Cell;

use gtk::graphene;

mod imp {
use super::*;
use gtk::graphene;
use std::cell::Cell;

#[derive(Debug, Default, glib::Properties)]
#[properties(wrapper_type = super::LoadingIndicator)]
Expand Down
6 changes: 4 additions & 2 deletions origami/src/shimmer_effect/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use adw::prelude::*;
use adw::subclass::prelude::*;
use glib::clone;
use gtk::{glib, graphene, gsk};
use gtk::glib;
use gtk::graphene;
use gtk::gsk;
use std::cell::Cell;

const GRADIENT_WIDTH: f32 = 256.0;
const GRADIENT_PIXELS_PER_SEC: f32 = 100.0;

mod imp {
use super::*;
use std::cell::Cell;

#[derive(Default, glib::Properties)]
#[properties(wrapper_type = super::ShimmerEffect)]
Expand Down
34 changes: 21 additions & 13 deletions origami/src/spoiler_overlay/mod.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
use std::cell::Cell;
use std::cell::OnceCell;
use std::cell::RefCell;
use std::sync::OnceLock;

use adw::prelude::*;
use adw::subclass::prelude::*;
use glib::clone;
use gtk::glib::once_cell::sync::Lazy;
use gtk::{gdk, gio, glib, graphene, gsk};

static PARTICLE_TEXTURE: Lazy<gdk::Texture> = Lazy::new(|| {
let bytes = glib::Bytes::from_static(include_bytes!("turbulence_2x.png"));
gdk::Texture::from_bytes(&bytes).unwrap()
});
use gtk::gdk;
use gtk::gio;
use gtk::glib;
use gtk::graphene;
use gtk::gsk;

fn particle_texture() -> &'static gdk::Texture {
static PARTICLE_TEXTURE: OnceLock<gdk::Texture> = OnceLock::new();
PARTICLE_TEXTURE.get_or_init(|| {
let bytes = glib::Bytes::from_static(include_bytes!("turbulence_2x.png"));
gdk::Texture::from_bytes(&bytes).unwrap()
})
}

const BLUR_SHADER: &[u8] = include_bytes!("blur_shader.frag");

mod imp {
use gtk::glib::once_cell::unsync::OnceCell;

use super::*;
use std::cell::{Cell, RefCell};

#[derive(Default, glib::Properties)]
#[properties(wrapper_type = super::SpoilerOverlay)]
Expand Down Expand Up @@ -202,7 +210,7 @@ mod imp {
fn ensure_shader(&self) {
let widget = self.obj();
if self.shader.borrow().is_none() {
let renderer = widget.native().unwrap().renderer();
let renderer = widget.native().unwrap().renderer().unwrap();

let shader = gsk::GLShader::from_bytes(&BLUR_SHADER.into());
match shader.compile(&renderer) {
Expand Down Expand Up @@ -240,7 +248,7 @@ mod imp {
snapshot.gl_shader_pop_texture();
snapshot.pop();

let renderer = self.obj().native().unwrap().renderer();
let renderer = self.obj().native().unwrap().renderer().unwrap();

let Some(node) = snapshot.to_node() else {
return; // nothing to render
Expand All @@ -265,7 +273,7 @@ mod imp {
time: f32,
speed_modifiers: &[(f32, f32)],
) {
let texture = &*PARTICLE_TEXTURE;
let texture = particle_texture();

let texture_bounds = {
// Texture have 2x size, so we divide it to scale correctly;
Expand Down

0 comments on commit 861cfa7

Please sign in to comment.