diff --git a/TODO b/TODO index 38ba88e..3324f7a 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -* Continue rebasing from cb494a80f276f3f91c73396f243353789bf14428 * Add a focus listener interface. * Make focus apply synchronously. * Graphics and input objects for DirectX. diff --git a/include/guisan/widgets/tabbedarea.hpp b/include/guisan/widgets/tabbedarea.hpp index bfc201b..cad650e 100644 --- a/include/guisan/widgets/tabbedarea.hpp +++ b/include/guisan/widgets/tabbedarea.hpp @@ -122,6 +122,13 @@ namespace gcn */ bool isOpaque() const; + /** + * Checks if the tabbed area is active or not. + * + * @return true if the tabbed area is active, false otherwise. + */ + bool isTabActive() const; + /** * Adds a tab to the tabbed area. The newly created tab will be * automatically deleted by the tabbed area when it is removed. @@ -293,6 +300,11 @@ namespace gcn * True if the tabbed area is opaque, false otherwise. */ bool mOpaque; + + /** + * True if the tabbed area is active, false otherwise. + */ + bool tabActive; }; } diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index aba2da1..2ecc327 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -224,6 +224,10 @@ namespace gcn void Button::mousePressed(MouseEvent& mouseEvent) { + if (mouseEvent.isConsumed()) + { + return; + } if (mouseEvent.getButton() == MouseEvent::Left) { mMousePressed = true; diff --git a/src/widgets/tab.cpp b/src/widgets/tab.cpp index 2d5223e..38509e5 100644 --- a/src/widgets/tab.cpp +++ b/src/widgets/tab.cpp @@ -71,7 +71,7 @@ namespace gcn Tab::Tab() : mTabbedArea(NULL), mHasMouse(false) { mLabel = new Label(); - mLabel->setPosition(4, 4); + mLabel->setPosition(6, 6); add(mLabel); setFrameSize(1); @@ -85,7 +85,7 @@ namespace gcn void Tab::adjustSize() { - setSize(mLabel->getWidth() + 8, mLabel->getHeight() + 8); + setSize(mLabel->getWidth() + 12, mLabel->getHeight() + 12); if (mTabbedArea != NULL) { @@ -159,12 +159,16 @@ namespace gcn graphics->setColor(baseColor); graphics->fillRectangle(Rectangle(0, 0, currentClipArea.width, currentClipArea.height)); - if (mTabbedArea != NULL && mTabbedArea->isFocused() && mTabbedArea->isTabSelected(this)) + if (mTabbedArea != NULL && mTabbedArea->isFocused() && mTabbedArea->isTabSelected(this) + // && mHasMouse) + && mTabbedArea->isTabActive()) { graphics->setColor(Color(0x000000)); graphics->drawRectangle( Rectangle(2, 2, currentClipArea.width - 4, currentClipArea.height - 4)); } + mLabel->setAlignment(Graphics::Center); + mLabel->_draw(graphics); graphics->popClipArea(); } diff --git a/src/widgets/tabbedarea.cpp b/src/widgets/tabbedarea.cpp index 8088034..457bd58 100644 --- a/src/widgets/tabbedarea.cpp +++ b/src/widgets/tabbedarea.cpp @@ -277,6 +277,11 @@ namespace gcn return mOpaque; } + bool TabbedArea::isTabActive() const + { + return tabActive; + } + void TabbedArea::draw(Graphics *graphics) { const Color& faceColor = getBaseColor(); @@ -318,7 +323,15 @@ namespace gcn mTabContainer->getHeight()); } - //drawChildren(graphics); + // Draw the widget from a select tab. + for (const auto& p : mTabs) + { + p.first->_draw(graphics); + if (p.first == mSelectedTab) + { + p.second->_draw(graphics); + } + } } void TabbedArea::adjustSize() @@ -356,8 +369,11 @@ namespace gcn Tab* tab = mTabs[i].first; tab->setPosition(x, maxTabHeight - tab->getHeight()); - x += tab->getWidth(); + + Widget* widget = mTabs[i].second; + widget->setX(mWidgetContainer->getX()); + widget->setY(mWidgetContainer->getY()); } } @@ -466,6 +482,17 @@ namespace gcn if (tab != NULL) { setSelectedTab(tab); + tabActive = true; + mouseEvent.consume(); + } + else + { + widget = mWidgetContainer->getWidgetAt(mouseEvent.getX(), mouseEvent.getY()); + if (widget == NULL) + { + mouseEvent.consume(); + } + tabActive = false; } }