diff options
author | Ira Rice <irarice@gmail.com> | 2009-01-18 23:15:08 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-18 23:15:08 -0700 |
commit | 18c00fedebda79d4ebfbe15401c3e5bc8869fda2 (patch) | |
tree | deda39b903e4882d60d0a82fb415f42f16acfadb /src | |
parent | 8f28b18a31fc8415fbf6aedc5106b8b8525f4caf (diff) | |
download | mana-18c00fedebda79d4ebfbe15401c3e5bc8869fda2.tar.gz mana-18c00fedebda79d4ebfbe15401c3e5bc8869fda2.tar.bz2 mana-18c00fedebda79d4ebfbe15401c3e5bc8869fda2.tar.xz mana-18c00fedebda79d4ebfbe15401c3e5bc8869fda2.zip |
Reflowed Player tab in setup to use layout code. TODO: Fix up table
model, cause it's a mess.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/setup_players.cpp | 48 | ||||
-rw-r--r-- | src/gui/table_model.cpp | 6 |
2 files changed, 30 insertions, 24 deletions
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index e7770959..4bfca983 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -29,6 +29,8 @@ #include "ok_dialog.h" #include "setup_players.h" +#include "widgets/layouthelper.h" + #include "../configuration.h" #include "../log.h" #include "../player_relations.h" @@ -43,7 +45,7 @@ #define ROW_HEIGHT 12 // The following column widths really shouldn't be hardcoded but should scale with the size of the widget... except // that, right now, the widget doesn't exactly scale either. -#define NAME_COLUMN_WIDTH 120 +#define NAME_COLUMN_WIDTH 195 #define RELATION_CHOICE_COLUMN_WIDTH 80 #define WIDGET_AT(row, column) (((row) * COLUMNS_NR) + column) @@ -128,7 +130,8 @@ public: mPlayers = player_names; // set up widgets - for (unsigned int r = 0; r < player_names->size(); ++r) { + for (unsigned int r = 0; r < player_names->size(); ++r) + { std::string name = (*player_names)[r]; gcn::Widget *widget = new gcn::Label(name); mWidgets.push_back(widget); @@ -220,7 +223,6 @@ Setup_Players::Setup_Players(): mIgnoreActionChoicesBox(new gcn::DropDown(new IgnoreChoicesListModel())) { setOpaque(false); - setDimension(gcn::Rectangle(0, 0, 290, 255)); int table_width = NAME_COLUMN_WIDTH + RELATION_CHOICE_COLUMN_WIDTH; mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH); @@ -228,28 +230,30 @@ Setup_Players::Setup_Players(): RELATION_CHOICE_COLUMN_WIDTH); mPlayerTitleTable->setDimension(gcn::Rectangle(10, 10, table_width, 10)); mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf)); - for (int i = 0; i < COLUMNS_NR; i++) { + + for (int i = 0; i < COLUMNS_NR; i++) + { mPlayerTableTitleModel->set(0, i, new gcn::Label(gettext(table_titles[i]))); } + mPlayerTitleTable->setLinewiseSelection(true); - mPlayerScrollArea->setDimension(gcn::Rectangle(10, 25, table_width + COLUMNS_NR, 90)); mPlayerScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mPlayerTable->setActionEventId(ACTION_TABLE); mPlayerTable->setLinewiseSelection(true); mPlayerTable->addActionListener(this); - mDeleteButton->setPosition(10, 118); - gcn::Label *ignore_action_label = new gcn::Label(_("When ignoring:")); - ignore_action_label->setPosition(80, 118); mIgnoreActionChoicesBox->setDimension(gcn::Rectangle(80, 132, 120, 12)); mIgnoreActionChoicesBox->setActionEventId(ACTION_STRATEGY); mIgnoreActionChoicesBox->addActionListener(this); + int ignore_strategy_index = 0; // safe default - if (player_relations.getPlayerIgnoreStrategy()) { + + if (player_relations.getPlayerIgnoreStrategy()) + { ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex( player_relations.getPlayerIgnoreStrategy()->mShortName); if (ignore_strategy_index < 0) @@ -258,22 +262,24 @@ Setup_Players::Setup_Players(): mIgnoreActionChoicesBox->setSelected(ignore_strategy_index); mIgnoreActionChoicesBox->adjustHeight(); - mPersistIgnores->setPosition(80, 148); - mDefaultTrading->setPosition(80, 160); - mDefaultWhisper->setPosition(80, 172); - reset(); - add(ignore_action_label); - add(mDefaultTrading); - add(mDefaultWhisper); - add(mIgnoreActionChoicesBox); - add(mDeleteButton); - add(mPlayerScrollArea); - add(mPlayerTitleTable); - add(mPersistIgnores); + // Do the layout + LayoutHelper h(this); + ContainerPlacer place = h.getPlacer(0, 0); + + place(0, 0, mPlayerTitleTable, 4); + place(0, 1, mPlayerScrollArea, 4, 4).setPadding(2); + place(0, 5, mDeleteButton); + place(2, 5, ignore_action_label); + place(2, 6, mIgnoreActionChoicesBox, 2).setPadding(2); + place(2, 7, mPersistIgnores); + place(2, 8, mDefaultTrading); + place(2, 9, mDefaultWhisper); player_relations.addListener(this); + + setDimension(gcn::Rectangle(0, 0, 290, 250)); } Setup_Players::~Setup_Players(void) diff --git a/src/gui/table_model.cpp b/src/gui/table_model.cpp index 9911eec3..d626423a 100644 --- a/src/gui/table_model.cpp +++ b/src/gui/table_model.cpp @@ -25,6 +25,8 @@ #include "table_model.h" +#include "../utils/dtor.h" + void TableModel::installListener(TableModelListener *listener) { listeners.insert(listener); @@ -63,9 +65,7 @@ StaticTableModel::StaticTableModel(int row, int column) : StaticTableModel::~StaticTableModel(void) { - for (std::vector<gcn::Widget *>::const_iterator it = mTableModel.begin(); it != mTableModel.end(); it++) - if (*it) - delete *it; + delete_all(mTableModel); } void StaticTableModel::resize(void) |