fidgit 0.0.5alpha → 0.0.6alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/config/default_schema.yml +1 -1
- data/fidgit.gemspec +2 -2
- data/lib/fidgit/elements/combo_box.rb +30 -9
- data/lib/fidgit/elements/container.rb +23 -13
- data/lib/fidgit/elements/element.rb +14 -0
- data/lib/fidgit/elements/menu_pane.rb +6 -2
- data/lib/fidgit/elements/scroll_area.rb +1 -8
- data/lib/fidgit/elements/scroll_window.rb +1 -8
- data/lib/fidgit/elements/text_area.rb +1 -1
- data/lib/fidgit/states/gui_state.rb +4 -0
- data/lib/fidgit/version.rb +1 -1
- data/media/images/combo_arrow.png +0 -0
- data/spec/fidgit/history_spec.rb +14 -14
- metadata +13 -12
data/config/default_schema.yml
CHANGED
data/fidgit.gemspec
CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
|
-
s.add_dependency('gosu', '~> 0.7.
|
25
|
-
s.add_dependency('chingu', '~> 0.
|
24
|
+
s.add_dependency('gosu', '~> 0.7.32')
|
25
|
+
s.add_dependency('chingu', '~> 0.9rc5')
|
26
26
|
s.add_development_dependency('rspec', '~> 2.1.0')
|
27
27
|
s.add_development_dependency('texplay', '~> 0.3.5')
|
28
28
|
end
|
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Fidgit
|
4
4
|
class ComboBox < Button
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def_delegators :@menu, :each
|
8
|
+
|
5
9
|
event :changed
|
6
10
|
|
7
11
|
def index; @menu.index(@value) end
|
@@ -46,6 +50,8 @@ class ComboBox < Button
|
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
53
|
+
@@arrow ||= Gosu::Image["combo_arrow.png"]
|
54
|
+
|
49
55
|
super('', options)
|
50
56
|
|
51
57
|
rect.height = [height, font_size + padding_top + padding_bottom].max
|
@@ -57,12 +63,19 @@ class ComboBox < Button
|
|
57
63
|
|
58
64
|
# Force text to be updated if the item added has the same value.
|
59
65
|
if item.value == @value
|
60
|
-
|
66
|
+
self.text = item.text
|
67
|
+
self.icon = item.icon
|
61
68
|
end
|
62
69
|
|
63
70
|
item
|
64
71
|
end
|
65
72
|
|
73
|
+
def draw
|
74
|
+
super
|
75
|
+
size = height / @@arrow.width.to_f
|
76
|
+
@@arrow.draw x + width - height, y, z, size, size
|
77
|
+
end
|
78
|
+
|
66
79
|
def clicked_left_mouse_button(sender, x, y)
|
67
80
|
@menu.x = self.x
|
68
81
|
@menu.y = self.y + height + border_thickness
|
@@ -71,17 +84,25 @@ class ComboBox < Button
|
|
71
84
|
nil
|
72
85
|
end
|
73
86
|
|
87
|
+
def clear
|
88
|
+
self.text = ""
|
89
|
+
self.icon = nil
|
90
|
+
@menu.clear
|
91
|
+
end
|
92
|
+
|
93
|
+
protected
|
94
|
+
def layout
|
95
|
+
super
|
96
|
+
rect.width + height # Allow size for the arrow.
|
97
|
+
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
|
101
|
+
|
74
102
|
protected
|
75
103
|
# Any combo-box passed a block will allow you access to its methods.
|
76
104
|
def post_init_block(&block)
|
77
|
-
|
78
|
-
when 1
|
79
|
-
yield self
|
80
|
-
when 0
|
81
|
-
instance_methods_eval &block
|
82
|
-
else
|
83
|
-
raise "block arity must be 0 or 1"
|
84
|
-
end
|
105
|
+
with(&block)
|
85
106
|
end
|
86
107
|
end
|
87
108
|
end
|
@@ -4,11 +4,9 @@ module Fidgit
|
|
4
4
|
# A container that contains Elements.
|
5
5
|
# @abstract
|
6
6
|
class Container < Element
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def index(value); @children.index value; end
|
11
|
-
def [](index); @children[index]; end
|
7
|
+
extend Forwardable
|
8
|
+
|
9
|
+
def_delegators :@children, :size, :each, :find, :index, :[]
|
12
10
|
|
13
11
|
def x=(value)
|
14
12
|
each {|c| c.x += value - x }
|
@@ -91,6 +89,7 @@ module Fidgit
|
|
91
89
|
List.new({parent: self}.merge!(options), &block)
|
92
90
|
end
|
93
91
|
|
92
|
+
# Deprecated: use horizontal/vertical/grid
|
94
93
|
def pack(arrangement, options = {}, &block)
|
95
94
|
klass = case arrangement
|
96
95
|
when :horizontal
|
@@ -106,6 +105,24 @@ module Fidgit
|
|
106
105
|
klass.new({parent: self}.merge!(options), &block)
|
107
106
|
end
|
108
107
|
|
108
|
+
public
|
109
|
+
# Pack elements within the block horizontally.
|
110
|
+
def horizontal(options = {}, &block)
|
111
|
+
HorizontalPacker.new({ parent: self }.merge!(options), &block)
|
112
|
+
end
|
113
|
+
|
114
|
+
public
|
115
|
+
# Pack elements within the blockvertically.
|
116
|
+
def vertical(options = {}, &block)
|
117
|
+
VerticalPacker.new({ parent: self }.merge!(options), &block)
|
118
|
+
end
|
119
|
+
|
120
|
+
public
|
121
|
+
# Pack elements within the block in a grid (matrix) formation.
|
122
|
+
def grid(options = {}, &block)
|
123
|
+
GridPacker.new({ parent: self }.merge!(options), &block)
|
124
|
+
end
|
125
|
+
|
109
126
|
def radio_button(text, value, options = {}, &block)
|
110
127
|
RadioButton.new(text, value, {parent: self}.merge!(options), &block)
|
111
128
|
end
|
@@ -174,14 +191,7 @@ module Fidgit
|
|
174
191
|
protected
|
175
192
|
# Any container passed a block will allow you access to its methods.
|
176
193
|
def post_init_block(&block)
|
177
|
-
|
178
|
-
when 1
|
179
|
-
yield self
|
180
|
-
when 0
|
181
|
-
instance_methods_eval &block
|
182
|
-
else
|
183
|
-
raise "block arity must be 0 or 1"
|
184
|
-
end
|
194
|
+
with(&block)
|
185
195
|
end
|
186
196
|
end
|
187
197
|
end
|
@@ -248,6 +248,20 @@ module Fidgit
|
|
248
248
|
@parent.send :add, self if @parent
|
249
249
|
end
|
250
250
|
|
251
|
+
public
|
252
|
+
# Evaluate a block, just like it was a constructor block.
|
253
|
+
def with(&block)
|
254
|
+
raise ArgumentError.new("Must pass a block") unless block_given?
|
255
|
+
case block.arity
|
256
|
+
when 1
|
257
|
+
yield self
|
258
|
+
when 0
|
259
|
+
instance_methods_eval &block
|
260
|
+
else
|
261
|
+
raise "block arity must be 0 or 1"
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
251
265
|
protected
|
252
266
|
# By default, elements do not accept block arguments.
|
253
267
|
def post_init_block(&block)
|
@@ -57,11 +57,15 @@ module Fidgit
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
# -------------------
|
61
|
+
|
62
|
+
extend Forwardable
|
63
|
+
|
64
|
+
def_delegators :@items, :each, :clear, :size, :[]
|
65
|
+
|
60
66
|
event :selected
|
61
67
|
|
62
68
|
def index(value); @items.index find(value); end
|
63
|
-
def size; @items.size; end
|
64
|
-
def [](index); @items[index]; end
|
65
69
|
|
66
70
|
# @option (see Composite#initialize)
|
67
71
|
# @option options [Float] :x (cursor x, if in a GuiState)
|
@@ -62,14 +62,7 @@ module Fidgit
|
|
62
62
|
|
63
63
|
protected
|
64
64
|
def post_init_block(&block)
|
65
|
-
|
66
|
-
when 1
|
67
|
-
yield @content
|
68
|
-
when 0
|
69
|
-
@content.instance_methods_eval &block
|
70
|
-
else
|
71
|
-
raise "block arity must be 0 or 1"
|
72
|
-
end
|
65
|
+
with(&block)
|
73
66
|
end
|
74
67
|
end
|
75
68
|
end
|
@@ -79,14 +79,7 @@ module Fidgit
|
|
79
79
|
|
80
80
|
protected
|
81
81
|
def post_init_block(&block)
|
82
|
-
|
83
|
-
when 1
|
84
|
-
yield @view.content
|
85
|
-
when 0
|
86
|
-
@view.content.instance_methods_eval &block
|
87
|
-
else
|
88
|
-
raise "block arity must be 0 or 1"
|
89
|
-
end
|
82
|
+
@view.content.with(&block)
|
90
83
|
end
|
91
84
|
end
|
92
85
|
end
|
@@ -251,7 +251,7 @@ module Fidgit
|
|
251
251
|
word_width = 0
|
252
252
|
|
253
253
|
text.each_char do |char|
|
254
|
-
char_width = font.text_width(char)
|
254
|
+
char_width = (char == "\n") ? 0 : font.text_width(char)
|
255
255
|
|
256
256
|
overall_width = line_width + (line_width == 0 ? 0 : space_width) + word_width + char_width
|
257
257
|
if overall_width > max_width and not (char == ' ' and not word.empty?)
|
@@ -5,6 +5,10 @@ module Fidgit
|
|
5
5
|
# A 1x1 white pixel used for drawing.
|
6
6
|
PIXEL_IMAGE = 'pixel.png'
|
7
7
|
|
8
|
+
extend Forwardable
|
9
|
+
|
10
|
+
def_delegators :@container, :horizontal, :vertical, :grid
|
11
|
+
|
8
12
|
# The Container that contains all the elements for this GuiState.
|
9
13
|
# @return [Packer]
|
10
14
|
attr_reader :container
|
data/lib/fidgit/version.rb
CHANGED
Binary file
|
data/spec/fidgit/history_spec.rb
CHANGED
@@ -121,23 +121,23 @@ module Fidgit
|
|
121
121
|
$x.should == 7
|
122
122
|
end
|
123
123
|
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Abstract class, so doesn't really do anything.
|
127
|
+
describe History::Action do
|
128
|
+
before :each do
|
129
|
+
@object = described_class.new
|
130
|
+
end
|
124
131
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
@object = described_class.new
|
129
|
-
end
|
130
|
-
|
131
|
-
describe "do()" do
|
132
|
-
it "should raise an error" do
|
133
|
-
lambda { @object.do }.should raise_error NotImplementedError
|
134
|
-
end
|
132
|
+
describe "do()" do
|
133
|
+
it "should raise an error" do
|
134
|
+
lambda { @object.do }.should raise_error NotImplementedError
|
135
135
|
end
|
136
|
+
end
|
136
137
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
end
|
138
|
+
describe "undo()" do
|
139
|
+
it "should raise an error" do
|
140
|
+
lambda { @object.undo }.should raise_error NotImplementedError
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fidgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6alpha
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,34 +9,34 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-06-06 00:00:00.000000000 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: gosu
|
17
|
-
requirement: &
|
17
|
+
requirement: &26037252 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.7.
|
22
|
+
version: 0.7.32
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *26037252
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: chingu
|
28
|
-
requirement: &
|
28
|
+
requirement: &26036940 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.9rc5
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *26036940
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rspec
|
39
|
-
requirement: &
|
39
|
+
requirement: &26036652 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 2.1.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *26036652
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: texplay
|
50
|
-
requirement: &
|
50
|
+
requirement: &26036364 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
version: 0.3.5
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *26036364
|
59
59
|
description: Fidgit is a GUI library built on Gosu/Chingu
|
60
60
|
email:
|
61
61
|
- bil.bagpuss@gmail.com
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- lib/fidgit/version.rb
|
135
135
|
- lib/fidgit/window.rb
|
136
136
|
- media/images/arrow.png
|
137
|
+
- media/images/combo_arrow.png
|
137
138
|
- media/images/file_directory.png
|
138
139
|
- media/images/file_file.png
|
139
140
|
- media/images/pixel.png
|