Added experimental listbox grow support.
This allows a listbox to grow, but keep the unused area blank instead of trying to allocate it for it's content. The feature had minimal testing, but ran into a problem that the stacked widget doesn't let the room grow. This needs to be fixed before testing further.
This commit is contained in:
parent
fd05e12d11
commit
e661d2f4c1
5 changed files with 32 additions and 2 deletions
|
@ -632,7 +632,7 @@
|
|||
grow_factor = 1
|
||||
[column]
|
||||
horizontal_grow = "true"
|
||||
vertical_alignment = "top"
|
||||
vertical_grow = "true"
|
||||
{GUI_FORCE_WIDGET_MINIMUM_SIZE 0 "((screen_height * 30) / 100)" (
|
||||
{GAMELISTBOX}
|
||||
)}
|
||||
|
|
|
@ -419,5 +419,15 @@ void tlistbox::finalize(
|
|||
|
||||
}
|
||||
|
||||
void tlistbox::set_content_size(const tpoint& origin, const tpoint& size)
|
||||
{
|
||||
/** @todo This function needs more testing. */
|
||||
assert(content_grid());
|
||||
|
||||
const int best_height = content_grid()->get_best_size().y;
|
||||
const tpoint s(size.x, size.y < best_height ? size.y : best_height);
|
||||
content_grid()->set_size(origin, s);
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
|
|
|
@ -287,6 +287,9 @@ private:
|
|||
*/
|
||||
bool linked_widgets_disabled_;
|
||||
|
||||
/** Inherited from tscrollbar_container. */
|
||||
virtual void set_content_size(const tpoint& origin, const tpoint& size);
|
||||
|
||||
/** Inherited from tcontrol. */
|
||||
const std::string& get_control_type() const
|
||||
{ static const std::string type = "listbox"; return type; }
|
||||
|
|
|
@ -310,7 +310,7 @@ void tscrollbar_container::
|
|||
std::max(best_size.x, content_size.x),
|
||||
std::max(best_size.y, content_size.y));
|
||||
|
||||
content_grid_->set_size(content_origin, content_grid_size);
|
||||
set_content_size(content_origin, content_grid_size);
|
||||
|
||||
// Set vertical scrollbar
|
||||
set_scrollbar_mode(vertical_scrollbar_grid_, vertical_scrollbar_,
|
||||
|
@ -568,6 +568,12 @@ void tscrollbar_container::child_populate_dirty_list(twindow& caller,
|
|||
content_grid_->populate_dirty_list(caller, child_call_stack);
|
||||
}
|
||||
|
||||
void tscrollbar_container::set_content_size(
|
||||
const tpoint& origin, const tpoint& size)
|
||||
{
|
||||
content_grid_->set_size(origin, size);
|
||||
}
|
||||
|
||||
void tscrollbar_container::show_content_rect(const SDL_Rect& rect)
|
||||
{
|
||||
assert(content_);
|
||||
|
|
|
@ -392,6 +392,17 @@ private:
|
|||
void child_populate_dirty_list(twindow& caller,
|
||||
const std::vector<twidget*>& call_stack);
|
||||
|
||||
/**
|
||||
* Sets the size of the content grid.
|
||||
*
|
||||
* This function normally just updates the content grid but can be
|
||||
* overridden by a subclass.
|
||||
*
|
||||
* @param origin The origin for the content.
|
||||
* @param size The size of the content.
|
||||
*/
|
||||
virtual void set_content_size(const tpoint& origin, const tpoint& size);
|
||||
|
||||
/** Helper function which needs to be called after the scollbar moved. */
|
||||
void scrollbar_moved();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue