fidgit 0.0.4alpha → 0.0.5alpha

Sign up to get free protection for your applications and to get access to all the features.
@@ -101,6 +101,7 @@
101
101
  :height: ?scroll_bar_thickness
102
102
 
103
103
  :Label: # < Element
104
+ :justify: :left
104
105
  :disabled:
105
106
  :color: ?light_gray
106
107
 
@@ -11,6 +11,12 @@ class ExampleState < Fidgit::GuiState
11
11
  label '', icon: Gosu::Image["head_icon.png"], tip: 'A label with just icon'
12
12
  label '', background_color: Gosu::Color.rgb(0, 255, 0), tip: 'No text or icon'
13
13
  end
14
+
15
+ pack :vertical do
16
+ label ":left justification", width: 400, background_color: Gosu::Color.rgb(0, 100, 0), justify: :left, tip: 'A label with text'
17
+ label ":right justification", width: 400, background_color: Gosu::Color.rgb(0, 100, 0), justify: :right, tip: 'A label with text'
18
+ label ":center justification", width: 400, background_color: Gosu::Color.rgb(0, 100, 0), justify: :center, tip: 'A label with text'
19
+ end
14
20
  end
15
21
  end
16
22
 
@@ -10,7 +10,9 @@ class ComboBox < Button
10
10
  def value=(value)
11
11
  if @value != value
12
12
  @value = value
13
- @text = @menu.find(@value).text
13
+ item = @menu.find(@value)
14
+ self.text = item.text
15
+ self.icon = item.icon
14
16
  publish :changed, @value
15
17
  end
16
18
 
@@ -5,6 +5,8 @@ module Fidgit
5
5
  attr_accessor :color, :background_color, :border_color
6
6
  attr_reader :text, :icon
7
7
 
8
+ VALID_JUSTIFICATION = [:left, :right, :center]
9
+
8
10
  def text=(value)
9
11
  @text = value
10
12
  recalc
@@ -22,9 +24,11 @@ module Fidgit
22
24
  #
23
25
  # @option (see Element#initialize)
24
26
  # @option options [Fidgit::Thumbnail, Gosu::Image, nil] :icon (nil)
27
+ # @option options [:left, :right, :center] :justify (:left) Text justification.
25
28
  def initialize(text, options = {})
26
29
  options = {
27
30
  color: default(:color),
31
+ justify: default(:justify),
28
32
  background_color: default(:background_color),
29
33
  border_color: default(:border_color),
30
34
  }.merge! options
@@ -33,6 +37,9 @@ module Fidgit
33
37
  @icon = options[:icon]
34
38
  @color = options[:color].dup
35
39
 
40
+ raise "Justification must be one of #{VALID_JUSTIFICATION.inspect}" unless VALID_JUSTIFICATION.include? options[:justify]
41
+ @justify = options[:justify]
42
+
36
43
  super(options)
37
44
  end
38
45
 
@@ -44,7 +51,21 @@ module Fidgit
44
51
  end
45
52
 
46
53
  unless @text.empty?
47
- font.draw(@text, current_x, y + padding_top, z, 1, 1, @color)
54
+ case @justify
55
+ when :left
56
+ rel_x = 0.0
57
+ center_x = current_x
58
+
59
+ when :right
60
+ rel_x = 1.0
61
+ center_x = x + rect.width - padding_right
62
+
63
+ when :center
64
+ rel_x = 0.5
65
+ center_x = (current_x + x + rect.width - padding_right) / 2.0
66
+ end
67
+
68
+ font.draw_rel(@text, center_x, y + padding_top, z, rel_x, 0, 1, 1, @color)
48
69
  end
49
70
 
50
71
  nil
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Fidgit
4
- VERSION = '0.0.4alpha'
4
+ VERSION = '0.0.5alpha'
5
5
  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.4alpha
4
+ version: 0.0.5alpha
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-03-23 00:00:00.000000000 +00:00
12
+ date: 2011-03-25 00:00:00.000000000 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: gosu
17
- requirement: &26488260 !ruby/object:Gem::Requirement
17
+ requirement: &26622144 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.7.28
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *26488260
25
+ version_requirements: *26622144
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: chingu
28
- requirement: &26479692 !ruby/object:Gem::Requirement
28
+ requirement: &26621748 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.9rc4
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *26479692
36
+ version_requirements: *26621748
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rspec
39
- requirement: &26479404 !ruby/object:Gem::Requirement
39
+ requirement: &26621364 !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: *26479404
47
+ version_requirements: *26621364
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: texplay
50
- requirement: &26479128 !ruby/object:Gem::Requirement
50
+ requirement: &26621016 !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: *26479128
58
+ version_requirements: *26621016
59
59
  description: Fidgit is a GUI library built on Gosu/Chingu
60
60
  email:
61
61
  - bil.bagpuss@gmail.com