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

slider control not documented and enhancement #88

Closed
passenger94 opened this Issue Mar 23, 2015 · 10 comments

Comments

Projects
None yet
2 participants
@passenger94
Contributor

passenger94 commented Mar 23, 2015

slider control exists but not documented (with fraction and fraction= methods)
i made a pull request with enhancement : ability to initialize a slider control with :fraction style attribute (same name as existing method, could be changed to value for example), works for me on linux - ubuntu.
A test app

Shoes.app do
    stack do
        @p = para ""
        slider fraction: 0.5 do |sl|
            @p.text = "changed : #{sl.fraction}"
        end
    end
end

slider01

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Mar 24, 2015

Contributor

Slider has a method 'change' that isn't in the progress widget - what does it do? does it work?

Contributor

ccoupe commented Mar 24, 2015

Slider has a method 'change' that isn't in the progress widget - what does it do? does it work?

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Mar 24, 2015

Contributor

It looks like that method was initially planned to be used for the block given to the slider method with shoes_control_change which points to nowhere ...
now it's a change attribute :

g_signal_connect(G_OBJECT(ref), "value-changed",
                   G_CALLBACK(shoes_widget_changed), (gpointer)self);
shoes_widget_changed(GtkWidget *ref, gpointer data)
{ 
  VALUE self = (VALUE)data;
  shoes_control_send(self, s_change);
}

s_change is the :change symbol
block given to slider as a procedure in the :change attribute

shoes_canvas_slider(int argc, VALUE *argv, VALUE self)
{
  rb_arg_list args;
  VALUE slider;
  SETUP();

  rb_parse_args(argc, argv, "|h&", &args);

  if (!NIL_P(args.a[1]))
    ATTRSET(args.a[0], change, args.a[1]);    //  <---here

  slider = shoes_control_new(cSlider, args.a[0], self);
  shoes_add_ele(canvas, slider);
  return slider;
}

used also with edit_line, edit_box, list_box

I commented the line with the ruby declaration method in ruby.c and it works fine without it !
we might comment/remove it

Edit :
commented all the occurrences of rb_define_method( "change",) in ruby.c (edit_line, edit_box, list_box, slider) and everything works for me without them !

Contributor

passenger94 commented Mar 24, 2015

It looks like that method was initially planned to be used for the block given to the slider method with shoes_control_change which points to nowhere ...
now it's a change attribute :

g_signal_connect(G_OBJECT(ref), "value-changed",
                   G_CALLBACK(shoes_widget_changed), (gpointer)self);
shoes_widget_changed(GtkWidget *ref, gpointer data)
{ 
  VALUE self = (VALUE)data;
  shoes_control_send(self, s_change);
}

s_change is the :change symbol
block given to slider as a procedure in the :change attribute

shoes_canvas_slider(int argc, VALUE *argv, VALUE self)
{
  rb_arg_list args;
  VALUE slider;
  SETUP();

  rb_parse_args(argc, argv, "|h&", &args);

  if (!NIL_P(args.a[1]))
    ATTRSET(args.a[0], change, args.a[1]);    //  <---here

  slider = shoes_control_new(cSlider, args.a[0], self);
  shoes_add_ele(canvas, slider);
  return slider;
}

used also with edit_line, edit_box, list_box

I commented the line with the ruby declaration method in ruby.c and it works fine without it !
we might comment/remove it

Edit :
commented all the occurrences of rb_define_method( "change",) in ruby.c (edit_line, edit_box, list_box, slider) and everything works for me without them !

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Mar 24, 2015

Contributor

Does it work on windows, osx ?
if so i could update the manual
state style and method works for me

Shoes.app do
    stack do
        @p = para ""
        @sl = slider fraction: 0.5, state: "disabled" do |sl|
            @p.text = "changed : #{sl.fraction}"
        end
        button "switch slider state" do
            @sl.state = @sl.state == "disabled" ? nil : "disabled"
        end
    end
end
Contributor

passenger94 commented Mar 24, 2015

Does it work on windows, osx ?
if so i could update the manual
state style and method works for me

Shoes.app do
    stack do
        @p = para ""
        @sl = slider fraction: 0.5, state: "disabled" do |sl|
            @p.text = "changed : #{sl.fraction}"
        end
        button "switch slider state" do
            @sl.state = @sl.state == "disabled" ? nil : "disabled"
        end
    end
end

@ccoupe ccoupe added this to the 3.2.22 milestone Mar 24, 2015

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Mar 24, 2015

Contributor

Your example works well on OSX, Windows and Ubuntu 14.04. Please do update the manual.

Contributor

ccoupe commented Mar 24, 2015

Your example works well on OSX, Windows and Ubuntu 14.04. Please do update the manual.

@passenger94 passenger94 self-assigned this Mar 24, 2015

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Mar 24, 2015

Contributor

ok will try to do it asap, not sure i can do it until 2/3 days from now, feel free to build something if in a hurry for the release !
shall we keep the change methods commented in ruby.c, maybe removed ?

Contributor

passenger94 commented Mar 24, 2015

ok will try to do it asap, not sure i can do it until 2/3 days from now, feel free to build something if in a hurry for the release !
shall we keep the change methods commented in ruby.c, maybe removed ?

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Mar 25, 2015

Contributor

Believe me: my release schedules are flexible. The last one took a week from saying 'we ought to' to getting it done. I don't mind having commented code. It helps remember what didn't work or was there. Of course we need to clean it up after a few months or as part of a general clean up.

Contributor

ccoupe commented Mar 25, 2015

Believe me: my release schedules are flexible. The last one took a week from saying 'we ought to' to getting it done. I don't mind having commented code. It helps remember what didn't work or was there. Of course we need to clean it up after a few months or as part of a general clean up.

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Mar 25, 2015

Contributor

here's a draft

== Slider ==

Sliders allows you to adjust a value, from 0.0 to 1.0, thanks to the handle that can be moved with the mouse or by using the arrow keys. !{:margin_left => 100}man-ele-slider.png!

here's a sample showing you a slider in action :

{{{
 #!ruby
Shoes.app do
    stack margin: 10 do
        flow do
            @sl = slider fraction: 0.35, state: nil do |sd|
                @p.text = "value : #{sd.fraction}"
            end
            @p = para "", margin_left: 10
        end
        button "switch slider state" do
            @sl.state = (@sl.state == "disabled" ? nil : "disabled")
        end
    end
end 
}}}

For more methods beyond those listed below, also look into the [[Common]]
methods page. Because you get those methods on every slider as well.

=== fraction() » a decimal number ===

Returns a decimal number from 0.0 to 1.0, depending on how far along the slider bar we are.

=== fraction = a decimal number ===

Sets the slider to a decimal number between 0.0 and 1.0.

=== state » a string ===

See [[Styles.state]] style for details.

=== state = nil, "disabled" or "readonly" ===

See [[Styles.state]] style for details.

we shall replace the image with a screencap taken in Windows for consistency

manualslider

Contributor

passenger94 commented Mar 25, 2015

here's a draft

== Slider ==

Sliders allows you to adjust a value, from 0.0 to 1.0, thanks to the handle that can be moved with the mouse or by using the arrow keys. !{:margin_left => 100}man-ele-slider.png!

here's a sample showing you a slider in action :

{{{
 #!ruby
Shoes.app do
    stack margin: 10 do
        flow do
            @sl = slider fraction: 0.35, state: nil do |sd|
                @p.text = "value : #{sd.fraction}"
            end
            @p = para "", margin_left: 10
        end
        button "switch slider state" do
            @sl.state = (@sl.state == "disabled" ? nil : "disabled")
        end
    end
end 
}}}

For more methods beyond those listed below, also look into the [[Common]]
methods page. Because you get those methods on every slider as well.

=== fraction() » a decimal number ===

Returns a decimal number from 0.0 to 1.0, depending on how far along the slider bar we are.

=== fraction = a decimal number ===

Sets the slider to a decimal number between 0.0 and 1.0.

=== state » a string ===

See [[Styles.state]] style for details.

=== state = nil, "disabled" or "readonly" ===

See [[Styles.state]] style for details.

we shall replace the image with a screencap taken in Windows for consistency

manualslider

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Mar 25, 2015

Contributor

side note : we could add further enhancement to slider easily, the ability to choose directly the range of the slider and control the step

shoes_native_slider(VALUE self, shoes_canvas *canvas, shoes_place *place, VALUE attr, char *msg)
{
    double start = 0.0;
    double end = 1.0;
    double gap = 0.01;
    if (RTEST(ATTR(attr, startpoint))) start = NUM2DBL(ATTR(attr, startpoint));
    if (RTEST(ATTR(attr, endpoint))) end = NUM2DBL(ATTR(attr, endpoint));
    if (RTEST(ATTR(attr, step))) gap = NUM2DBL(ATTR(attr, step));
#ifdef GTK3
  SHOES_CONTROL_REF ref = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, start, end, gap);
#else
  SHOES_CONTROL_REF ref = gtk_hscale_new_with_range(start, end, gap);
#endif

and some changes in ruby.c and ruby.h (symbols needs to be created)
works on linux (cocoa needs to be done), if you're interested i open a new issue for this (3.2.23 milestone ?)

Contributor

passenger94 commented Mar 25, 2015

side note : we could add further enhancement to slider easily, the ability to choose directly the range of the slider and control the step

shoes_native_slider(VALUE self, shoes_canvas *canvas, shoes_place *place, VALUE attr, char *msg)
{
    double start = 0.0;
    double end = 1.0;
    double gap = 0.01;
    if (RTEST(ATTR(attr, startpoint))) start = NUM2DBL(ATTR(attr, startpoint));
    if (RTEST(ATTR(attr, endpoint))) end = NUM2DBL(ATTR(attr, endpoint));
    if (RTEST(ATTR(attr, step))) gap = NUM2DBL(ATTR(attr, step));
#ifdef GTK3
  SHOES_CONTROL_REF ref = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, start, end, gap);
#else
  SHOES_CONTROL_REF ref = gtk_hscale_new_with_range(start, end, gap);
#endif

and some changes in ruby.c and ruby.h (symbols needs to be created)
works on linux (cocoa needs to be done), if you're interested i open a new issue for this (3.2.23 milestone ?)

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Mar 25, 2015

Contributor

File an issue for anything you like. The worst that will happen is it won't get done promptly. @passenger94 , do you have good Gtk skills? The Gkt3 code almost works - except for computing the clip region which was the big change from gtk2 to gtk3. It was more difficult than I could figure out. That's an example of a issue that needs be filed even if no one wants to work on it.

Contributor

ccoupe commented Mar 25, 2015

File an issue for anything you like. The worst that will happen is it won't get done promptly. @passenger94 , do you have good Gtk skills? The Gkt3 code almost works - except for computing the clip region which was the big change from gtk2 to gtk3. It was more difficult than I could figure out. That's an example of a issue that needs be filed even if no one wants to work on it.

@ccoupe ccoupe closed this Mar 27, 2015

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Mar 29, 2015

Contributor

i'll look into this and try to figure out if it's in my capacity ...

Contributor

passenger94 commented Mar 29, 2015

i'll look into this and try to figure out if it's in my capacity ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment