Skip to content

Commit

Permalink
stabilising the top,right,bottom and left props for most elements. Ad…
Browse files Browse the repository at this point in the history
…ded image as an element not finished though.
  • Loading branch information
fasihrana committed Nov 9, 2018
1 parent 8c7f2c3 commit 5cee39a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "skryn"
version = "0.0.1"
version = "0.0.2"
authors = ["Fasih Rana <fasih.rana@apparicion.com>"]
exclude = [
".idea",
Expand Down
42 changes: 42 additions & 0 deletions src/elements/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use std::io;
use std::io::prelude::*;
use std::fs::File;

#[derive(Clone, Debug, PartialEq)]
pub enum ImagePath{
Local(String),
URL(String),
}

#[derive(Clone, Debug, PartialEq)]
pub struct Image{
path: ImagePath,
bytes: Vec<u8>,
ext_id: u64,
}

impl Image {
pub fn load(path: ImagePath) -> Option<Image> {
let mut ret = None;
if let ImagePath::Local(_s) = path.clone() {
let mut f = File::open(&_s[0..]);
if let Ok(mut c) = f {
let l = c.metadata().unwrap().len();
let mut bytes :Vec<u8> = Vec::new();
bytes.resize(l as usize, 0);
let _r = c.read(&mut bytes);
println!("read file ? {:?}", _r);
if let Ok(_) = _r {
//let bytes = contents.to_vec();
ret = Some(Image{
path,
bytes,
ext_id:0,
});
}
}
}

ret
}
}
4 changes: 3 additions & 1 deletion src/elements/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ mod vbox;
mod hbox;
mod scrollbox;
mod button;
mod image;

pub use self::element::*;
pub use self::textbox::TextBox;
pub use self::vbox::VBox;
pub use self::hbox::HBox;
pub use self::scrollbox::ScrollBox;
pub use self::button::Button;
pub use self::button::Button;
pub use self::image::*;
8 changes: 4 additions & 4 deletions src/gui/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ impl Properties {
.set(Property::Bottom(Unit::Stretch(0.0)))
.set(Property::MinWidth(Unit::Pixel(0.0)))
.set(Property::MinHeight(Unit::Pixel(0.0)))
.set(Property::Color(ColorF::new(0.9,0.9,0.9,1.0)))
.set(Property::Color(ColorF::new(0.8,0.8,0.8,1.0)))
.set(Property::BgColor(ColorF::new(1.0,1.0,1.0,0.0)))
.set(Property::FocusColor(ColorF::new(0.8,0.8,0.8,1.0)))
.set(Property::FocusColor(ColorF::new(1.0,1.0,1.0,1.0)))
.set(Property::FocusBgColor(ColorF::new(0.0,0.0,0.0,0.0)))
.set(Property::HoverColor(ColorF::new(1.0,1.0,1.0,1.0)))
.set(Property::HoverColor(ColorF::new(0.9,0.9,0.9,1.0)))
.set(Property::HoverBgColor(ColorF::new(0.0,0.0,0.0,0.0)))
.set(Property::DisabledColor(ColorF::new(0.7,0.7,0.7,1.0)))
.set(Property::DisabledColor(ColorF::new(0.5,0.5,0.5,1.0)))
.set(Property::DisabledBgColor(ColorF::new(0.0,0.0,0.0,0.0)))
.set(Property::TextAlign(Align::Left))
}
Expand Down

0 comments on commit 5cee39a

Please sign in to comment.