Skip to content
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

Would it be possible to add an example for the callback use of a color_button, into the libui gem examples? #34

Open
rubyFeedback opened this issue Oct 5, 2021 · 1 comment

Comments

@rubyFeedback
Copy link
Collaborator

Hey there kojix2 (and everyone else handling libui-related code in ruby),

I noticed Andy did a LOT of work in regards to glimmer-libui in the
last 2 or 3 weeks or so. I am watching his changes for inspirational
ideas! Pretty amazing what he did with glimmer. I am trying to
convince him to add ruby-gtk AND gosu to the stack ... but time is
limited I guess so ... anyway. :D

As another example in regards to glimmer-libui, Andy already has almost
40 (!) example files added so far. That's a LOT. He is super-fast when it
comes to writing code. I ported the form example he gave already - pretty
cool. I did not even have that idea. (e. g. user login name form, as an
example, that's pretty useful as a "building block" ...imagine a full
widget series for a desktop-like variant!).

Anyway.

I also noticed, somewhat randomly, that I don't (yet) have a working example
for a color-button in my own dsl-like gem (or wanna-be DSL).

The code Andy wrote in this regard is as follows (copy/paste incoming
but it is super-easy to understand):


require 'glimmer-dsl-libui'

include Glimmer

window('color button', 230) {
  color_button { |cb|
    on_changed do
      rgba = cb.color
      p rgba
    end
  }
}.show

Which is quite cool - that's a proper DSL. My DSL is not
yet anywhere near as advanced; for instance I don't handle
blocks as Andy does in glimmer, so glimmer is better in
this regard.

I tried to reproduce his code, however had, I managed to trip
myself up here. Pointers and procs mess with my head.

I tried to get this variant to work:

LibUI.color_button_on_changed

and "tap" into the pointer such as via:

rgba = cb.color

as Andy does, but I was unable to do so. I seem to only
deal with raw Fiddle::Pointers, so right now I am confused
how Andy managed to get .color method to work (I may
have passed the wrong thing into the callback ...)

If you have the time available, perhaps at some future
weekend, would it be possible to add one example for:

color_button

into the libui gem as-is?

It should not be too much code; I mostly want to see what
I did wrong, because I can not seem to get a "cb.color"
variant to work. Perhaps I just got dumber in the last weeks.

So, a minimal example for "color_button" would be helpful.

As always thank you for reading and potentially considering.

PS: I realized some time ago that I may have to rewrite
my own gem eventually; with Andy pushing the limit I will
also have to extend the DSL-like features, such as:

window {
}

which works for glimmer-libui but not for my variant.

So Andy is going into new frontiers here. I also noticed the
github entry you created, but I have not yet worked through
it. I'll eventually get to it, but I first want to add more examples, screenshots
and so forth, more documentation, more examples and so forth. Then I
am going to rewrite the current code I use; my code base is a bit messy in
its current form right now and I already noticed a few bugs (and fixed a few
of them, but more exist), but some of the examples I have aren't working
as-is; I break too many things. So I have to fix that at a later time as well.

I am investing more time into ruby-gtk3 right now, mostly as that is my "main"
area to explore GUIs, and I have about ~9000 lines of old documentation
from my ruby-gtk2 days that I still have to port into my gtk-related gem.
Just to explain a bit how I have to distribute my time (and that's just
programming-related; reallife isn't all about programming only of course :D;
anyway enough random babbling from me here!).

@AndyObtiva
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants