Skip to content

Commit

Permalink
make gain example depend on flicker and portlight directly
Browse files Browse the repository at this point in the history
  • Loading branch information
micahrj committed Jan 12, 2025
1 parent c40f17f commit bcea767
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion examples/gain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ formats = ["clap", "vst3"]

[dependencies]
coupler = { workspace = true, features = ["derive"] }
reflector = { git = "https://github.com/coupler-rs/reflector", rev = "eb40c59a71470077b4f58a26685796d1609ea8ed" }
portlight = { git = "https://github.com/coupler-rs/portlight", rev = "fff171e9f3f70a9604102e1e1877ad67d0c2badd" }
flicker = { git = "https://github.com/coupler-rs/flicker", rev = "80aca05cb6c7406f8c2a4ba66d85849dc344afaa" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
21 changes: 11 additions & 10 deletions examples/gain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use coupler::params::{ParamId, ParamValue};
use coupler::view::{ParentWindow, RawParent, Size, View};
use coupler::{buffers::*, bus::*, engine::*, events::*, host::*, params::*, plugin::*, view::*};

use reflector::graphics::Renderer;
use reflector::platform::{
use flicker::Renderer;

use portlight::{
App, AppMode, AppOptions, Bitmap, Cursor, MouseButton, Point, RawWindow, Response, Result,
Window, WindowContext, WindowOptions,
};
Expand Down Expand Up @@ -185,9 +186,9 @@ impl ViewState {
}
}

fn handle_event(&mut self, cx: &WindowContext, event: reflector::platform::Event) -> Response {
use reflector::graphics::{Affine, Color, Path, Point};
use reflector::platform::Event;
fn handle_event(&mut self, cx: &WindowContext, event: portlight::Event) -> Response {
use flicker::{Affine, Color, Path, Point};
use portlight::Event;

match event {
Event::Frame => {
Expand All @@ -197,9 +198,9 @@ impl ViewState {
let height = (size.height * scale) as usize;
self.framebuffer.resize(width * height, 0xFF000000);

let mut canvas = self.renderer.canvas(&mut self.framebuffer, width, height);
let mut target = self.renderer.attach(&mut self.framebuffer, width, height);

canvas.clear(Color::rgba(21, 26, 31, 255));
target.clear(Color::rgba(21, 26, 31, 255));

let transform = Affine::scale(scale as f32);

Expand All @@ -215,7 +216,7 @@ impl ViewState {
path.line_to(center + (radius - 4.0) * Point::new(angle2.cos(), angle2.sin()));
path.arc(radius - 4.0, angle2, angle1);
path.close();
canvas.fill_path(&path, transform, Color::rgba(240, 240, 245, 255));
target.fill_path(&path, transform, Color::rgba(240, 240, 245, 255));

let center = Point::new(128.0, 128.0);
let radius = 32.0;
Expand All @@ -227,7 +228,7 @@ impl ViewState {
path.line_to(center + (radius - 4.0) * Point::new(-angle.cos(), angle.sin()));
path.arc(radius - 4.0, angle + span, angle);
path.close();
canvas.stroke_path(&path, 1.0, transform, Color::rgba(240, 240, 245, 255));
target.stroke_path(&path, 1.0, transform, Color::rgba(240, 240, 245, 255));

cx.window().present(Bitmap::new(&self.framebuffer, width, height));
}
Expand Down Expand Up @@ -288,7 +289,7 @@ impl GainView {
let app = AppOptions::new().mode(AppMode::Guest).build()?;

let mut options = WindowOptions::new();
options.size(reflector::platform::Size::new(256.0, 256.0));
options.size(portlight::Size::new(256.0, 256.0));

let raw_parent = match parent.as_raw() {
RawParent::Win32(window) => RawWindow::Win32(window),
Expand Down

0 comments on commit bcea767

Please sign in to comment.