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
15
.gitignore
vendored
15
.gitignore
vendored
|
|
@ -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
|
||||
|
|
|
|||
16
Cargo.toml
16
Cargo.toml
|
|
@ -1,7 +1,19 @@
|
|||
[package]
|
||||
name = "app"
|
||||
version = "0.1.0"
|
||||
name = "shinekit"
|
||||
version = "0.1.0-dev"
|
||||
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]
|
||||
libc = "0.2"
|
||||
|
|
|
|||
19
LICENSE
Normal file
19
LICENSE
Normal 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.
|
||||
7
examples/layout/Cargo.toml
Normal file
7
examples/layout/Cargo.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[package]
|
||||
name = "layout"
|
||||
version = "0.1.0"
|
||||
authors = ["Ryan McGrath <ryan@rymc.io>"]
|
||||
|
||||
[dependencies]
|
||||
shinekit = { path = "../.." }
|
||||
|
|
@ -9,25 +9,9 @@
|
|||
//! @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;
|
||||
extern crate shinekit;
|
||||
use shinekit::*;
|
||||
|
||||
//mod calendar;
|
||||
//use calendar::{Data, Calendar};
|
||||
|
||||
fn main() {
|
||||
shinekit::run(vec![
|
||||
StyleSheet::default(include_str!("styles/default.json"))
|
||||
|
|
@ -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);
|
||||
|
|
@ -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) {
|
||||
}
|
||||
|
|
@ -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