-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:shoes/shoes4 into right_and_bottom
- Loading branch information
Showing
34 changed files
with
866 additions
and
326 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
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
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,37 @@ | ||
class Shoes | ||
class Link < Text | ||
def initialize texts, color=nil, &blk | ||
class Link < Span | ||
attr_reader :app, :parent, :gui | ||
|
||
DEFAULT_OPTS = { underline: true, fg: ::Shoes::COLORS[:blue] } | ||
|
||
def initialize(app, parent, texts, opts={}, &blk) | ||
@app = app | ||
@parent = parent | ||
setup_block(blk, opts) | ||
|
||
opts = DEFAULT_OPTS.merge(opts) | ||
@gui = Shoes.backend_for(self, opts) | ||
|
||
super texts, opts | ||
end | ||
|
||
def setup_block(blk, opts) | ||
if blk | ||
@blk = blk | ||
elsif opts.include?(:click) | ||
# Slightly awkward, but we need App, not InternalApp, to call visit | ||
@blk = Proc.new { app.app.visit(opts[:click]) } | ||
end | ||
end | ||
|
||
def click(&blk) | ||
@blk = blk | ||
super texts, color | ||
self | ||
end | ||
attr_reader :blk | ||
attr_accessor :click_listener, :line_height, :start_x, :start_y, | ||
:end_x, :end_y, :clickabled, | ||
:parent | ||
|
||
def in_bounds?(x, y) | ||
(start_x..end_x).include?(x) and (start_y..end_y).include?(y) | ||
def execute_link | ||
@blk.call | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Shoes | ||
class LinkHover | ||
# Just a placeholder for now until we get this implemented | ||
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
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Shoes | ||
module Mock | ||
class Link | ||
include Shoes::Mock::CommonMethods | ||
|
||
def initialize(dsl, app, opts = {}) | ||
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
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
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
class Shoes | ||
module Swt | ||
class Download | ||
|
||
|
||
attr_accessor :busy | ||
def initialize(_dsl) | ||
@busy = false | ||
end | ||
|
||
# This exists to guarantee the callback block for download completion | ||
# executes on the main UI thread. Without it we get thread access errors. | ||
def eval_block(result, blk) | ||
def eval_block(blk, result) | ||
::Swt.display.asyncExec do | ||
blk.call result | ||
@busy = false | ||
end | ||
end | ||
|
||
def busy? | ||
@busy | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.