Browse Source

Some minor fixes and additions

clip_rect
Emil Ernerfeldt 5 years ago
parent
commit
be8eb02b3f
  1. 1
      TODO.md
  2. 3
      build_and_run.sh
  3. 4
      emigui/src/layout.rs
  4. 8
      emigui/src/math.rs
  5. 2
      emigui/src/types.rs
  6. 2
      emigui/src/widgets.rs
  7. 4
      emigui_glium/src/painter.rs
  8. 2
      example_wasm/src/app.rs
  9. 2
      example_wasm/src/lib.rs

1
TODO.md

@ -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?
# Code
* Try it on iPhone
* Read TTF from browser?
* requestAnimationFrame

3
build_and_run.sh

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

4
emigui/src/layout.rs

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

8
emigui/src/math.rs

@ -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 {
fn add_assign(&mut self, rhs: Vec2) {
*self = Vec2 {

2
emigui/src/types.rs

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

2
emigui/src/widgets.rs

@ -247,7 +247,7 @@ impl Widget for RadioButton {
// ----------------------------------------------------------------------------
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,
max: f32,
id: Option<Id>,

4
emigui_glium/src/painter.rs

@ -10,7 +10,7 @@ pub struct Painter {
}
impl Painter {
pub fn new(facade: &glium::backend::Facade) -> Painter {
pub fn new(facade: &dyn glium::backend::Facade) -> Painter {
let program = program!(facade,
140 => {
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) {
return; // No change
}

2
example_wasm/src/app.rs

@ -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) {
gui.add(Slider::usize(value, 1, 1000));

2
example_wasm/src/lib.rs

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

Loading…
Cancel
Save