littleflylongbow / guichan

Automatically exported from code.google.com/p/guichan
Other
0 stars 0 forks source link

DropDowns should be made more generic #117

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The DropDown class as it is is rather useful, but I think that restricting
its content to just ListBoxes at the moment restricts the class a bit more
than it needs to be. It'd be nice if dropdowns could be changed to work
like a container which can be opened up or collapsed, and wrapped in a
ScrollArea. Maybe most people wouldn't use them in any other way than a
plain listbox, but the more abstract its content is allowed to be (I'd
suggest making the contained content just a plain widget), the more
flexible the widget will be to GUIChan users, since if it's a plain widget,
it'd allow for developers to be able to not require that any widgets they
want to use within it be derivatives of the ListBox class. Some instances
where this might be rather desirable would be if the dropdown was made to
show/hide content within a window, for example, or if you make your own
type of a ListBox which allows for multiple selections to be made (you
could technically do this last one by making a list model which contains
checkboxes, and then overloading the checkboxes to not draw the box part,
but it can be done a little cleaner if it isn't forced into a model which
doesn't fit what it needs to model as well), or even some other creative
variants that other implementers might think of.

By the way, this is a bit of a random thought that I had recently when
discussing a project that's being worked on within my own project, where
what I was describing seemed to match up rather nicely with DropDown
behavior, except for the ListBox requirement, and is why I decided to post
it here. If you don't agree with it, that's alright, but I think that it's
at least worth a bit of a discussion.

Original issue reported on code.google.com by irar...@gmail.com on 13 Jun 2009 at 6:59

GoogleCodeExporter commented 8 years ago
I wouldn't be surprised if DropDown can be simplefied and be more generic. I'd 
be 
happy to look at any suggestions for improvements.

Original comment by olof.nae...@gmail.com on 14 Jun 2009 at 1:53

GoogleCodeExporter commented 8 years ago
One thing about the DropDown is that you want to be able to ask it for its 
current
index (and know when it changed via the SelectionListener), which is rather 
closely
related to the ListBox. The same goes for its scroll wheel and keyboard 
handling.

Maybe it would help if you would elaborate on which functionality of the 
DropDown
would be nice to make more generic? Would it be worth having a superclass just 
for
popping up a widget on click?

Comparing to Qt, since I can't help it. The QComboBox has a setView() method to
complement the setModel() method. This allows you to also display tables and 
trees in
a combo box (as well as use any custom view), but still the combo box is able 
to work
with the "current index". That wouldn't be the case if you could just set any 
QWidget
on it, instead of being limited to QAbstractItemView instances.

Original comment by b.lindeijer on 14 Jun 2009 at 2:55

GoogleCodeExporter commented 8 years ago
Yeah, Bjorn, a superclass might help a lot in both reducing the complexity and
helping to allow for more flexibility with the widget.

As for how much, I'd say that nearly all of it might be movable to a 
superclass, but
it'd take a bit of pondering on how to do it all (I mainly was trying to get 
this
issue a bit of attention first, since I'm still a bit fuzzy on where the lines 
should
get drawn), but yes, not all of it could get replaced by the parent widget. For 
one,
I think that what's displayed when it's closed can be handled by just changing 
the
viewable area.

I'll probably revisit this issue at a later date, but at the moment, I've got 
some
other issues on my own project which have been backlogged for a while, and 
should get
around to actually implementing some of the design documents I have lying 
around.
I'll probably get back to this issue when I get the TextBox revision finished 
for my
own project and attempt to supply a usable backport (issue #90. If you'd like 
some
more information on what I have planned so far, I can supply it there).

Original comment by irar...@gmail.com on 15 Jun 2009 at 4:36