FLTK logo

Re: [fltk/fltk] Fl_Help_VIew: allow Fl_Scrollbars to be accessable (#146)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.issues  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: [fltk/fltk] Fl_Help_VIew: allow Fl_Scrollbars to be accessable (#146) Albrecht Schlosser Oct 11, 2020  
 

I vote for public accessor methods scrollbar() and hscrollbar() that return pointers. For "symmetry" reasons I also like vscrollbar() and hscrollbar() but that's IMHO less consistent with existing widgets.

Reasoning:

  1. Exposing member instances directly is (and was) IMHO a bad choice. I'm thinking of a future enhancement so users can replace the internal (default) Fl_Scrollbar's with their own derived classes for whatever reasons (draw methods etc.). This is not possible with the current code using (and exposing) internal member variables. One way to achieve this would be to add accessor methods as mentioned above and to deprecate direct access to the (currently) public members. This could be done in FLTK 1.4 and in a later version we could (a) make the member variables private and (b) replace them with pointers and allocate them with new. In step (c) we could add setter methods so users can actually replace the scrollbars with their own derived classes of scrollbars.

Note: It's not possible to use an accessor method, for instance scrollbar(), with the same name as the internal member variable scrollbar, hence if we needed both for backwards compatibility (for some time) we'd have to use other names, e.g. pscrollbar() for the accessor methods which is unfortunately "not the FLTK way". FYI: Compiler (gcc) error message is

../../FL/Fl_Scroll.H:141:51: error: ‘Fl_Scrollbar* Fl_Scroll::scrollbar()’ conflicts with a previous declaration
  141 |   Fl_Scrollbar *scrollbar()  { return &scrollbar; }
      |                                                   ^
../../FL/Fl_Scroll.H:138:16: note: previous declaration ‘Fl_Scrollbar Fl_Scroll::scrollbar’
  138 |   Fl_Scrollbar scrollbar;
      |                ^~~~~~~~~
  1. Since the member variables in Fl_Help_View are already private (and named correctly with trailing '_') we can safely add the public (or protected) accessor methods with appropriate names (as suggested).

  2. If we wanted to take the route described in (1) we should, however, use another name as described in (1). To use all possible options (compatibility, consistency, and symmetry) we might want to use pvscrollbar() and phscrollbar().


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.