FLTK logo

Re: [fltk.coredev] Fl_Flex method name question

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.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Fl_Flex method name question Albrecht Schlosser Oct 25, 2022  
 
On 10/24/22 19:12 'melcher....@googlemail.com' via fltk.coredev wrote:
Is `int set_size(Fl_Widget *w) const;` correct, or should it be `int get_size(Fl_Widget *w) const;` with a 'g'. Since it's `const`, it's only returning something, and not setting anything.

Yes, it is returning whether `void set_size(...)`has been called on this widget. The naming follows (ehm, I tried to follow) the good old FLTK convention that the setter and getter methods have the same name.

https://www.fltk.org/doc-1.4/classFl__Flex.html#a3235849fc0e99512d76c0048de68e6a8

Setter(s):

void Fl_Flex::set_size(Fl_Widget &w, int size)
void Fl_Flex::set_size(Fl_Widget *w, int size)

Getter:

int Fl_Flex::set_size(Fl_Widget *w) const


I admit that the "set_" prefix of the setter method makes this confusing because the getter doesn't set anything. I'm open for better suggestions, and since FLTK 1.4.0 has not yet been released we can IMHO still change this if we decide to do so.

BTW, for history: in the original contribution the setter was SetSize() and there was no getter method.

Returning an int rather than bool is always FLTK convention.

As far as I have seen proposals, here are my comments:

hasSize(): -1 (violates FLTK conventions)

has_size(): naming is OK, but IMHO too general. Although it corresponds to set_size(), my gut feeling is that this is confusing as well (every widget has a size, right?).

check_size(): similar to has_size(), IMHO too general.

is_fixed(), has_fixed_size(): these are my personal favorites so far, the latter more than the former.

is_fixed_size() would IMHO be another good option.


Are there more proposals? Votes?

--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/53e76fb5-e588-f110-23d2-1821732ecafe%40online.de.
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'.