subtle-dynamic_icon 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +29 -0
- data/README +4 -0
- data/lib/subtle/dominikh/dynamic_icon.rb +48 -0
- data/test/setup.rb +2 -0
- metadata +61 -0
data/LICENSE
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Copyright (c) 2010, Dominik Honnef <dominikho@gmx.net>
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are
|
6
|
+
met:
|
7
|
+
|
8
|
+
- Redistributions of source code must retain the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
10
|
+
|
11
|
+
- Redistributions in binary form must reproduce the above copyright
|
12
|
+
notice, this list of conditions and the following disclaimer in the
|
13
|
+
documentation and/or other materials provided with the distribution.
|
14
|
+
|
15
|
+
- Neither the name of the author nor the names of the
|
16
|
+
contributors may be used to endorse or promote products derived from
|
17
|
+
this software without specific prior written permission.
|
18
|
+
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "subtle/subtlext"
|
2
|
+
module Dominikh
|
3
|
+
# @abstract Subclass and override {#render} to implement a dynamic
|
4
|
+
# icon, e.g. a graph.
|
5
|
+
# @see http://rdoc.subforge.org/subtle/classes/Subtlext/Icon.html
|
6
|
+
class DynamicIcon < Subtlext::Icon
|
7
|
+
attr_reader :color
|
8
|
+
|
9
|
+
def initialize(width, height)
|
10
|
+
super(width, height)
|
11
|
+
@color = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def color=(val)
|
15
|
+
case val
|
16
|
+
when Subtlext::Color
|
17
|
+
@color = val
|
18
|
+
when NilClass
|
19
|
+
@color = nil
|
20
|
+
else
|
21
|
+
@color = Subtlext::Color.new(val.to_s)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# return [String]
|
26
|
+
def to_str
|
27
|
+
s = super
|
28
|
+
if color
|
29
|
+
return color + s + Subtlext::Color.new(::COLORS[:fg_sublets])
|
30
|
+
else
|
31
|
+
return s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
alias_method :to_s, :to_str
|
35
|
+
|
36
|
+
def +(other)
|
37
|
+
self.to_s + other
|
38
|
+
end
|
39
|
+
|
40
|
+
# Draws the icon. Redefine this in subclasses to define custom
|
41
|
+
# drawing routines.
|
42
|
+
#
|
43
|
+
# @return [void]
|
44
|
+
def render
|
45
|
+
clear
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/test/setup.rb
ADDED
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: subtle-dynamic_icon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dominik Honnef
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-04-15 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: DynamicIcon is a small abstractional layer around Subtlext::Icon, with integrated support for colors and custom drawing routines. The main purpose of this gem is to be used as a foundation for more sophisticated icons like graphs.
|
17
|
+
email: dominikho@gmx.net
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/subtle
|
26
|
+
- lib/subtle/dominikh
|
27
|
+
- lib/subtle/dominikh/dynamic_icon.rb
|
28
|
+
- test/suite
|
29
|
+
- test/suite/lib
|
30
|
+
- test/fixtures
|
31
|
+
- test/setup.rb
|
32
|
+
- README
|
33
|
+
- LICENSE
|
34
|
+
has_rdoc: yard
|
35
|
+
homepage: ""
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.9.1
|
46
|
+
version:
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
requirements: []
|
54
|
+
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.3.1
|
57
|
+
signing_key:
|
58
|
+
specification_version: 2
|
59
|
+
summary: A small abstractional layer around Subtlext::Icon, featuring integrated support for colors and custom drawing routines.
|
60
|
+
test_files: []
|
61
|
+
|