-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider adding the speed option to colour-the-circles .rb example #44
Comments
I’m watching a baseball game at Fenway Park right now, so I’ll send a more detailed response later. But, I just wanted to note that this is just a sample, and I think the levels of difficulty it offers are good enough as variations. I don’t think changing the speed is important because adding more circles already forces the player to operate at a higher speed, so it’s almost the same thing, and is sufficient as such. You are welcome to build your own standalone project though and add it on GitHub. You can also let me know here if you do so. As for tooltips, you can add some inside an area control. For regular controls, that’s not supported in LibUI yet, but is in SWT. Later. |
OK, I opened an issue at the libui-ng project to support tooltips given that they are missing from it: Otherwise, in Glimmer DSL for SWT if you are willing to use it instead, it is very simple to add tooltips to any controls using require 'glimmer-dsl-swt'
class HelloButton
include Glimmer::UI::CustomShell
attr_accessor :count
before_body do
self.count = 0
end
body {
shell {
text 'Hello, Button!'
button {
text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
tool_tip_text 'Clicking this button increments the button count.'
on_widget_selected do
self.count += 1
end
}
}
}
end
HelloButton.launch I am keeping this issue open until libui-ng supports tooltips and they are included in Glimmer DSL for LibUI. |
I also mentioned you could already add a tooltip in Glimmer DSL for LibUI when using the Here is an example of how to do it (you can fine tune it by adding a time delay if you like): require 'glimmer-dsl-libui'
include Glimmer
window('Basic Area', 400, 400) {
margined true
vertical_box {
area { |area_proxy|
rectangle(0, 0, 400, 400) { # stable implicit path shape, added declaratively
fill r: 102, g: 102, b: 204, a: 1.0
on_mouse_moved do |area_mouse_event|
@last_move_time = Time.now
if @tooltip_rectangle || @tooltip_text
@tooltip_rectangle&.destroy
@tooltip_text&.destroy
area_proxy.queue_redraw_all
end
area_proxy.content {
@tooltip_rectangle = rectangle(area_mouse_event[:x], area_mouse_event[:y], 100, 100) {
fill r: 0, g: 255, b: 255, a: 1.0
}
@tooltip_text = text(area_mouse_event[:x] + 20, area_mouse_event[:y] + 20, 60) { # declarative stable text
string('This is a tooltip!') {
font family: 'Arial', size: (OS.mac? ? 14 : 11)
color :black
}
}
}
Glimmer::LibUI.timer(3, repeat: false) do
# ensure not to close tooltip if the user moves the mouse again
# by comparing time to last move time
if Time.now - @last_move_time >= 3
@tooltip_rectangle&.destroy
@tooltip_text&.destroy
area_proxy.queue_redraw_all
end
end
end
}
}
}
}.show The tooltip will follow the mouse cursor, and will disappear after 3 seconds of no mouse movement. |
Colour the circles example allows us to click on a circle and colour fill it.
We can also designate the difficulty.
Would it be possible to also be able to set the speed, that is, how quickly
a circle appears? If you want to retain hardcoded values for the difficulty
then that is fine, so I am more proposing a separate "free-form variant"
where we can say "speed at 5 new circles in 3 seconds" or something
like that (e. g. the ratio of that).
Not sure where to set this, probably from the menu it makes the most
sense, e. g. next to the difficulty slider, or in the same area.
Can we use tooltips in libui? Probably not, but I think tooltips would be
quite convenient to quickly explain the options.
The example code I used was from here:
https://raw.githubusercontent.com/AndyObtiva/glimmer-dsl-libui/master/examples/color_the_circles.rb
At any rate, please feel free to proceed with the issue reques tin any
way you see fit. Glimmer on!
PS: I am working through all glimmer examples right now, slowly. First
on linux, then I want to test it on windows - the latter is a very nifty
use case for ruby users. On linux I can use ruby-gtk3 directly, so this
is interesting how it works on windows.
The text was updated successfully, but these errors were encountered: