diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-10-02 18:57:10 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-10-02 18:57:10 +0300 |
commit | f1e92aca00a4859047e83fab76220767b9a2f814 (patch) | |
tree | 8aaa9d6853c6a8e0e8fc568c6f981cbd889b0cc3 /src/gui/widgets | |
parent | 70b520b1e876f9698bb95baa2d274ea289a0c6bd (diff) | |
parent | 99771a1fb50286fdb0b511f425312503e657eddc (diff) | |
download | plus-f1e92aca00a4859047e83fab76220767b9a2f814.tar.gz plus-f1e92aca00a4859047e83fab76220767b9a2f814.tar.bz2 plus-f1e92aca00a4859047e83fab76220767b9a2f814.tar.xz plus-f1e92aca00a4859047e83fab76220767b9a2f814.zip |
Merge branch 'master' into strippedstripped1.1.10.2
Conflicts:
packaging/debian/watch
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/dropshortcutcontainer.cpp | 9 | ||||
-rw-r--r-- | src/gui/widgets/dropshortcutcontainer.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/emoteshortcutcontainer.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/emoteshortcutcontainer.h | 8 | ||||
-rw-r--r-- | src/gui/widgets/inttextfield.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/itemshortcutcontainer.cpp | 14 | ||||
-rw-r--r-- | src/gui/widgets/itemshortcutcontainer.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/layout.h | 29 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 57 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.h | 5 | ||||
-rw-r--r-- | src/gui/widgets/spellshortcutcontainer.cpp | 9 | ||||
-rw-r--r-- | src/gui/widgets/spellshortcutcontainer.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/textfield.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/textfield.h | 7 | ||||
-rw-r--r-- | src/gui/widgets/window.h | 4 |
17 files changed, 156 insertions, 17 deletions
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index b628cf2d4..1fa272448 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -306,5 +306,12 @@ void DropShortcutContainer::mouseMoved(gcn::MouseEvent &event) // Hide ItemTooltip void DropShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) { - mItemPopup->setVisible(false); + if (mItemPopup) + mItemPopup->setVisible(false); +} + +void DropShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +{ + if (mItemPopup) + mItemPopup->setVisible(false); } diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index b2d63a7dd..348f48567 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -76,6 +76,8 @@ class DropShortcutContainer : public ShortcutContainer */ void mouseReleased(gcn::MouseEvent &event); + void widgetHidden(const gcn::Event &event); + private: void mouseExited(gcn::MouseEvent &event); void mouseMoved(gcn::MouseEvent &event); diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 5aced193f..cc9e8badf 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -252,4 +252,10 @@ void EmoteShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) { if (mEmotePopup) mEmotePopup->setVisible(false); -}
\ No newline at end of file +} + +void EmoteShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +{ + if (mEmotePopup) + mEmotePopup->setVisible(false); +} diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index b1cc866d2..06c009f0b 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -27,6 +27,12 @@ #include <vector> +#ifdef __GNUC__ +#define A_UNUSED __attribute__ ((unused)) +#else +#define A_UNUSED +#endif + class AnimatedSprite; class Image; class TextPopup; @@ -73,6 +79,8 @@ class EmoteShortcutContainer : public ShortcutContainer void mouseExited(gcn::MouseEvent &event); + void widgetHidden(const gcn::Event &event); + private: std::vector<const EmoteSprite*> mEmoteImg; diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp index 021340fbe..89544e108 100644 --- a/src/gui/widgets/inttextfield.cpp +++ b/src/gui/widgets/inttextfield.cpp @@ -50,6 +50,9 @@ void IntTextField::keyPressed(gcn::KeyEvent &event) key.getValue() == Key::DELETE) { setText(std::string()); + if (mSendAlwaysEvents) + distributeActionEvent(); + event.consume(); } @@ -62,6 +65,8 @@ void IntTextField::keyPressed(gcn::KeyEvent &event) int i; s >> i; setValue(i); + if (mSendAlwaysEvents) + distributeActionEvent(); } void IntTextField::setRange(int min, int max) diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 2cc80ee8b..9a17d81cd 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -327,6 +327,12 @@ void ItemContainer::distributeValueChangedEvent() } } +void ItemContainer::hidePopup() +{ + if (mItemPopup) + mItemPopup->setVisible(false); +} + void ItemContainer::keyPressed(gcn::KeyEvent &event A_UNUSED) { /*switch (event.getKey().getValue()) diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 845bfb3a9..e4188f54b 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -73,6 +73,8 @@ class ItemContainer : public gcn::Widget, */ virtual ~ItemContainer(); + void hidePopup(); + /** * Necessary for checking how full the inventory is. */ diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 79685fe45..560045a29 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -378,6 +378,16 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) // Hide ItemTooltip void ItemShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) { - mItemPopup->setVisible(false); - mSpellPopup->setVisible(false); + if (mItemPopup) + mItemPopup->setVisible(false); + if (mSpellPopup) + mSpellPopup->setVisible(false); +} + +void ItemShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +{ + if (mItemPopup) + mItemPopup->setVisible(false); + if (mSpellPopup) + mSpellPopup->setVisible(false); } diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index e6b32c6f8..473cef350 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -78,6 +78,8 @@ class ItemShortcutContainer : public ShortcutContainer */ void mouseReleased(gcn::MouseEvent &event); + void widgetHidden(const gcn::Event &event); + private: void mouseExited(gcn::MouseEvent &event); void mouseMoved(gcn::MouseEvent &event); diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index f5e1f1749..5e3ac4532 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -261,6 +261,28 @@ class LayoutCell */ void computeSizes(); + void setType(int t) + { mType = t; } + + int getWidth() + { return mExtent[0]; } + + int getHeight() + { return mExtent[1]; } + + void setWidth(int w) + { mExtent[0] = w; } + + void setHeight(int h) + { mExtent[1] = h; } + + enum + { + NONE = 0, + WIDGET, + ARRAY + }; + private: // Copy not allowed, as the cell may own an array. LayoutCell(LayoutCell const &); @@ -272,13 +294,6 @@ class LayoutCell LayoutArray *mArray; }; - enum - { - NONE = 0, - WIDGET, - ARRAY - }; - /** * Returns the embedded array. Creates it if the cell does not contain * anything yet. Aborts if it contains a widget. diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 2796d3ab2..3204028dc 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -47,6 +47,8 @@ ScrollArea::ScrollArea(): gcn::ScrollArea(), mX(0), mY(0), + mClickX(0), + mClickY(0), mHasMouse(false), mOpaque(true), mVertexes(new GraphicsVertexes()), @@ -64,6 +66,8 @@ ScrollArea::ScrollArea(gcn::Widget *widget): gcn::ScrollArea(widget), mX(0), mY(0), + mClickX(0), + mClickY(0), mHasMouse(false), mOpaque(true), mVertexes(new GraphicsVertexes()), @@ -513,3 +517,56 @@ void ScrollArea::widgetMoved(const gcn::Event& event A_UNUSED) { mRedraw = true; } + +void ScrollArea::mousePressed(gcn::MouseEvent& event) +{ + gcn::ScrollArea::mousePressed(event); + if (event.getButton() == gcn::MouseEvent::LEFT) + { + mClickX = event.getX(); + mClickY = event.getY(); + } +} + +void ScrollArea::mouseReleased(gcn::MouseEvent& event) +{ + if (event.getButton() == gcn::MouseEvent::LEFT && mClickX && mClickY) + { + if (!event.isConsumed()) + { + int dx = event.getX() - mClickX; + int dy = event.getY() - mClickY; + + if ((dx < 10 && dx > 0) || (dx > -10 && dx < 0)) + dx = 0; + + if ((dy < 10 && dy > 0) || (dy > -10 && dy < 0)) + dy = 0; + + if (dx) + { + int s = getHorizontalScrollAmount() + dx; + if (s < 0) + s = 0; + else if (s > getHorizontalMaxScroll()) + s = getHorizontalMaxScroll(); + + setHorizontalScrollAmount(s); + } + if (dy) + { + int s = getVerticalScrollAmount() + dy; + if (s < 0) + s = 0; + else if (s > getVerticalMaxScroll()) + s = getVerticalMaxScroll(); + + setVerticalScrollAmount(s); + } + mClickX = 0; + mClickY = 0; + event.consume(); + } + } + gcn::ScrollArea::mouseReleased(event); +} diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 095010f3c..56e21c58c 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -112,6 +112,10 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener */ void mouseExited(gcn::MouseEvent& event); + void mousePressed(gcn::MouseEvent& event); + + void mouseReleased(gcn::MouseEvent& event); + void widgetResized(const gcn::Event &event); void widgetMoved(const gcn::Event &event); @@ -148,6 +152,7 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener static Image *buttons[4][2]; int mX, mY; + int mClickX, mClickY; bool mHasMouse; bool mOpaque; GraphicsVertexes *mVertexes; diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 8abe727b5..6317dd56f 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -290,5 +290,12 @@ void SpellShortcutContainer::mouseMoved(gcn::MouseEvent &event) // Hide SpellTooltip void SpellShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) { - mSpellPopup->setVisible(false); + if (mSpellPopup) + mSpellPopup->setVisible(false); +} + +void SpellShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +{ + if (mSpellPopup) + mSpellPopup->setVisible(false); } diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index 2155e2a8b..88b00338a 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -77,6 +77,8 @@ class SpellShortcutContainer : public ShortcutContainer */ void mouseReleased(gcn::MouseEvent &event); + void widgetHidden(const gcn::Event &event); + private: void mouseExited(gcn::MouseEvent &event); void mouseMoved(gcn::MouseEvent &event); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 5d4fbc0b4..6ce4cbf3b 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -51,11 +51,11 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab, gcn::ActionListener* listener, std::string eventId, bool sendAlwaysEvents): gcn::TextField(text), + mSendAlwaysEvents(sendAlwaysEvents), mNumeric(false), mMinimum(0), mMaximum(0), - mLastEventPaste(false), - mSendAlwaysEvents(sendAlwaysEvents) + mLastEventPaste(false) { setFrameSize(2); diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 7e19099e8..93f970168 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -96,6 +96,12 @@ class TextField : public gcn::TextField */ int getValue() const; + void setSendAlwaysEvents(bool b) + { mSendAlwaysEvents = b; } + + protected: + bool mSendAlwaysEvents; + private: void handlePaste(); @@ -109,7 +115,6 @@ class TextField : public gcn::TextField int mMaximum; bool mLoseFocusOnTab; int mLastEventPaste; - bool mSendAlwaysEvents; }; #endif diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 510a68323..ffc27ab10 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -113,14 +113,14 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Called whenever the widget changes size. */ - void widgetResized(const gcn::Event &event); + virtual void widgetResized(const gcn::Event &event); virtual void widgetMoved(const gcn::Event& event); /** * Called whenever the widget is hidden. */ - virtual void widgetHidden(const gcn::Event& event); + virtual void widgetHidden(const gcn::Event &event); /** * Sets whether or not the window has a close button. |