new ui un-stashed

This commit is contained in:
Diego Waxemberg
2014-10-24 16:02:10 -04:00
parent fac48ecf42
commit 6fbc55f193
23 changed files with 461 additions and 396 deletions
+15
View File
@@ -0,0 +1,15 @@
//
// App.h
// Limelight
//
// Created by Diego Waxemberg on 10/22/14.
// Copyright (c) 2014 Limelight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface App : NSObject
@property NSString* displayName;
@end
+13
View File
@@ -0,0 +1,13 @@
//
// App.m
// Limelight
//
// Created by Diego Waxemberg on 10/22/14.
// Copyright (c) 2014 Limelight Stream. All rights reserved.
//
#import "App.h"
@implementation App
@end
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "limelight_computer_2x-1.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "limelight_computer_2x.png"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "limelight_computer_2x-2.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "Left4Dead2-2.jpg"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "Left4Dead2.jpg"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "Left4Dead2-1.jpg"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

+2 -4
View File
@@ -29,9 +29,9 @@
<key>UILaunchStoryboardName</key>
<string>Launch Screen</string>
<key>UIMainStoryboardFile</key>
<string>MainFrame-iPhone</string>
<string>iPhone</string>
<key>UIMainStoryboardFile~ipad</key>
<string>MainFrame-iPad</string>
<string>iPad</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
@@ -44,8 +44,6 @@
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
+16
View File
@@ -0,0 +1,16 @@
//
// UIAppView.h
// Limelight
//
// Created by Diego Waxemberg on 10/22/14.
// Copyright (c) 2014 Limelight Stream. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "App.h"
@interface UIAppView : UIView
- (id) initWithApp:(App*)app;
@end
+50
View File
@@ -0,0 +1,50 @@
//
// UIAppView.m
// Limelight
//
// Created by Diego Waxemberg on 10/22/14.
// Copyright (c) 2014 Limelight Stream. All rights reserved.
//
#import "UIAppView.h"
@implementation UIAppView {
App* _app;
UIButton* _appButton;
UILabel* _appLabel;
}
static int LABEL_DY = 20;
- (id) initWithApp:(App*)app {
self = [super init];
_app = app;
_appButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_appButton setContentEdgeInsets:UIEdgeInsetsMake(0, 4, 0, 4)];
[_appButton setBackgroundImage:[[UIImage imageNamed:@"Left4Dead2"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)] forState:UIControlStateNormal];
[_appButton sizeToFit];
_appLabel = [[UILabel alloc] init];
[_appLabel setText:_app.displayName];
[_appLabel sizeToFit];
_appLabel.center = CGPointMake(_appButton.bounds.origin.x + (_appButton.bounds.size.width / 2), _appButton.bounds.origin.y + _appButton.bounds.size.height + LABEL_DY);
[self addSubview:_appButton];
[self addSubview:_appLabel];
self.frame = CGRectMake(0, 0, _appButton.frame.size.width > _appLabel.frame.size.width ? _appButton.frame.size.width : _appLabel.frame.size.width, _appButton.frame.size.height + _appLabel.frame.size.height);
return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
+16
View File
@@ -0,0 +1,16 @@
//
// UIComputerView.h
// Limelight
//
// Created by Diego Waxemberg on 10/22/14.
// Copyright (c) 2014 Limelight Stream. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Computer.h"
@interface UIComputerView : UIView
- (id) initWithComputer:(Computer*)computer;
@end
+48
View File
@@ -0,0 +1,48 @@
//
// UIComputerView.m
// Limelight
//
// Created by Diego Waxemberg on 10/22/14.
// Copyright (c) 2014 Limelight Stream. All rights reserved.
//
#import "UIComputerView.h"
@implementation UIComputerView {
Computer* _computer;
UIButton* _hostButton;
UILabel* _hostLabel;
}
static int LABEL_DY = 20;
- (id) initWithComputer:(Computer*)computer {
self = [super init];
_computer = computer;
_hostButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_hostButton setContentEdgeInsets:UIEdgeInsetsMake(0, 4, 0, 4)];
[_hostButton setBackgroundImage:[[UIImage imageNamed:@"Computer"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)] forState:UIControlStateNormal];
[_hostButton sizeToFit];
_hostLabel = [[UILabel alloc] init];
[_hostLabel setText:[_computer displayName]];
[_hostLabel sizeToFit];
_hostLabel.center = CGPointMake(_hostButton.bounds.origin.x + (_hostButton.bounds.size.width / 2), _hostButton.bounds.origin.y + _hostButton.bounds.size.height + LABEL_DY);
[self addSubview:_hostButton];
[self addSubview:_hostLabel];
self.frame = CGRectMake(0, 0, _hostButton.frame.size.width > _hostLabel.frame.size.width ? _hostButton.frame.size.width : _hostLabel.frame.size.width, _hostButton.frame.size.height + _hostLabel.frame.size.height);
return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
@@ -11,15 +11,7 @@
#import "PairManager.h"
#import "StreamConfiguration.h"
@interface MainFrameViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate, MDNSCallback, NSURLConnectionDelegate, PairCallback, UITextFieldDelegate>
@property (strong, nonatomic) IBOutlet UIPickerView *HostPicker;
- (IBAction)StreamButton:(UIButton *)sender;
- (IBAction)PairButton:(UIButton *)sender;
@property (strong, nonatomic) IBOutlet UIPickerView *StreamConfigs;
@property (strong, nonatomic) NSArray* streamConfigVals;
@property (strong, nonatomic) NSArray* hostPickerVals;
@property (strong, nonatomic) IBOutlet UITextField *hostTextField;
@interface MainFrameViewController : UIViewController <MDNSCallback, PairCallback, NSURLConnectionDelegate>
+ (StreamConfiguration*) getStreamConfiguration;
@@ -1,4 +1,4 @@
//
// MainFrameViewController.m
// Limelight-iOS
//
@@ -14,6 +14,9 @@
#import "VideoDecoderRenderer.h"
#import "StreamManager.h"
#import "Utils.h"
#import "UIComputerView.h"
#import "UIAppView.h"
#import "App.h"
@implementation MainFrameViewController {
NSOperationQueue* _opQueue;
@@ -27,6 +30,8 @@ static StreamConfiguration* streamConfig;
return streamConfig;
}
//TODO: no more pair button
/*
- (void)PairButton:(UIButton *)sender
{
NSLog(@"Pair Button Pressed!");
@@ -34,7 +39,7 @@ static StreamConfiguration* streamConfig;
_selectedHost = [[Computer alloc] initWithIp:self.hostTextField.text];
NSLog(@"Using custom host: %@", self.hostTextField.text);
}
if (![self validatePcSelected]) {
NSLog(@"No valid PC selected");
return;
@@ -54,6 +59,7 @@ static StreamConfiguration* streamConfig;
[_opQueue addOperation:pMan];
}
*/
- (void)showPIN:(NSString *)PIN {
dispatch_sync(dispatch_get_main_queue(), ^{
@@ -86,9 +92,12 @@ static StreamConfiguration* streamConfig;
[self presentViewController:alert animated:YES completion:nil];
}
//TODO: No more stream button
/*
- (void)StreamButton:(UIButton *)sender
{
NSLog(@"Stream Button Pressed!");
if ([self.hostTextField.text length] > 0) {
_selectedHost = [[Computer alloc] initWithIp:self.hostTextField.text];
NSLog(@"Using custom host: %@", self.hostTextField.text);
@@ -139,18 +148,9 @@ static StreamConfiguration* streamConfig;
NSLog(@"StreamConfig: %@, %d, %dx%dx%d at %d Mbps", streamConfig.host, streamConfig.hostAddr, streamConfig.width, streamConfig.height, streamConfig.frameRate, streamConfig.bitRate);
[self performSegueWithIdentifier:@"createStreamFrame" sender:self];
}
*/
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if (pickerView == self.StreamConfigs) {
return [self.streamConfigVals objectAtIndex:row];
} else if (pickerView == self.HostPicker) {
return ((Computer*)([self.hostPickerVals objectAtIndex:row])).displayName;
} else {
return nil;
}
}
/*
- (void)setSelectedHost:(NSInteger)selectedIndex
{
_selectedHost = (Computer*)([self.hostPickerVals objectAtIndex:selectedIndex]);
@@ -159,58 +159,71 @@ static StreamConfiguration* streamConfig;
_selectedHost = NULL;
}
}
*/
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if (pickerView == self.HostPicker) {
[self setSelectedHost:[self.HostPicker selectedRowInComponent:0]];
}
//TODO: figure out how to save this info!!
}
// returns the number of 'columns' to display.
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
// returns the # of rows in each component..
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if (pickerView == self.StreamConfigs) {
return self.streamConfigVals.count;
} else if (pickerView == self.HostPicker) {
return self.hostPickerVals.count;
} else {
return 0;
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.streamConfigVals = [[NSArray alloc] initWithObjects:@"1280x720 (30Hz)", @"1280x720 (60Hz)", @"1920x1080 (30Hz)", @"1920x1080 (60Hz)",nil];
[self.StreamConfigs selectRow:1 inComponent:0 animated:NO];
NSArray* streamConfigVals = [[NSArray alloc] initWithObjects:@"1280x720 (30Hz)", @"1280x720 (60Hz)", @"1920x1080 (30Hz)", @"1920x1080 (60Hz)",nil];
_opQueue = [[NSOperationQueue alloc] init];
// Initialize the host picker list
[self updateHosts:[[NSArray alloc] init]];
//[self updateHosts:[[NSArray alloc] init]];
Computer* test = [[Computer alloc] initWithIp:@"CEMENT-TRUCK"];
UIScrollView* hostScrollView = [[UIScrollView alloc] init];
hostScrollView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height / 2);
[hostScrollView setShowsHorizontalScrollIndicator:NO];
UIComputerView* compView;
for (int i = 0; i < 5; i++) {
compView = [[UIComputerView alloc] initWithComputer:test];
[hostScrollView addSubview:compView];
[compView sizeToFit];
compView.center = CGPointMake((compView.frame.size.width + 20) * i + compView.frame.size.width, hostScrollView.frame.size.height / 2);
}
[hostScrollView setContentSize:CGSizeMake(compView.frame.size.width * 5 + compView.frame.size.width, hostScrollView.frame.size.height)];
UIScrollView* appScrollView = [[UIScrollView alloc] init];
appScrollView.frame = CGRectMake(0, hostScrollView.frame.size.height, self.view.frame.size.width, self.view.frame.size.height / 2);
[appScrollView setShowsHorizontalScrollIndicator:NO];
App* testApp = [[App alloc] init];
testApp.displayName = @"Left 4 Dead 2";
UIAppView* appView;
for (int i = 0; i < 5; i++) {
appView = [[UIAppView alloc] initWithApp:testApp];
[appScrollView addSubview:appView];
[appView sizeToFit];
appView.center = CGPointMake((appView.frame.size.width + 20) * i + compView.frame.size.width, appScrollView.frame.size.height / 2);
}
[appScrollView setContentSize:CGSizeMake(appView.frame.size.width * 5 + appView.frame.size.width, appScrollView.frame.size.height)];
[self.view addSubview:hostScrollView];
[self.view addSubview:appScrollView];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
_mDNSManager = [[MDNSManager alloc] initWithCallback:self];
[_mDNSManager searchForHosts];
[super viewDidDisappear:animated];
//_mDNSManager = [[MDNSManager alloc] initWithCallback:self];
// [_mDNSManager searchForHosts];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[_mDNSManager stopSearching];
[super viewDidDisappear:animated];
// [_mDNSManager stopSearching];
}
- (void)updateHosts:(NSArray *)hosts {
@@ -219,11 +232,6 @@ static StreamConfiguration* streamConfig;
if ([hostPickerValues count] == 0) {
[hostPickerValues addObject:[[Computer alloc] initPlaceholder]];
}
self.hostPickerVals = hostPickerValues;
[self.HostPicker reloadAllComponents];
[self setSelectedHost:[self.HostPicker selectedRowInComponent:0]];
}
- (BOOL)validatePcSelected {
@@ -257,22 +265,4 @@ static StreamConfiguration* streamConfig;
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
NSString *deviceType = [UIDevice currentDevice].model;
if ([deviceType containsString:@"iPhone"] || [deviceType containsString:@"iPod"]) {
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
} else {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
NSString *deviceType = [UIDevice currentDevice].model;
if ([deviceType containsString:@"iPhone"] || [deviceType containsString:@"iPod"]) {
return UIInterfaceOrientationPortrait;
} else {
return UIInterfaceOrientationLandscapeRight;
}
}
@end
@@ -118,13 +118,4 @@
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeRight;
}
@end