Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial launch, pretty *darn* simple tool...
- Loading branch information
Showing
6 changed files
with
162 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,7 +1,24 @@ | |||
BoxFloat | Typewriter | ||
-------- | -------- | ||
|
|
||
I couldn't get Three20 Launcher to work, but then I thought "really, how hard | I couldn't get Three20 Launcher to work, but then I thought "really, how hard | ||
could this be?" | could this be?" | ||
|
|
||
Here's the result! | This is half of the result. The other half is [Iconid][] | ||
|
|||
"Typewriter" is able to accept any view, and so is actually a generic "box | |||
model" library. | |||
|
|||
It has one mode: as you add subviews, it will "type" them from left to right, | |||
dropping to a new line when the width of the next view exceeds the typewriter's | |||
`frame.size.width`. | |||
|
|||
To use this as an app launcher, just *use* an appropriate view for the subviews! | |||
|
|||
Todo | |||
==== | |||
|
|||
* Scrolling | |||
* Pagination | |||
|
|||
[Iconid]: https://github.com/colinta/iconid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,5 +1,11 @@ | |||
class AppDelegate | class AppDelegate | ||
def application(application, didFinishLaunchingWithOptions:launchOptions) | def application(application, didFinishLaunchingWithOptions:launchOptions) | ||
application.setStatusBarStyle(UIStatusBarStyleBlackTranslucent) | |||
|
|||
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) | |||
@window.rootViewController = FirstController.new | |||
@window.makeKeyAndVisible | |||
|
|||
true | true | ||
end | end | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,50 @@ | |||
|
|||
class FirstController < UIViewController | |||
|
|||
def viewDidLoad | |||
@typewriter = TypewriterView.alloc.initWithFrame([[0, 0], [320, 400]]) | |||
self.view.addSubview(@typewriter) | |||
|
|||
blue_view = UIView.alloc.initWithFrame([[0, 0], [ 80, 80]]) | |||
blue_view.backgroundColor = UIColor.blueColor | |||
red_view = UIView.alloc.initWithFrame([[0, 0], [120, 120]]) | |||
red_view.backgroundColor = UIColor.redColor | |||
|
|||
green_view = UIView.alloc.initWithFrame([[0, 0], [120, 40]]) | |||
green_view.backgroundColor = UIColor.greenColor | |||
cyan_view = UIView.alloc.initWithFrame([[0, 0], [120, 40]]) | |||
cyan_view.backgroundColor = UIColor.cyanColor | |||
|
|||
green_cyan_combo = TypewriterView.alloc.initWithFrame([[0, 0], [120, 120]]) | |||
green_cyan_combo.addSubview(green_view) | |||
green_cyan_combo.addSubview(cyan_view) | |||
|
|||
gray_view = UIView.alloc.initWithFrame([[0, 0], [80, 240]]) | |||
gray_view.backgroundColor = UIColor.grayColor | |||
|
|||
white_view = UIView.alloc.initWithFrame([[0, 0], [80, 120]]) | |||
white_view.backgroundColor = UIColor.whiteColor | |||
|
|||
black_view = UIView.alloc.initWithFrame([[0, 0], [80, 180]]) | |||
black_view.backgroundColor = UIColor.blackColor | |||
|
|||
bw_view = TypewriterView.alloc.initWithFrame([[]]) | |||
|
|||
[blue_view, red_view, green_cyan_combo, gray_view].each { |view| | |||
@typewriter.addSubview(view) | |||
} | |||
end | |||
|
|||
def shouldAutorotateToInterfaceOrientation(orientation) | |||
true | |||
end | |||
|
|||
def willAnimateRotationToInterfaceOrientation(orientation, duration:duration) | |||
bframe = @typewriter.frame | |||
w, h = bframe.size.width, bframe.size.height | |||
bframe.size = h, w | |||
@typewriter.frame = bframe | |||
@typewriter.setNeedsLayout | |||
end | |||
|
|||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,24 +1,60 @@ | |||
|
|
||
class BoxFloatView < UIView | class TypewriterView < UIView | ||
|
|
||
def apps | def initWithFrame(frame) | ||
@apps ||= [] | super | ||
frame = self.frame # frame could be [[], []] or a CGRect; normalize it. | |||
|
|||
layoutSubviews | |||
|
|||
self | |||
end | end | ||
|
|
||
##| | def frame=(new_frame) | ||
##| STYLES | super | ||
##| easily stylable using teacup | layoutSubviews | ||
##| * backgroundColor is already supported by UIView | end | ||
##| |
|
||
def clear | |||
@x = 0 | |||
@y = @max_height | |||
end | |||
|
|
||
##| | ##| | ||
##| DRAWING | ##| START AT 0, 0, AND START FLOATING | ||
##| | ##| | ||
def drawRect(rect) | def layoutSubviews | ||
super | @x = @y = 0 # the coordinates for the next frame | ||
@max_height = 0 # the max_height of *all* the rows so far (not just the current row) | |||
|
|||
frame = self.frame | |||
# the width, which is fixed. when a row would be longer than this, it is | |||
# wrapped to the next row. | |||
@fixed_width = frame.size.width | |||
|
|||
self.subviews.each do |view| | |||
add_next(view) | |||
end | |||
end | |||
|
|||
def add_next(view) | |||
# ignore the x, y of the added view, we only respect the size | |||
view_frame = view.frame | |||
|
|||
# new row? | |||
self.clear if @x + view_frame.size.width > @fixed_width | |||
|
|||
# new max_height? | |||
@max_height = @y + view_frame.size.height if @y + view_frame.size.height > @max_height | |||
|
|||
view_frame.origin.x = @x | |||
@x += view_frame.size.width | |||
view_frame.origin.y = @y | |||
|
|||
view.frame = view_frame | |||
end | end | ||
|
|
||
end | end | ||
|
|
||
module BoxFloatDelegate | module TypewriterDelegate | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,9 +1,46 @@ | |||
describe "Application 'boxfloat'" do | describe "Application 'typewriter'" do | ||
before do | before do | ||
@app = UIApplication.sharedApplication | @app = UIApplication.sharedApplication | ||
end | end | ||
|
|
||
it "has one window" do | it "has one window" do | ||
@app.windows.size.should == 1 | @app.windows.size.should == 1 | ||
end | end | ||
|
|||
it "has a rootViewController" do | |||
@app.windows[0].rootViewController.nil?.should != true | |||
end | |||
|
|||
it "has a subview, same as its rootViewController" do | |||
@app.windows[0].subviews.length.should == 1 | |||
|
|||
@app.windows[0].subviews[0].should == @app.windows[0].rootViewController.view | |||
end | |||
|
|||
it "has a TypewriterView" do | |||
typewriter = @app.windows[0].subviews[0].subviews[0] | |||
typewriter.class.name.should == "TypewriterView" | |||
end | |||
|
|||
describe "adding subviews to typewriter" do | |||
|
|||
before do | |||
@app = UIApplication.sharedApplication | |||
@typewriter = @app.windows[0].subviews[0].subviews[0] | |||
end | |||
|
|||
it "has a bunch of subviews" do | |||
@typewriter.subviews.length.should > 1 | |||
end | |||
|
|||
it "should not have overlapping subviews" do | |||
@typewriter.subviews.each { |subview| | |||
@typewriter.subviews.select {|v| v != subview }.each { |check| | |||
CGRectIntersectsRect(subview.frame, check.frame).should == false | |||
} | |||
} | |||
end | |||
|
|||
end | |||
|
|||
end | end |