Rework so project has a license, more natural crate structure, dedicated examples folder, less confusing lib heirarchy

This commit is contained in:
Ryan McGrath 2018-06-20 18:07:26 -04:00
parent 0c503a549a
commit 994d31ac3f
No known key found for this signature in database
GPG key ID: 811674B62B666830
21 changed files with 85 additions and 115 deletions

15
.gitignore vendored
View file

@ -1,5 +1,18 @@
# Compiled files
*.o
*.so
*.rlib
*.dll
# Executables
*.exe
# Generated by Cargo
target
# Other
certs certs
.env .env
target Cargo.lock
**/*.rs.bk **/*.rs.bk
**/*.swp **/*.swp

View file

@ -1,7 +1,19 @@
[package] [package]
name = "app" name = "shinekit"
version = "0.1.0" version = "0.1.0-dev"
authors = ["Ryan McGrath <ryan@rymc.io>"] authors = ["Ryan McGrath <ryan@rymc.io>"]
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] [dependencies]
libc = "0.2" libc = "0.2"

19
LICENSE Normal file
View file

@ -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.

View file

@ -0,0 +1,7 @@
[package]
name = "layout"
version = "0.1.0"
authors = ["Ryan McGrath <ryan@rymc.io>"]
[dependencies]
shinekit = { path = "../.." }

View file

@ -9,25 +9,9 @@
//! @author Ryan McGrath <ryan@rymc.io> //! @author Ryan McGrath <ryan@rymc.io>
//! @created 05/30/2018 //! @created 05/30/2018
#![allow(dead_code)] extern crate shinekit;
#![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::*; use shinekit::*;
//mod calendar;
//use calendar::{Data, Calendar};
fn main() { fn main() {
shinekit::run(vec![ shinekit::run(vec![
StyleSheet::default(include_str!("styles/default.json")) StyleSheet::default(include_str!("styles/default.json"))

View file

@ -17,10 +17,9 @@ use cocoa::appkit::{
use serde_json::{Map, Value}; use serde_json::{Map, Value};
pub mod window; use color::Color;
use shinekit::color::Color; use window::Window;
use shinekit::application::window::Window; use view::View;
use shinekit::view::View;
pub struct App { pub struct App {
pub app: id, pub app: id,

View file

@ -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());
}*/
}
}

View file

@ -7,21 +7,33 @@
//! @author Ryan McGrath <ryan@rymc.io> //! @author Ryan McGrath <ryan@rymc.io>
//! @created 05/30/2018 //! @created 05/30/2018
pub mod application; #![allow(dead_code)]
//pub mod tableview; #![allow(non_upper_case_globals)]
pub mod color;
//pub mod scrollview;
//pub mod text;
pub mod util;
pub mod view;
pub mod stylesheet;
pub use application::App; #[macro_use]
pub use stylesheet::StyleSheet; extern crate objc;
pub use view::View; extern crate cocoa;
extern crate objc_id;
extern crate core_graphics;
#[macro_use]
extern crate serde_json;
use serde_json::Value; 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; 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) { pub fn run(user_styles: Vec<(String, Value)>, mut application: App) {
let mut styles = load_styles(user_styles); let mut styles = load_styles(user_styles);

View file

@ -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) {
}

View file

@ -16,8 +16,8 @@ use objc::runtime::{Class, Object, Sel, BOOL};
use cocoa::foundation::NSArray; use cocoa::foundation::NSArray;
use cocoa::base::{class, id, nil, YES, NO}; use cocoa::base::{class, id, nil, YES, NO};
use shinekit::color::Color; use color::Color;
use shinekit::util::empty_frame; use util::empty_frame;
#[derive(Debug)] #[derive(Debug)]
pub enum ViewKind { pub enum ViewKind {

View file

@ -11,8 +11,8 @@ use cocoa::base::{id, nil, YES, NO};
use cocoa::appkit::{NSWindow, NSWindowStyleMask, NSBackingStoreType}; use cocoa::appkit::{NSWindow, NSWindowStyleMask, NSBackingStoreType};
use cocoa::foundation::{NSRect, NSPoint, NSSize, NSString, NSAutoreleasePool}; use cocoa::foundation::{NSRect, NSPoint, NSSize, NSString, NSAutoreleasePool};
use shinekit::color::Color; use color::Color;
use shinekit::view::View; use view::View;
pub struct Window { pub struct Window {
pub window: id, pub window: id,