Skip to content

Commit bb8459c

Browse files
committed
Made the combo box display its own arrow (icon at right side, indicating the menu can be opened).
1 parent 6bd0731 commit bb8459c

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

lib/fidgit/elements/combo_box.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def initialize(options = {}, &block)
5050
end
5151
end
5252

53+
@@arrow ||= Gosu::Image["combo_arrow.png"]
54+
5355
super('', options)
5456

5557
rect.height = [height, font_size + padding_top + padding_bottom].max
@@ -68,6 +70,12 @@ def item(text, value, options = {}, &block)
6870
item
6971
end
7072

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+
7179
def clicked_left_mouse_button(sender, x, y)
7280
@menu.x = self.x
7381
@menu.y = self.y + height + border_thickness
@@ -82,6 +90,15 @@ def clear
8290
@menu.clear
8391
end
8492

93+
protected
94+
def layout
95+
super
96+
rect.width + height # Allow size for the arrow.
97+
98+
nil
99+
end
100+
101+
85102
protected
86103
# Any combo-box passed a block will allow you access to its methods.
87104
def post_init_block(&block)

lib/fidgit/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# encoding: UTF-8
22

33
module Fidgit
4-
VERSION = '0.0.5alpha'
4+
VERSION = '0.0.6alpha'
55
end

media/images/combo_arrow.png

546 Bytes
Loading

0 commit comments

Comments
 (0)