forked from shoes/shoes4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Shoes::Swt::Color, refactor fill
- Loading branch information
1 parent
2d0df9c
commit e0effc4
Showing
6 changed files
with
41 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
module Shoes | ||
module Swt | ||
module Color | ||
def to_native | ||
::Swt::Graphics::Color.new(Shoes.display, @red, @green, @blue) | ||
class Color | ||
# @param [Shoes::Color] color the DSL representation of this color | ||
def initialize(color) | ||
@dsl = color | ||
@real = ::Swt::Graphics::Color.new(Shoes.display, @dsl.red, @dsl.green, @dsl.blue) | ||
@alpha = color.alpha | ||
end | ||
|
||
attr_reader :alpha, :dsl, :real | ||
|
||
def apply_as_background(gc) | ||
gc.set_background real | ||
gc.set_alpha alpha | ||
end | ||
|
||
# TODO: Remove | ||
def red; @real.red; end | ||
def green; @real.green; end | ||
def blue; @real.blue; end | ||
end | ||
end | ||
end | ||
|
||
module Shoes | ||
class Color | ||
include Shoes::Swt::Color | ||
def to_native | ||
::Shoes::Swt::Color.new(self) | ||
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