diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-07-01 23:18:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-07-02 23:50:33 +0300 |
commit | 1cafda1147c06a647e3d3f1e3f986d7296ccbd08 (patch) | |
tree | 920e60dbd1feb3657edc130aa6a4ba4af562454a /src/dragdrop.h | |
parent | b210f1b896039b4909ca5fb7abea8b437896a77a (diff) | |
download | mv-1cafda1147c06a647e3d3f1e3f986d7296ccbd08.tar.gz mv-1cafda1147c06a647e3d3f1e3f986d7296ccbd08.tar.bz2 mv-1cafda1147c06a647e3d3f1e3f986d7296ccbd08.tar.xz mv-1cafda1147c06a647e3d3f1e3f986d7296ccbd08.zip |
add support for drag and drop in spells window.
Diffstat (limited to 'src/dragdrop.h')
-rw-r--r-- | src/dragdrop.h | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/src/dragdrop.h b/src/dragdrop.h index d67c2623e..845420968 100644 --- a/src/dragdrop.h +++ b/src/dragdrop.h @@ -22,6 +22,7 @@ #define DRAGDROP_H #include "item.h" +#include "textcommand.h" #include "resources/image.h" @@ -51,7 +52,9 @@ class DragDrop mItemImage(item ? item->getImage() : nullptr), mSelItem(0), mSelItemColor(1), - mSource(source) + mSource(source), + mText(), + mTag() { if (mItemImage) mItemImage->incRef(); @@ -77,11 +80,14 @@ class DragDrop DragDropSource getSource() const { return mSource; } - void dragItem(Item *const item, const DragDropSource source) + void dragItem(Item *const item, + const DragDropSource source, + const int tag = 0) { if (mItemImage) mItemImage->decRef(); + mText.clear(); if (item) { mItem = item->getId(); @@ -89,14 +95,50 @@ class DragDrop mItemImage = item->getImage(); if (mItemImage) mItemImage->incRef(); + mSource = source; + mTag = tag; } else { mItem = 0; mItemColor = 1; mItemImage = nullptr; + mSource = DRAGDROP_SOURCE_EMPTY; + mTag = 0; + } + } + + void dragCommand(TextCommand *const command, + const DragDropSource source, + const int tag = 0) + { + if (mItemImage) + mItemImage->decRef(); + mItem = 0; + mItemColor = 1; + + if (command) + { + mText = command->getSymbol(); + mItemImage = command->getImage(); + if (mItemImage) + { + mItemImage->incRef(); + } + else if (mText.empty()) + { + mSource = DRAGDROP_SOURCE_EMPTY; + mTag = 0; + return; + } + } + else + { + mText.clear(); + mItemImage = nullptr; } mSource = source; + mTag = tag; } void clear() @@ -107,6 +149,7 @@ class DragDrop mItemColor = 1; mItemImage = nullptr; mSource = DRAGDROP_SOURCE_EMPTY; + mText.clear(); } bool isEmpty() const @@ -145,6 +188,12 @@ class DragDrop { } + const std::string &getText() + { return mText; } + + int getTag() + { return mTag; } + private: int mItem; uint8_t mItemColor; @@ -152,6 +201,8 @@ class DragDrop int mSelItem; uint8_t mSelItemColor; DragDropSource mSource; + std::string mText; + int mTag; }; extern DragDrop dragDrop; |