I'd like to know where exactly is scrollbar buttons' appearance defined?

48 katselukertaa
Siirry ensimmäiseen lukemattomaan viestiin

newusernew

lukematon,
15.4.2020 klo 2.41.0015.4.2020
vastaanottaja fltk.general

Untitled.png

For example, in the "default" scheme. How can you tweak their appearance? I know that it's most likely hard-coded somewhere in fltk, ok, then where exactly, what file should I look for?

Antal Ispanovity

lukematon,
15.4.2020 klo 3.00.3515.4.2020
vastaanottaja fltk.general


On Wednesday, April 15, 2020 at 8:41:00 AM UTC+2, newusernew wrote:

Untitled.png

For example, in the "default" scheme. How can you tweak their appearance? I know that it's most likely hard-coded somewhere in fltk, ok, then where exactly, what file should I look for?
If I see correctly Fl_Scrollbar.cxx is the widget itself. (Not to be confused with Fl_Scroll). There you can find the draw() method. It draws a horizontal or vertical Fl_Slider and the arrows are drawn with fl_polygon. The arrow style seems to be different for gtk+ scheme. 

newusernew

lukematon,
15.4.2020 klo 4.58.0915.4.2020
vastaanottaja fltk.general
thanks, but I still can't figure out where the slider button up/down boxes are defined.

Manolo

lukematon,
15.4.2020 klo 5.23.3815.4.2020
vastaanottaja fltk.general


On Wednesday, 15 April 2020 10:58:09 UTC+2, newusernew wrote:
thanks, but I still can't figure out where the slider button up/down boxes are defined.

These black triangles are drawn by function Fl_Scrollbar::draw() of file
src/Fl_Scrollbar.cxx by these statements:

    if (Fl::is_scheme("gtk+")) {
      fl_polygon(x1, yy1+w1, x1+w1, yy1+2*w1, x1+w1-1, yy1+w1, x1+w1, yy1);
      x1 += (W-H);
      fl_polygon(x1, yy1, x1+1, yy1+w1, x1, yy1+2*w1, x1+w1, yy1+w1);
    } else {
      fl_polygon(x1, yy1+w1, x1+w1, yy1+2*w1, x1+w1, yy1);
      x1 += (W-H);
      fl_polygon(x1, yy1, x1, yy1+2*w1, x1+w1, yy1+w1);
    }

newusernew

lukematon,
15.4.2020 klo 6.59.1515.4.2020
vastaanottaja fltk.general
I'm not talking about the black triangles, I'm talking about square button shapes that you press, on top of which these black triangles are drawn.

Antal Ispanovity

lukematon,
15.4.2020 klo 7.15.1615.4.2020
vastaanottaja fltk.general


On Wednesday, April 15, 2020 at 12:59:15 PM UTC+2, newusernew wrote:
I'm not talking about the black triangles, I'm talking about square button shapes that you press, on top of which these black triangles are drawn.
Look a couple of lines above the already mentioned code part:
   draw_box((pushed_==1) ? fl_down(slider()) : slider(),
                X, Y, H, H, selection_color());
        draw_box((pushed_==2) ? fl_down(slider()) : slider(),
                X+W-H, Y, H, H, selection_color());

It draws the upper (pused_ == 1) and the lower (pushed_ == 2) box/background. If it's pressed then it draws a "down" version of a box, otherwise the "up" version.

newusernew

lukematon,
15.4.2020 klo 9.47.3915.4.2020
vastaanottaja fltk.general
Antal Ispanovity wrote:
If it's pressed then it draws a "down" version of a box, otherwise the "up" version.
Where does it specify this? 

imm

lukematon,
15.4.2020 klo 9.56.0115.4.2020
vastaanottaja general fltk
That's what the code Antal showed does; decide which box to draw.

If you have a good look at the code, you'll see it's checking whether pushed is true or not for the slider and hence whether to draw fl_down() or normal...

-- 
Ian
From my Fairphone FP3
   

Antal Ispanovity

lukematon,
15.4.2020 klo 10.21.4715.4.2020
vastaanottaja fltk.general
Let's have a look at this line: 
      draw_box((pushed_==1) ? fl_down(slider()) : slider(),
       X, Y, H, H, selection_color());
Check out the list of box types:

and the box drawing function:

draw_box is actually Fl_Widget's draw_box but the syntax is the same as fl_draw_box.

If I'm correct buttons are drawn with different style of boxes. For example drawing an FL_UP_BOX looks like a regular button, and FL_DOWN_BOX looks like a button being pressed. the fl_down function (see Enumerations.H) returns with the "pressed" or "down" counterpart of a given box.
The slider() function stores a box style used for drawing the slider.


newusernew

lukematon,
20.4.2020 klo 19.57.1320.4.2020
vastaanottaja fltk.general
Ok, then what part do I have to change in order to replace UP_BOX scrollbar buttons with THIN_UP_BOX buttons, for example?

Manolo

lukematon,
21.4.2020 klo 2.14.1221.4.2020
vastaanottaja fltk.general


On Tuesday, 21 April 2020 01:57:13 UTC+2, newusernew wrote:
Ok, then what part do I have to change in order to replace UP_BOX scrollbar buttons with THIN_UP_BOX buttons, for example?

The slider(Fl_Boxtype) member function of class Fl_Scrollbar inherited from Fl_Slider allows to set the box type
of an Fl_Scrollbar object.

An example, starting from an Fl_Scroll object, would be:
  Fl_Scroll scroll = .....
  scroll.scrollbar.slider(FL_THIN_UP_BOX); // change the boxtype of the vertical scrollbar
  scroll.hscrollbar.slider(FL_ENGRAVED_BOX); // change differently the boxtype of the horizontal scrollbar

newusernew

lukematon,
21.4.2020 klo 17.27.5921.4.2020
vastaanottaja fltk.general
I think I need a solution on a deeper level, that is, I don't want to simply replace boxtypes with other boxtypes, I want to change boxtypes themselves. What do I have to do in order to change the appearance of UP_BOX as such, fundamentally?

Antal Ispanovity

lukematon,
21.4.2020 klo 17.56.4721.4.2020
vastaanottaja fltk.general


On Tuesday, April 21, 2020 at 11:27:59 PM UTC+2, newusernew wrote:
I think I need a solution on a deeper level, that is, I don't want to simply replace boxtypes with other boxtypes, I want to change boxtypes themselves. What do I have to do in order to change the appearance of UP_BOX as such, fundamentally?

Have a look at the documentation, it's very useful. You might need this section: https://www.fltk.org/doc-1.3/common.html#common_custom_boxtypes 
Vastaa kaikille
Vastaa kirjoittajalle
Välitä
0 uutta viestiä