diff options
author | Ira Rice <irarice@gmail.com> | 2009-01-20 16:46:17 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-20 16:46:17 -0700 |
commit | 1b3ac1ad7a745ed7b7aac1f1dd7514616db8a998 (patch) | |
tree | d04d002a96fb2febbfd8a42b66aab38f04ee6b16 | |
parent | c75f6978e780a4cbe7e4103b7a3187c2ddf75c33 (diff) | |
download | mana-client-1b3ac1ad7a745ed7b7aac1f1dd7514616db8a998.tar.gz mana-client-1b3ac1ad7a745ed7b7aac1f1dd7514616db8a998.tar.bz2 mana-client-1b3ac1ad7a745ed7b7aac1f1dd7514616db8a998.tar.xz mana-client-1b3ac1ad7a745ed7b7aac1f1dd7514616db8a998.zip |
Reflowed skill dialog, as well as started to work on revising the table
model (none of the changes yet make visible improvements yet,
unfortunately).
Signed-off-by: Ira Rice <irarice@gmail.com>
-rw-r--r-- | src/gui/skill.cpp | 23 | ||||
-rw-r--r-- | src/gui/table_model.cpp | 48 | ||||
-rw-r--r-- | src/gui/table_model.h | 39 |
3 files changed, 94 insertions, 16 deletions
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 44f77253..35a41659 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -28,6 +28,8 @@ #include "skill.h" #include "windowcontainer.h" +#include "widgets/layout.h" + #include "../localplayer.h" #include "../log.h" @@ -51,7 +53,7 @@ class SkillGuiTableModel : public StaticTableModel { public: SkillGuiTableModel(SkillDialog *dialog) : - StaticTableModel(0, 3) + StaticTableModel(0, 3, 0xbdb5aa) { mEntriesNr = 0; mDialog = dialog; @@ -136,16 +138,15 @@ SkillDialog::SkillDialog(): mTable.setActionEventId("skill"); skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - skillScrollArea->setDimension(gcn::Rectangle(5, 5, 230, 180)); - mPointsLabel->setDimension(gcn::Rectangle(8, 190, 200, 16)); - mIncButton->setPosition(skillScrollArea->getX(), 210); - mUseButton->setPosition(mIncButton->getX() + mIncButton->getWidth() + 5, - 210); - - add(skillScrollArea); - add(mPointsLabel); - add(mIncButton); - add(mUseButton); + skillScrollArea->setOpaque(false); + + place(0, 0, skillScrollArea, 5).setPadding(3); + place(0, 1, mPointsLabel, 2); + place(3, 2, mIncButton); + place(4, 2, mUseButton); + + Layout &layout = getLayout(); + layout.setRowHeight(0, Layout::AUTO_SET); // mSkillListBox->addActionListener(this); mTable.addActionListener(this); diff --git a/src/gui/table_model.cpp b/src/gui/table_model.cpp index d626423a..f7f0ab54 100644 --- a/src/gui/table_model.cpp +++ b/src/gui/table_model.cpp @@ -21,6 +21,7 @@ #include <cstdlib> +#include <guichan/graphics.hpp> #include <guichan/widget.hpp> #include "table_model.h" @@ -50,14 +51,16 @@ void TableModel::signalAfterUpdate(void) } - #define WIDGET_AT(row, column) (((row) * mColumns) + (column)) #define DYN_SIZE(h) ((h) >= 0) // determines whether this size is tagged for auto-detection -StaticTableModel::StaticTableModel(int row, int column) : +StaticTableModel::StaticTableModel(int row, int column, + gcn::Color backgroundColor, bool opacity) : mRows(row), mColumns(column), - mHeight(1) + mHeight(1), + mBackgroundColor(backgroundColor), + mOpaque(opacity) { mTableModel.resize(row * column, NULL); mWidths.resize(column, 1); @@ -144,3 +147,42 @@ int StaticTableModel::getColumns(void) { return mColumns; } + +int StaticTableModel::getWidth(void) +{ + int width = 0; + + for (unsigned int i = 0; i < mWidths.size(); i++) + { + width += mWidths[i]; + } + + return width; +} + +int StaticTableModel::getHeight(void) +{ + return (mColumns * mHeight); +} + +void StaticTableModel::drawBackground(gcn::Graphics *graphics) +{ + if (isOpaque()) + { + for (unsigned int i = 0; i < mTableModel.size(); i++) + { + mTableModel[i]->setBackgroundColor(mBackgroundColor); + } + } +} + +void StaticTableModel::setOpaque(bool opaque) +{ + mOpaque = opaque; +} + +bool StaticTableModel::isOpaque() const +{ + return mOpaque; +} + diff --git a/src/gui/table_model.h b/src/gui/table_model.h index a52a7561..304500bb 100644 --- a/src/gui/table_model.h +++ b/src/gui/table_model.h @@ -25,6 +25,7 @@ #include <set> #include <vector> +#include <guichan/color.hpp> #include <guichan/gui.hpp> #include "../guichanfwd.h" @@ -99,12 +100,14 @@ private: class StaticTableModel : public TableModel { public: - StaticTableModel(int width, int height); + StaticTableModel(int width, int height, gcn::Color background = 0xffffff, + bool opacity = true); virtual ~StaticTableModel(void); /** * Inserts a widget into the table model. - * The model is resized to accomodate the widget's width and height, unless column width / row height have been fixed. + * The model is resized to accomodate the widget's width and height, + * unless column width / row height have been fixed. */ virtual void set(int row, int column, gcn::Widget *widget); @@ -127,9 +130,27 @@ public: */ virtual void resize(void); + /** + * Sets the table to be opaque, that is sets the table + * to display its background. + * + * @param opaque True if the table should be opaque, false otherwise. + */ + virtual void setOpaque(bool opaque); + + /** + * Checks if the scroll area is opaque, that is if the scroll area + * displays its background. + * + * @return True if the scroll area is opaque, false otherwise. + */ + virtual bool isOpaque() const; + virtual int getRows(void); virtual int getColumns(void); virtual int getRowHeight(void); + virtual int getWidth(void); + virtual int getHeight(void); virtual int getColumnWidth(int index); virtual gcn::Widget *getElementAt(int row, int column); @@ -137,8 +158,22 @@ public: protected: int mRows, mColumns; int mHeight; + bool mOpaque; std::vector<gcn::Widget *> mTableModel; std::vector<int> mWidths; + + /** + * Holds the background color of the table. + */ + gcn::Color mBackgroundColor; + + /** + * Draws the background of the table, that is + * the area behind the content. + * + * @param graphics a Graphics object to draw with. + */ + virtual void drawBackground(gcn::Graphics *graphics); }; #endif /* !defined(TMW_TABLE_MODEL_H_) */ |