From 994d31ac3f45884e9c0274bff041cb699b47e7c5 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Wed, 20 Jun 2018 18:07:26 -0400 Subject: [PATCH] Rework so project has a license, more natural crate structure, dedicated examples folder, less confusing lib heirarchy --- .gitignore | 15 +++++- Cargo.toml | 16 +++++- LICENSE | 19 +++++++ examples/layout/Cargo.toml | 7 +++ {src => examples/layout/src}/main.rs | 18 +------ {src => examples/layout/src}/styles/dark.json | 0 .../layout/src}/styles/default.json | 0 .../application/mod.rs => application.rs} | 7 ++- src/calendar.rs | 50 ------------------- src/{shinekit => }/color.rs | 0 src/{shinekit/mod.rs => lib.rs} | 34 +++++++++---- src/{shinekit => }/listview/datasource.rs | 0 src/{shinekit => }/listview/mod.rs | 0 src/{shinekit => }/listview/row.rs | 0 src/{shinekit => }/scrollview.rs | 0 src/shinekit/layout.rs | 26 ---------- src/{shinekit => }/stylesheet.rs | 0 src/{shinekit => }/text.rs | 0 src/{shinekit => }/util.rs | 0 src/{shinekit => }/view.rs | 4 +- src/{shinekit/application => }/window.rs | 4 +- 21 files changed, 85 insertions(+), 115 deletions(-) create mode 100644 LICENSE create mode 100644 examples/layout/Cargo.toml rename {src => examples/layout/src}/main.rs (71%) rename {src => examples/layout/src}/styles/dark.json (100%) rename {src => examples/layout/src}/styles/default.json (100%) rename src/{shinekit/application/mod.rs => application.rs} (95%) delete mode 100644 src/calendar.rs rename src/{shinekit => }/color.rs (100%) rename src/{shinekit/mod.rs => lib.rs} (75%) rename src/{shinekit => }/listview/datasource.rs (100%) rename src/{shinekit => }/listview/mod.rs (100%) rename src/{shinekit => }/listview/row.rs (100%) rename src/{shinekit => }/scrollview.rs (100%) delete mode 100644 src/shinekit/layout.rs rename src/{shinekit => }/stylesheet.rs (100%) rename src/{shinekit => }/text.rs (100%) rename src/{shinekit => }/util.rs (100%) rename src/{shinekit => }/view.rs (99%) rename src/{shinekit/application => }/window.rs (98%) diff --git a/.gitignore b/.gitignore index 21ca23c..fe16799 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,18 @@ +# Compiled files +*.o +*.so +*.rlib +*.dll + +# Executables +*.exe + +# Generated by Cargo +target + +# Other certs .env -target +Cargo.lock **/*.rs.bk **/*.swp diff --git a/Cargo.toml b/Cargo.toml index ec12723..f2c6369 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,19 @@ [package] -name = "app" -version = "0.1.0" +name = "shinekit" +version = "0.1.0-dev" authors = ["Ryan McGrath "] +description = """ +A general UI framework for Mac, iOS, and Windows. Uses actual native +platform widgets, very little to no middleman. Cocoa on Mac, Cocoa Touch on iOS, +UWP on Windows, with potentially more coming. +""" +documentation = "https://shinekit.rs/docs/" +homepage = "https://shinekit.rs" +repository = "https://github.com/ryanmcgrath/shinekit" +readme = "../readme.md" +keywords = ["shinekit", "gui", "framework", "cocoa", "iphone", "ios", "windows"] +license = "MIT" +categories = ["gui"] [dependencies] libc = "0.2" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7cddbe3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +The MIT License (MIT) +Copyright (c) 2018 Ryan McGrath + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/examples/layout/Cargo.toml b/examples/layout/Cargo.toml new file mode 100644 index 0000000..f4a4600 --- /dev/null +++ b/examples/layout/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "layout" +version = "0.1.0" +authors = ["Ryan McGrath "] + +[dependencies] +shinekit = { path = "../.." } diff --git a/src/main.rs b/examples/layout/src/main.rs similarity index 71% rename from src/main.rs rename to examples/layout/src/main.rs index 8f85a7d..0d4ab34 100644 --- a/src/main.rs +++ b/examples/layout/src/main.rs @@ -9,25 +9,9 @@ //! @author Ryan McGrath //! @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; +extern crate shinekit; use shinekit::*; -//mod calendar; -//use calendar::{Data, Calendar}; - fn main() { shinekit::run(vec![ StyleSheet::default(include_str!("styles/default.json")) diff --git a/src/styles/dark.json b/examples/layout/src/styles/dark.json similarity index 100% rename from src/styles/dark.json rename to examples/layout/src/styles/dark.json diff --git a/src/styles/default.json b/examples/layout/src/styles/default.json similarity index 100% rename from src/styles/default.json rename to examples/layout/src/styles/default.json diff --git a/src/shinekit/application/mod.rs b/src/application.rs similarity index 95% rename from src/shinekit/application/mod.rs rename to src/application.rs index 71f54e7..3bad9f3 100644 --- a/src/shinekit/application/mod.rs +++ b/src/application.rs @@ -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, diff --git a/src/calendar.rs b/src/calendar.rs deleted file mode 100644 index 4b55e00..0000000 --- a/src/calendar.rs +++ /dev/null @@ -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 -//! @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, - 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()); - }*/ - } -} diff --git a/src/shinekit/color.rs b/src/color.rs similarity index 100% rename from src/shinekit/color.rs rename to src/color.rs diff --git a/src/shinekit/mod.rs b/src/lib.rs similarity index 75% rename from src/shinekit/mod.rs rename to src/lib.rs index f5038ed..12ad35e 100644 --- a/src/shinekit/mod.rs +++ b/src/lib.rs @@ -7,21 +7,33 @@ //! @author Ryan McGrath //! @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); diff --git a/src/shinekit/listview/datasource.rs b/src/listview/datasource.rs similarity index 100% rename from src/shinekit/listview/datasource.rs rename to src/listview/datasource.rs diff --git a/src/shinekit/listview/mod.rs b/src/listview/mod.rs similarity index 100% rename from src/shinekit/listview/mod.rs rename to src/listview/mod.rs diff --git a/src/shinekit/listview/row.rs b/src/listview/row.rs similarity index 100% rename from src/shinekit/listview/row.rs rename to src/listview/row.rs diff --git a/src/shinekit/scrollview.rs b/src/scrollview.rs similarity index 100% rename from src/shinekit/scrollview.rs rename to src/scrollview.rs diff --git a/src/shinekit/layout.rs b/src/shinekit/layout.rs deleted file mode 100644 index dd0a584..0000000 --- a/src/shinekit/layout.rs +++ /dev/null @@ -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 -//! @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; - 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) { -} diff --git a/src/shinekit/stylesheet.rs b/src/stylesheet.rs similarity index 100% rename from src/shinekit/stylesheet.rs rename to src/stylesheet.rs diff --git a/src/shinekit/text.rs b/src/text.rs similarity index 100% rename from src/shinekit/text.rs rename to src/text.rs diff --git a/src/shinekit/util.rs b/src/util.rs similarity index 100% rename from src/shinekit/util.rs rename to src/util.rs diff --git a/src/shinekit/view.rs b/src/view.rs similarity index 99% rename from src/shinekit/view.rs rename to src/view.rs index d1d2bec..6d2d2ea 100644 --- a/src/shinekit/view.rs +++ b/src/view.rs @@ -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 { diff --git a/src/shinekit/application/window.rs b/src/window.rs similarity index 98% rename from src/shinekit/application/window.rs rename to src/window.rs index 370e5c7..addc7a8 100644 --- a/src/shinekit/application/window.rs +++ b/src/window.rs @@ -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,