mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Resize list of stylesheets to fit available space
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1138 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/set/style_panel.hpp>
|
||||
#include <gui/set/window.hpp>
|
||||
#include <gui/control/package_list.hpp>
|
||||
#include <gui/control/card_viewer.hpp>
|
||||
#include <gui/control/native_look_editor.hpp>
|
||||
@@ -47,6 +48,23 @@ StylePanel::StylePanel(Window* parent, int id)
|
||||
s->SetSizeHints(this);
|
||||
SetSizer(s);
|
||||
}
|
||||
void StylePanel::updateListSize() {
|
||||
// how many columns fit?
|
||||
size_t fit_columns = (size_t)((GetSize().y - 400) / 152);
|
||||
// we only need enough columns to show all items
|
||||
int x_room = GetSize().x - editor->GetBestSize().x - 6;
|
||||
size_t need_columns = (size_t)ceil(list->requiredWidth() / (double)x_room);
|
||||
size_t column_count = max(1u, min(fit_columns, need_columns));
|
||||
// change count
|
||||
if (column_count != list->column_count) {
|
||||
list->column_count = column_count;
|
||||
static_cast<SetWindow*>(GetParent())->fixMinWindowSize();
|
||||
}
|
||||
}
|
||||
bool StylePanel::Layout() {
|
||||
updateListSize();
|
||||
return SetWindowPanel::Layout();
|
||||
}
|
||||
|
||||
void StylePanel::onChangeSet() {
|
||||
list->showData<StyleSheet>(set->game->name() + _("-*"));
|
||||
|
||||
Reference in New Issue
Block a user