diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-25 22:50:59 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-25 22:50:59 +0100 |
commit | cc79f0fe21e1a2ef73cbe987d54e848b9a47142d (patch) | |
tree | edd316eb6094f0c02d6d014385865dcd88a2bc56 /src/gui/table.cpp | |
parent | b0df784f1be44a657ca8092069488602270629b7 (diff) | |
parent | 99e8a3fd77b63a029fe02dcf771b6af1aad252ed (diff) | |
download | mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.gz mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.bz2 mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.xz mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.zip |
Merge branch 'eathena/master'
Conflicts:
A lot of files.
Diffstat (limited to 'src/gui/table.cpp')
-rw-r--r-- | src/gui/table.cpp | 56 |
1 files changed, 18 insertions, 38 deletions
diff --git a/src/gui/table.cpp b/src/gui/table.cpp index 1fd088ce..ec5b0480 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -23,7 +23,7 @@ #include <guichan/graphics.hpp> #include <guichan/key.hpp> -#include "color.h" +#include "palette.h" #include "table.h" #include "../configuration.h" @@ -98,6 +98,7 @@ GuiTable::GuiTable(TableModel *initial_model, gcn::Color background, GuiTable::~GuiTable() { + uninstallActionListeners(); delete mModel; } @@ -264,7 +265,7 @@ void GuiTable::installActionListeners() // -- widget ops void GuiTable::draw(gcn::Graphics* graphics) { - if (!mModel) + if (!mModel || !isVisible()) return; if (config.getValue("guialpha", 0.8) != mAlpha) @@ -272,11 +273,8 @@ void GuiTable::draw(gcn::Graphics* graphics) if (mOpaque) { - const int red = getBackgroundColor().r; - const int green = getBackgroundColor().g; - const int blue = getBackgroundColor().b; - const int alpha = (int)(mAlpha * 255.0f); - graphics->setColor(gcn::Color(red, green, blue, alpha)); + graphics->setColor(guiPalette->getColor(Palette::BACKGROUND, + (int)(mAlpha * 255.0f))); graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } @@ -321,18 +319,19 @@ void GuiTable::draw(gcn::Graphics* graphics) widget->setDimension(bounds); - if (!mLinewiseMode && c == mSelectedColumn && r == mSelectedRow) + graphics->setColor(guiPalette->getColor(Palette::HIGHLIGHT, + (int)(mAlpha * 255.0f))); + + if (mLinewiseMode && r == mSelectedRow && c == 0) + { + graphics->fillRectangle(gcn::Rectangle(0, y_offset, + getWidth(), height)); + } + else if (!mLinewiseMode && + c == mSelectedColumn && r == mSelectedRow) { - bool valid; - const int red = - (textColor->getColor('H', valid) >> 16) & 0xFF; - const int green = - (textColor->getColor('H', valid) >> 8) & 0xFF; - const int blue = textColor->getColor('H', valid) & 0xFF; - const int alpha = (int)(mAlpha * 127.0f); - - graphics->setColor(gcn::Color(red, green, blue, alpha)); - graphics->fillRectangle(bounds); + graphics->fillRectangle(gcn::Rectangle(x_offset, y_offset, + width, height)); } graphics->pushClipArea(bounds); @@ -343,21 +342,6 @@ void GuiTable::draw(gcn::Graphics* graphics) x_offset += width; } - if (mLinewiseMode && r == mSelectedRow) - { - bool valid; - const int red = - (textColor->getColor('H', valid) >> 16) & 0xFF; - const int green = - (textColor->getColor('H', valid) >> 8) & 0xFF; - const int blue = textColor->getColor('H', valid) & 0xFF; - const int alpha = (int)(mAlpha * 127.0f); - - graphics->setColor(gcn::Color(red, green, blue, alpha)); - graphics->fillRectangle(gcn::Rectangle(0, y_offset, - x_offset, height)); - } - y_offset += height; } @@ -401,25 +385,21 @@ void GuiTable::keyPressed(gcn::KeyEvent& keyEvent) else if (key.getValue() == gcn::Key::UP) { setSelectedRow(mSelectedRow - 1); - keyEvent.consume(); } else if (key.getValue() == gcn::Key::DOWN) { setSelectedRow(mSelectedRow + 1); - keyEvent.consume(); } else if (key.getValue() == gcn::Key::LEFT) { setSelectedColumn(mSelectedColumn - 1); - keyEvent.consume(); } else if (key.getValue() == gcn::Key::RIGHT) { setSelectedColumn(mSelectedColumn + 1); - keyEvent.consume(); } else if (key.getValue() == gcn::Key::HOME) @@ -459,7 +439,7 @@ void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) { if (isFocused()) { - if (getSelectedRow() >= 0 ) + if (getSelectedRow() > 0 || (getSelectedRow() == 0 && mWrappingEnabled)) { setSelectedRow(getSelectedRow() - 1); } |