Initial project import
This commit is contained in:
commit
23f2d29e32
11957 files changed
+1754577
No files matched your search
@@ -0,0 +1,43 @@
|
||||
module ios
|
||||
|
||||
import macos
|
||||
|
||||
#flag -framework UIKit
|
||||
#insert "@VEXEROOT/vlib/ios/uikit_bridge.h"
|
||||
|
||||
fn C.ios_ui_application_main(argc int, argv &&char, principal voidptr, delegate voidptr) int
|
||||
fn C.ios_color_from_hex(hex u32) voidptr
|
||||
fn C.ios_color_from_hex_alpha(hex u32, alpha f64) voidptr
|
||||
fn C.ios_index_path_row(index_path voidptr) i64
|
||||
fn C.ios_index_path_for_row(row i64, section i64) voidptr
|
||||
|
||||
// Start the UIKit application run loop.
|
||||
@[inline]
|
||||
pub fn application_main(argc int, argv &&char, delegate_class_name string) int {
|
||||
return C.ios_ui_application_main(argc, argv, unsafe { nil },
|
||||
macos.nsstring(delegate_class_name))
|
||||
}
|
||||
|
||||
// Create a UIColor from a hex value (0xRRGGBB).
|
||||
@[inline]
|
||||
pub fn color(hex u32) macos.Id {
|
||||
return C.ios_color_from_hex(hex)
|
||||
}
|
||||
|
||||
// Create a UIColor from a hex value with alpha.
|
||||
@[inline]
|
||||
pub fn color_alpha(hex u32, alpha f64) macos.Id {
|
||||
return C.ios_color_from_hex_alpha(hex, alpha)
|
||||
}
|
||||
|
||||
// Get the row index from an NSIndexPath.
|
||||
@[inline]
|
||||
pub fn index_path_row(index_path macos.Id) int {
|
||||
return int(C.ios_index_path_row(index_path))
|
||||
}
|
||||
|
||||
// Create an NSIndexPath for a row in a section.
|
||||
@[inline]
|
||||
pub fn index_path(row int, section int) macos.Id {
|
||||
return C.ios_index_path_for_row(i64(row), i64(section))
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef IOS_UIKIT_BRIDGE_H
|
||||
#define IOS_UIKIT_BRIDGE_H
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
static inline int ios_ui_application_main(int argc, char** argv, void* principal, void* delegate) {
|
||||
return UIApplicationMain(argc, argv, (__bridge NSString*)principal, (__bridge NSString*)delegate);
|
||||
}
|
||||
|
||||
static inline void* ios_color_from_hex(unsigned int hex) {
|
||||
CGFloat r = ((hex >> 16) & 0xFF) / 255.0;
|
||||
CGFloat g = ((hex >> 8) & 0xFF) / 255.0;
|
||||
CGFloat b = (hex & 0xFF) / 255.0;
|
||||
return (void*)[UIColor colorWithRed:r green:g blue:b alpha:1.0];
|
||||
}
|
||||
|
||||
static inline void* ios_color_from_hex_alpha(unsigned int hex, double alpha) {
|
||||
CGFloat r = ((hex >> 16) & 0xFF) / 255.0;
|
||||
CGFloat g = ((hex >> 8) & 0xFF) / 255.0;
|
||||
CGFloat b = (hex & 0xFF) / 255.0;
|
||||
return (void*)[UIColor colorWithRed:r green:g blue:b alpha:alpha];
|
||||
}
|
||||
|
||||
static inline long long ios_index_path_row(void* index_path) {
|
||||
return [((NSIndexPath*)index_path) row];
|
||||
}
|
||||
|
||||
static inline void* ios_index_path_for_row(long long row, long long section) {
|
||||
return (void*)[NSIndexPath indexPathForRow:row inSection:section];
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user