Some minor fixes and additions

This commit is contained in:
Emil Ernerfeldt 2019-11-02 09:50:49 +01:00
parent 1d6bc3baba
commit be8eb02b3f
9 changed files with 21 additions and 7 deletions

View file

@ -3,7 +3,6 @@ We need to make it easy to make your own library using emigui_wasm.
Maybe we can use build.rs to generate needed stuff, e.g. index.hmtl? Maybe we can use build.rs to generate needed stuff, e.g. index.hmtl?
# Code # Code
* Try it on iPhone
* Read TTF from browser? * Read TTF from browser?
* requestAnimationFrame * requestAnimationFrame

View file

@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
set -eu set -eu
cargo check --all-features
cargo clippy
# ./build_wasm.sh # ./build_wasm.sh
# open "docs/index.html" # open "docs/index.html"

View file

@ -308,6 +308,10 @@ impl Region {
self.available_space.y self.available_space.y
} }
pub fn size(&self) -> Vec2 {
self.available_space
}
pub fn direction(&self) -> Direction { pub fn direction(&self) -> Direction {
self.dir self.dir
} }

View file

@ -40,6 +40,14 @@ impl Vec2 {
} }
} }
impl std::ops::Neg for Vec2 {
type Output = Vec2;
fn neg(self) -> Vec2 {
vec2(-self.x, -self.y)
}
}
impl std::ops::AddAssign for Vec2 { impl std::ops::AddAssign for Vec2 {
fn add_assign(&mut self, rhs: Vec2) { fn add_assign(&mut self, rhs: Vec2) {
*self = Vec2 { *self = Vec2 {

View file

@ -83,7 +83,7 @@ pub struct Outline {
pub color: Color, pub color: Color,
} }
#[derive(Clone, Debug, Serialize)] // TODO: copy #[derive(Clone, Debug, Serialize)]
#[serde(rename_all = "snake_case", tag = "kind")] #[serde(rename_all = "snake_case", tag = "kind")]
pub enum PaintCmd { pub enum PaintCmd {
Circle { Circle {

View file

@ -247,7 +247,7 @@ impl Widget for RadioButton {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
pub struct Slider<'a> { pub struct Slider<'a> {
get_set_value: Box<'a + FnMut(Option<f32>) -> f32>, get_set_value: Box<dyn 'a + FnMut(Option<f32>) -> f32>,
min: f32, min: f32,
max: f32, max: f32,
id: Option<Id>, id: Option<Id>,

View file

@ -10,7 +10,7 @@ pub struct Painter {
} }
impl Painter { impl Painter {
pub fn new(facade: &glium::backend::Facade) -> Painter { pub fn new(facade: &dyn glium::backend::Facade) -> Painter {
let program = program!(facade, let program = program!(facade,
140 => { 140 => {
vertex: " vertex: "
@ -127,7 +127,7 @@ impl Painter {
} }
} }
fn upload_texture(&mut self, facade: &glium::backend::Facade, texture: &emigui::Texture) { fn upload_texture(&mut self, facade: &dyn glium::backend::Facade, texture: &emigui::Texture) {
if self.current_texture_id == Some(texture.id) { if self.current_texture_id == Some(texture.id) {
return; // No change return; // No change
} }

View file

@ -1,4 +1,4 @@
use emigui::{label, math::*, types::*, widgets::*, Align, Region, TextStyle}; use emigui::{color::*, label, math::*, types::*, widgets::*, Align, Region, TextStyle};
pub fn show_value_gui(value: &mut usize, gui: &mut Region) { pub fn show_value_gui(value: &mut usize, gui: &mut Region) {
gui.add(Slider::usize(value, 1, 1000)); gui.add(Slider::usize(value, 1, 1000));

View file

@ -7,7 +7,7 @@ extern crate emigui;
extern crate emigui_wasm; extern crate emigui_wasm;
use { use {
emigui::{label, types::srgba, widgets::Label, Align, Emigui, RawInput}, emigui::{color::srgba, label, widgets::Label, Emigui, RawInput},
emigui_wasm::now_sec, emigui_wasm::now_sec,
}; };