Comments (9)
( discussion in zulipchat )
from druid.
Also when I resize one of the windows, all of the other windows redraw... I really cannot figure out why...
from druid.
this is message log of these two windows when I resized one of them
from druid.
Are you using 0.7.0 or master
?
from druid.
master, iirc
from druid.
( more precisely, d062962)
from druid.
I confirmed this as a bug by combining the anim
and multiwin
examples.
from druid.
I tested this on Linux.
This version of the anim.rs example works fine on Linux. In all windows the animation can draw in parralel.
// Copyright 2019 The Druid Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! An example of an animating widget. It is just a widget that
//! requests an animation frame when it needs to, and draws the frame in the
//! `paint` method.
//! Once the animation is over it simply stops requesting animation frames.
//! Usually we would put the state in the `Data`, but for things like animation
//! we don't. This is because the animation state is not useful to know for the
//! rest of the app. If this is something the rest of your widgets should know
//! about, you could put it in the `data`.
// On Windows platform, don't show a console when opening the app.
#![windows_subsystem = "windows"]
use std::f64::consts::PI;
use druid::kurbo::{Circle, Line};
use druid::widget::prelude::*;
use druid::{AppLauncher, Color, LocalizedString, Point, Vec2, WidgetExt, WindowDesc};
use druid::widget::{Button, Flex};
struct AnimWidget {
t: f64,
}
impl Widget<()> for AnimWidget {
fn event(&mut self, ctx: &mut EventCtx, event: &Event, _data: &mut (), _env: &Env) {
match event {
Event::MouseDown(_) => {
self.t = 0.0;
ctx.request_anim_frame();
}
Event::AnimFrame(interval) => {
ctx.request_paint();
self.t += (*interval as f64) * 1e-9;
if self.t < 6.0 {
ctx.request_anim_frame();
} else {
// We might have t>1.0 at the end of the animation,
// we want to make sure the line points up at the
// end of the animation.
self.t = 0.0;
}
}
_ => (),
}
}
fn lifecycle(&mut self, _ctx: &mut LifeCycleCtx, _event: &LifeCycle, _data: &(), _env: &Env) {}
fn update(&mut self, _ctx: &mut UpdateCtx, _old_data: &(), _data: &(), _env: &Env) {}
fn layout(
&mut self,
_layout_ctx: &mut LayoutCtx,
bc: &BoxConstraints,
_data: &(),
_env: &Env,
) -> Size {
bc.constrain((100.0, 100.0))
}
fn paint(&mut self, ctx: &mut PaintCtx, _data: &(), _env: &Env) {
let t = self.t;
let center = Point::new(50.0, 50.0);
ctx.paint_with_z_index(1, move |ctx| {
let ambit = center + 45.0 * Vec2::from_angle((0.75 + t) * 2.0 * PI);
ctx.stroke(Line::new(center, ambit), &Color::WHITE, 1.0);
});
ctx.fill(Circle::new(center, 50.0), &Color::BLACK);
}
}
fn create_win() -> WindowDesc<()> {
let root = Flex::row()
.with_child(AnimWidget { t: 0.0 })
.with_default_spacer()
.with_child(
Button::new("New Window")
.on_click(|ctx, _, _|ctx.new_window(create_win()))
);
WindowDesc::new(root).title(
LocalizedString::new("anim-demo-window-title")
.with_placeholder("You spin me right round..."),
)
}
pub fn main() {
AppLauncher::with_window(create_win())
.log_to_console()
.launch(())
.expect("launch failed");
}
from druid.
I tested this on Linux.
This version of the anim.rs example works fine on Linux. In all windows the animation can draw in parralel.
code...
tried on Windows 11, same problem
from druid.
Related Issues (20)
- Option::Unwrap on a None value layout.rs:228:34 HOT 3
- Selecting multiple files HOT 4
- OSX Tab change input field focus breaks rendering HOT 4
- Make it possible to build "standard" dialogs HOT 1
- Can't compile the program in Chapter 2 of druid book HOT 1
- Docs? HOT 2
- Broken links in the book.
- Window name is not null terminated in X11 HOT 3
- Build error of an empty project: `syn::Type` doesn't implement `Debug` HOT 7
- Issue building druid-derive on macos HOT 1
- Require widget to implement compute_max_intrinsic HOT 7
- App update upgrade features HOT 1
- do we stop to develop the project? HOT 1
- Read data from an other thread HOT 3
- Looks like the documentation is out of date HOT 1
- Opening another window within a Druid application.
- Dual monitor App invisible
- version `GLIBCXX_3.4.29' not found HOT 2
- assertion 'width >= -1' failed on NixOS/Sway HOT 1
- Prevent closing app with cross
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from druid.