Fix the formatting for a growing pane.
The code seems to work for this specific case but needs more testing. This commit finishes the proof-of-concept prototype it seems the big hurdles in the listbox have been tackled. Now need to focus on getting a real widget out of this prototype. The code is used to experiment with a different approach of the implementation of a listbox.
This commit is contained in:
parent
db8ddc9b02
commit
a849f6c7a4
3 changed files with 43 additions and 1 deletions
|
@ -296,6 +296,26 @@ void tpane::set_origin_children()
|
|||
}
|
||||
}
|
||||
|
||||
void tpane::place_or_set_origin_children()
|
||||
{
|
||||
unsigned y = 0;
|
||||
|
||||
BOOST_FOREACH(titem& item, items_) {
|
||||
if(item.grid->get_visible() == twidget::INVISIBLE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DBG_GUI_L << LOG_HEADER << " offset " << y << '\n';
|
||||
if(item.grid->get_size() != item.grid->get_best_size()) {
|
||||
item.grid->place(tpoint(0, y), item.grid->get_best_size());
|
||||
} else {
|
||||
item.grid->set_origin(tpoint(0, y));
|
||||
}
|
||||
y += item.grid->get_height();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void tpane::signal_handler_request_placement(
|
||||
tdispatcher& dispatcher
|
||||
, const event::tevent event
|
||||
|
@ -309,6 +329,15 @@ void tpane::signal_handler_request_placement(
|
|||
if(item.grid->has_widget(widget)) {
|
||||
if(item.grid->get_visible() != twidget::INVISIBLE) {
|
||||
|
||||
/*
|
||||
* This time we call init layout but also the linked widget
|
||||
* update this makes things work properly for the
|
||||
* addon_list. This code can use some more tuning,
|
||||
* polishing and testing.
|
||||
*/
|
||||
item.grid->layout_init(false);
|
||||
get_window()->layout_linked_widgets();
|
||||
|
||||
/*
|
||||
* By not calling init layout it uses its previous size
|
||||
* what seems to work properly when showing and hiding
|
||||
|
@ -316,7 +345,7 @@ void tpane::signal_handler_request_placement(
|
|||
*/
|
||||
item.grid->place(tpoint(0, 0), item.grid->get_best_size());
|
||||
}
|
||||
set_origin_children();
|
||||
place_or_set_origin_children();
|
||||
DBG_GUI_E << LOG_HEADER << ' ' << event << " handled.\n";
|
||||
handled = true;
|
||||
return;
|
||||
|
|
|
@ -164,6 +164,17 @@ private:
|
|||
*/
|
||||
void set_origin_children();
|
||||
|
||||
/**
|
||||
* Places or moves the children on the pane.
|
||||
*
|
||||
* If the child has its best size it's move else placed.
|
||||
*
|
||||
* @note It would probably be possible to merge all three placement
|
||||
* routines into one and using a flag for what to do: place, set_origin or
|
||||
* place_or_set_origin.
|
||||
*/
|
||||
void place_or_set_origin_children();
|
||||
|
||||
/***** ***** ***** signal handlers ***** ****** *****/
|
||||
|
||||
void signal_handler_request_placement(
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace gui2{
|
|||
|
||||
class tdialog;
|
||||
class tdebug_layout_graph;
|
||||
class tpane;
|
||||
|
||||
namespace event {
|
||||
class tdistributor;
|
||||
|
@ -56,6 +57,7 @@ class twindow
|
|||
friend twindow *build(CVideo &, const twindow_builder::tresolution *);
|
||||
friend struct twindow_implementation;
|
||||
friend class tinvalidate_layout_blocker;
|
||||
friend class tpane;
|
||||
|
||||
public:
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue