Rework so project has a license, more natural crate structure, dedicated examples folder, less confusing lib heirarchy
This commit is contained in:
parent
0c503a549a
commit
994d31ac3f
21 changed files with 85 additions and 115 deletions
|
|
@ -17,10 +17,9 @@ use cocoa::appkit::{
|
|||
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
pub mod window;
|
||||
use shinekit::color::Color;
|
||||
use shinekit::application::window::Window;
|
||||
use shinekit::view::View;
|
||||
use color::Color;
|
||||
use window::Window;
|
||||
use view::View;
|
||||
|
||||
pub struct App {
|
||||
pub app: id,
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
//! calendar.rs
|
||||
//!
|
||||
//! The actual implementation of the calendar view/data/etc. Fetches
|
||||
//! upcoming tournaments, ensures everything's good, and passes it on
|
||||
//! demand to the rendering view(s).
|
||||
//!
|
||||
//! @author Ryan McGrath <ryan@rymc.io>
|
||||
//! @created 05/30/2018
|
||||
|
||||
use ruikit::view::View;
|
||||
use ruikit::color::Color;
|
||||
use ruikit::tableview::{TableViewData, TableViewRow};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Data {
|
||||
pub color: Color,
|
||||
pub label: String
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub fn new(msg: &str, r: i32, g: i32, b: i32) -> Self {
|
||||
Data {
|
||||
label: msg.to_string(),
|
||||
color: Color::rgb(r,g,b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Calendar {
|
||||
pub tournaments: Vec<Data>,
|
||||
pub r: Color
|
||||
}
|
||||
|
||||
impl TableViewData for Calendar {
|
||||
fn number_of_items(&self) -> usize {
|
||||
self.tournaments.len()
|
||||
}
|
||||
|
||||
fn configure_item(&mut self, view: &TableViewRow, row: usize) {
|
||||
println!("Hmmm... {}", row);
|
||||
if row == 3 {
|
||||
//view.set_background_color(&Color::system_red());
|
||||
view.set_background_color(&self.r);
|
||||
}/* else if row == 2 {
|
||||
view.set_background_color(&Color::rgb(5,35,229));
|
||||
} else {
|
||||
view.set_background_color(&Color::system_blue());
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
@ -7,21 +7,33 @@
|
|||
//! @author Ryan McGrath <ryan@rymc.io>
|
||||
//! @created 05/30/2018
|
||||
|
||||
pub mod application;
|
||||
//pub mod tableview;
|
||||
pub mod color;
|
||||
//pub mod scrollview;
|
||||
//pub mod text;
|
||||
pub mod util;
|
||||
pub mod view;
|
||||
pub mod stylesheet;
|
||||
#![allow(dead_code)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
|
||||
pub use application::App;
|
||||
pub use stylesheet::StyleSheet;
|
||||
pub use view::View;
|
||||
#[macro_use]
|
||||
extern crate objc;
|
||||
extern crate cocoa;
|
||||
extern crate objc_id;
|
||||
extern crate core_graphics;
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_json;
|
||||
use serde_json::Value;
|
||||
|
||||
pub mod application;
|
||||
pub use application::App;
|
||||
|
||||
pub mod window;
|
||||
pub use window::Window;
|
||||
|
||||
pub mod color;
|
||||
pub mod util;
|
||||
pub mod stylesheet;
|
||||
use stylesheet::load_styles;
|
||||
pub use stylesheet::StyleSheet;
|
||||
|
||||
pub mod view;
|
||||
pub use view::View;
|
||||
|
||||
pub fn run(user_styles: Vec<(String, Value)>, mut application: App) {
|
||||
let mut styles = load_styles(user_styles);
|
||||
38
src/main.rs
38
src/main.rs
|
|
@ -1,38 +0,0 @@
|
|||
//! App
|
||||
//!
|
||||
//! An "App" in Rust, which is really just wrapping a lot of platform-specific
|
||||
//! logic. Attempts to do as much as possible in Rust, however the GUI story in
|
||||
//! Rust is the worst thing at the moment, so a lot of this is glorified message
|
||||
//! passing to Objective C and co. ObjC is also one of the best languages ever
|
||||
//! created and you can fight me on this if you so choose.
|
||||
//!
|
||||
//! @author Ryan McGrath <ryan@rymc.io>
|
||||
//! @created 05/30/2018
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate objc;
|
||||
extern crate cocoa;
|
||||
extern crate objc_id;
|
||||
extern crate core_graphics;
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_json;
|
||||
|
||||
// extern crate shinekit;
|
||||
mod shinekit;
|
||||
use shinekit::*;
|
||||
|
||||
//mod calendar;
|
||||
//use calendar::{Data, Calendar};
|
||||
|
||||
fn main() {
|
||||
shinekit::run(vec![
|
||||
StyleSheet::default(include_str!("styles/default.json"))
|
||||
], App::new("eSports Calendar", View::named("root").subviews(vec![
|
||||
View::named("sidebar"),
|
||||
View::named("content")
|
||||
])));
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
//! layout.rs
|
||||
//!
|
||||
//! A trait that more or less allows any other types to compose
|
||||
//! a "subclass" for a view. By using the actual backing [UI|NS]View
|
||||
//! for storing certain properties, it becomes much easier to get around
|
||||
//! Rust's (good-for-you) restrictions.
|
||||
//!
|
||||
//! @author Ryan McGrath <ryan@rymc.io>
|
||||
//! @created 05/30/2018
|
||||
|
||||
use objc::declare::ClassDecl;
|
||||
use objc::runtime::{Object, BOOL};
|
||||
use cocoa::base::{class, id, nil, YES, NO};
|
||||
use cocoa::foundation::NSArray;
|
||||
|
||||
use shinekit::view::View;
|
||||
|
||||
pub trait Layout {
|
||||
fn get_subviews(&self) -> &Vec<View>;
|
||||
fn get_root_backing_node(&self) -> &Object;
|
||||
fn set_constraint_ivar(&mut self, ivar: &str, constraint: id);
|
||||
|
||||
}
|
||||
|
||||
pub fn add_autolayout_ivars(decl: &mut ClassDecl) {
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"calendar": {
|
||||
"backgroundColor": "blue"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"window": {
|
||||
"backgroundColor": {"r": 35, "g": 108, "b": 218},
|
||||
"defaultWidth": 800,
|
||||
"defaultHeight": 600
|
||||
},
|
||||
|
||||
"root": {
|
||||
"backgroundColor": {"r": 35, "g": 108, "b": 218}
|
||||
},
|
||||
|
||||
"sidebar": {
|
||||
"backgroundColor": {"r": 5, "g": 5, "b": 5},
|
||||
"width": 200,
|
||||
"top": "root.top",
|
||||
"left": "root.left",
|
||||
"bottom": "root.bottom"
|
||||
},
|
||||
|
||||
"content": {
|
||||
"backgroundColor": {"r": 35, "g": 108, "b": 218},
|
||||
"top": "root.top",
|
||||
"left": "sidebar.right",
|
||||
"right": "root.right",
|
||||
"bottom": "root.bottom"
|
||||
}
|
||||
}
|
||||
|
|
@ -16,8 +16,8 @@ use objc::runtime::{Class, Object, Sel, BOOL};
|
|||
use cocoa::foundation::NSArray;
|
||||
use cocoa::base::{class, id, nil, YES, NO};
|
||||
|
||||
use shinekit::color::Color;
|
||||
use shinekit::util::empty_frame;
|
||||
use color::Color;
|
||||
use util::empty_frame;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ViewKind {
|
||||
|
|
@ -11,8 +11,8 @@ use cocoa::base::{id, nil, YES, NO};
|
|||
use cocoa::appkit::{NSWindow, NSWindowStyleMask, NSBackingStoreType};
|
||||
use cocoa::foundation::{NSRect, NSPoint, NSSize, NSString, NSAutoreleasePool};
|
||||
|
||||
use shinekit::color::Color;
|
||||
use shinekit::view::View;
|
||||
use color::Color;
|
||||
use view::View;
|
||||
|
||||
pub struct Window {
|
||||
pub window: id,
|
||||
Reference in a new issue