Unverified Commit 1e4e38a3 authored by Jeremy Soller's avatar Jeremy Soller Committed by GitHub
Browse files

Merge pull request #38 from blackle/master

 Update calendar and file_manager to use new CSS in orbtk 
parents 3f6dff89 2772abc9
......@@ -119,6 +119,30 @@ name = "constant_time_eq"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cssparser"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
"procedural-masquerade 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cssparser-macros"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
"procedural-masquerade 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "dbghelp-sys"
version = "0.2.0"
......@@ -529,8 +553,10 @@ dependencies = [
[[package]]
name = "orbtk"
version = "0.2.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "git+https://github.com/redox-os/orbtk.git#fbab345cd8850cc739c6a7194438d9043308d7f6"
dependencies = [
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"orbclient 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
"orbfont 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"orbimage 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -551,7 +577,7 @@ dependencies = [
"orbclient 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
"orbfont 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"orbimage 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"orbtk 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"orbtk 0.2.26 (git+https://github.com/redox-os/orbtk.git)",
"redox_event 0.1.0 (git+https://github.com/redox-os/event.git)",
"redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_users 0.1.0 (git+https://github.com/redox-os/users.git)",
......@@ -615,6 +641,11 @@ name = "precomputed-hash"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "procedural-masquerade"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "quote"
version = "0.3.15"
......@@ -1006,6 +1037,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd"
"checksum color_quant 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a475fc4af42d83d28adf72968d9bcfaf035a1a9381642d8e85d8a04957767b0d"
"checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e"
"checksum cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2842253baded8e712e9d8d80ebfe5ea8e95c5b27071e6a6db6080ca1e81c07d1"
"checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df"
"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850"
"checksum debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3"
"checksum deflate 0.7.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4dddda59aaab719767ab11d3efd9a714e95b610c4445d4435765021e9d52dfb1"
......@@ -1056,7 +1089,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum orbclient 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "6e5d8d9900998fb4b9394e27058aa22a6d3509fb67dd860f74ba0507d4406943"
"checksum orbfont 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "da4dfbc851e5c24c3cf1e16ec5222f868f3362d2b7493d0b53051fe2669267a2"
"checksum orbimage 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "c3b031607ef7a3c562949dfb595b1ea2b2d697b14544af407242a52dce811a6f"
"checksum orbtk 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1fdeb80960b8fdf548f12a694569ba35aec436246277393bcc13d9559722e443"
"checksum orbtk 0.2.26 (git+https://github.com/redox-os/orbtk.git)" = "<none>"
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
"checksum phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "cb325642290f28ee14d8c6201159949a872f220c62af6e110a56ea914fbe42fc"
"checksum phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d62594c0bb54c464f633175d502038177e90309daf2e0158be42ed5f023ce88f"
......@@ -1064,6 +1097,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2"
"checksum png 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3cb773e9a557edb568ce9935cf783e3cdcabe06a9449d41b3e5506d88e582c82"
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
"checksum procedural-masquerade 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dc1bcafee1590f81acb329ae45ec627b318123f085153913620316ae9a144b2a"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
"checksum rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6475140dfd8655aeb72e1fd4b7a1cc1c202be65d71669476e392fe62532b9edd"
"checksum rayon 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a77c51c07654ddd93f6cb543c7a849863b03abc7e82591afda6dc8ad4ac3ac4a"
......
......@@ -57,7 +57,7 @@ mime = "0.2"
orbclient = "0.3"
orbfont = "0.1"
orbimage = "0.1"
orbtk = "0.2"
orbtk = { git = "https://github.com/redox-os/orbtk.git" }
tendril = "0.4"
url = "1.5"
redox_users = { git = "https://github.com/redox-os/users.git" }
......
......@@ -2,15 +2,16 @@ extern crate orbtk;
extern crate chrono;
extern crate orbclient;
use orbtk::{Rect, Window, Grid, Label, Button};
use orbtk::traits::{Place, Text, Border, Click};
use orbclient::{Color};
use orbtk::{Rect, Window, WindowBuilder, Grid, Label, Button, Style};
use orbtk::traits::{Place, Text, Click};
use orbtk::theme::Theme;
use chrono::prelude::*;
use chrono::Duration;
use std::ops::{Sub, Add};
use std::sync::Arc;
use std::sync::mpsc::{channel, Receiver};
static CALENDAR_THEME_CSS: &'static str = include_str!("theme.css");
pub struct TimeMachine {
date: DateTime<Local>,
......@@ -67,7 +68,11 @@ impl Calendar {
let cell_day_name_height = 16;
let window_width = 7 * (cell_width + 8) + 8;
let window_height = 6 * (cell_height + 8) + 16 + cell_day_name_height + 24;
let window = Window::new(Rect::new(-1, -1, window_width, window_height), "Calendar");
let theme = Theme::parse(CALENDAR_THEME_CSS);
let mut window_builder = WindowBuilder::new(Rect::new(-1, -1, window_width, window_height), "Calendar");
window_builder = window_builder.theme(theme);
let window = window_builder.build();
let label_date = Label::new();
label_date.size(300, 16)
......@@ -153,14 +158,12 @@ impl Calendar {
cell
.size(self.cell_width, self.cell_height)
.border(true)
.with_class("date")
.text(text)
.text_offset(text_offset as i32, (self.cell_width / 2 -8) as i32);
if x.date() == Local::now().date() {
cell.bg.set(Color::rgb(82, 148, 226));
} else {
cell.bg.set(Color::rgb(255, 255, 255));
cell.with_class("today");
}
self.grid_calendar.insert(idx % 7, (idx / 7) + 1, &cell);
......
label.date {
background: white;
border-width: 1;
border-radius: 4;
}
label.date.today {
background: #5294E2;
color: white;
}
\ No newline at end of file
......@@ -22,7 +22,8 @@ use mime::TopLevel as MimeTop;
use orbclient::{Color, Renderer, WindowFlag};
use orbimage::Image;
use orbtk::{Window, Point, Rect, Button, List, Entry, Label, Place, Resize, Text, TextBox, Click, Enter};
use orbtk::{Window, WindowBuilder, Point, Rect, Button, List, Entry, Label, Place, Resize, Text, Style, TextBox, Click, Enter};
use orbtk::theme::Theme;
const ICON_SIZE: i32 = 32;
......@@ -38,6 +39,8 @@ static LAUNCH_COMMAND: &'static str = "/ui/bin/launcher";
#[cfg(not(target_os = "redox"))]
static LAUNCH_COMMAND: &'static str = "xdg-open";
static FILE_MANAGER_THEME_CSS: &'static str = include_str!("theme.css");
struct FileInfo {
name: String,
path: PathBuf,
......@@ -258,11 +261,13 @@ impl FileManager {
let (display_width, display_height) = orbclient::get_display_size().expect("viewer: failed to get display size");
let (window_w, window_h) = (cmp::min(640, display_width * 4/5) as i32, cmp::min(480, display_height * 4/5) as i32);
let window = Window::new_flags(
Rect::new(-1, -1, window_w as u32, window_h as u32), "File Manager", &[WindowFlag::Resizable]
);
let theme = Theme::parse(FILE_MANAGER_THEME_CSS);
window.bg.set(Color::rgb(255, 255, 255));
let mut window_builder = WindowBuilder::new(Rect::new(-1, -1, window_w as u32, window_h as u32), "File Manager")
.theme(theme)
.flags(&[WindowFlag::Resizable]);
window_builder = window_builder;
let window = window_builder.build();
let tx_resize = tx.clone();
window.on_resize(move |_window, width, height| {
......@@ -368,7 +373,7 @@ impl FileManager {
if let None = self.column_labels.get(0) {
let label = Label::new();
self.window.add(&label);
label.bg.set(Color::rgba(255, 255, 255, 0));
label.with_class("entry");
label.text_offset.set(Point::new(0, 8));
let tx = self.tx.clone();
......@@ -477,7 +482,7 @@ impl FileManager {
// header text
let label = Label::new();
self.window.add(&label);
label.bg.set(Color::rgba(255, 255, 255, 0));
label.with_class("header");
label.text_offset.set(Point::new(0, 8));
let tx = self.tx.clone();
......@@ -489,8 +494,7 @@ impl FileManager {
// sort arrow
let label = Label::new();
self.window.add(&label);
label.bg.set(Color::rgba(255, 255, 255, 0));
label.fg.set(Color::rgb(140, 140, 140));
label.with_class("sort");
label.text_offset.set(Point::new(0, 8));
self.column_labels.push(label);
}
......@@ -546,20 +550,20 @@ impl FileManager {
let mut label = Label::new();
label.position(columns[0].x, 0).size(w, ICON_SIZE as u32).text(file.name.clone());
label.text_offset.set(Point::new(0, 8));
label.bg.set(Color::rgba(255, 255, 255, 0));
label.with_class("file-name");
entry.add(&label);
label = Label::new();
label.position(columns[1].x, 0).size(w, ICON_SIZE as u32).text(file.size_str.clone());
label.text_offset.set(Point::new(0, 8));
label.bg.set(Color::rgba(255, 255, 255, 0));
label.with_class("file-size");
entry.add(&label);
let description = self.file_types_info.description_for(&file.name);
label = Label::new();
label.position(columns[2].x, 0).size(w, ICON_SIZE as u32).text(description);
label.text_offset.set(Point::new(0, 8));
label.bg.set(Color::rgba(255, 255, 255, 0));
label.with_class("description");
entry.add(&label);
list.push(&entry);
......
window {
background: white;
}
label.entry, label.header, label.sort, label.file-name, label.file-size, label.description {
background: white;
}
label.sort {
color: #8c8c8c;
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment