Draw the active tab differently: remove the horizontal line at the bottom (inspired by patch #1091165)

svn-id: r16322
This commit is contained in:
Max Horn 2004-12-25 21:56:26 +00:00
parent 5a38c16c27
commit ffbbef6f31

View File

@ -118,29 +118,52 @@ bool TabWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
return Widget::handleKeyDown(ascii, keycode, modifiers);
}
static void box(int x, int y, int width, int height, OverlayColor colorA, OverlayColor colorB, bool omitBottom) {
NewGui &gui = g_gui;
gui.hLine(x + 1, y, x + width - 2, colorA);
gui.hLine(x, y + 1, x + width - 1, colorA);
gui.vLine(x, y + 1, y + height - (omitBottom ? 1 : 2), colorA);
gui.vLine(x + 1, y, y + height - (omitBottom ? 2 : 1), colorA);
if (!omitBottom) {
gui.hLine(x + 1, y + height - 2, x + width - 1, colorB);
gui.hLine(x + 1, y + height - 1, x + width - 2, colorB);
}
gui.vLine(x + width - 1, y + 1, y + height - (omitBottom ? 1 : 2), colorB);
gui.vLine(x + width - 2, y + 1, y + height - (omitBottom ? 2 : 1), colorB);
}
void TabWidget::drawWidget(bool hilite) {
NewGui *gui = &g_gui;
const int left1 = _x + 1;
const int right1 = _x + kTabLeftOffset + _activeTab * (_tabWidth + kTabSpacing);
const int left2 = right1 + _tabWidth;
const int right2 = _x + _w - 2;
// Draw horizontal line
gui->hLine(_x + 1, _y + kTabHeight - 2, _x + _w - 2, gui->_shadowcolor);
gui->hLine(left1, _y + kTabHeight - 2, right1, gui->_shadowcolor);
gui->hLine(left2, _y + kTabHeight - 2, right2, gui->_shadowcolor);
// Iterate over all tabs and draw them
int i, x = _x + kTabLeftOffset;
for (i = 0; i < (int)_tabs.size(); ++i) {
OverlayColor color = (i == _activeTab) ? gui->_color : gui->_shadowcolor;
int yOffset = (i == _activeTab) ? 0 : 2;
gui->box(x, _y + yOffset, _tabWidth, kTabHeight - yOffset, color, color);
box(x, _y + yOffset, _tabWidth, kTabHeight - yOffset, color, color, (i == _activeTab));
gui->drawString(_tabs[i].title, x + kTabPadding, _y + yOffset / 2 + (kTabHeight - kLineHeight - 1), _tabWidth - 2 * kTabPadding, gui->_textcolor, kTextAlignCenter);
x += _tabWidth + kTabSpacing;
}
// Draw more horizontal lines
gui->hLine(_x+1, _y + kTabHeight - 1, _x + _w - 2, gui->_color);
gui->hLine(left1, _y + kTabHeight - 1, right1, gui->_color);
gui->hLine(left2, _y + kTabHeight - 1, right2, gui->_color);
gui->hLine(_x+1, _y + _h - 2, _x + _w - 2, gui->_shadowcolor);
gui->hLine(_x+1, _y + _h - 1, _x + _w - 2, gui->_color);
}
Widget *TabWidget::findWidget(int x, int y) {
if (y < kTabHeight) {
// Click was in the tab area