Merge remote-tracking branch 'public/release_candidate' into release
[CRYENGINE.git] / Code / Sandbox / Plugins / EditorAnimation / CharacterTool / BlockPalette.h
blob7d8c1b76d033ae07a697497654d2df3863731669
1 // Copyright 2001-2019 Crytek GmbH / Crytek Group. All rights reserved.
3 #pragma once
4 #include <memory>
5 #include <QWidget>
7 #include <CrySerialization/Forward.h>
9 struct BlockPaletteContent;
10 struct BlockPaletteLayout;
11 struct BlockPaletteItem;
13 struct BlockPaletteSelectedId
15 union
17 long long userId;
18 void* userPointer;
21 BlockPaletteSelectedId()
22 : userId(0)
26 typedef std::vector<BlockPaletteSelectedId> BlockPaletteSelectedIds;
28 class BlockPalette : public QWidget
30 Q_OBJECT
31 public:
32 BlockPalette(QWidget* parent);
33 ~BlockPalette();
35 void SetContent(const BlockPaletteContent& content);
36 void SetAddEventWithSingleClick(bool addWithSingleClick);
37 const BlockPaletteContent& Content() const { return *m_content.get(); }
39 void GetSelectedIds(BlockPaletteSelectedIds* ids) const;
40 const BlockPaletteItem* GetItemByHotkey(int hotkey) const;
41 void Serialize(Serialization::IArchive& ar);
42 signals:
43 void SignalChanged();
44 void SignalSelectionChanged();
45 void SignalItemClicked(const BlockPaletteItem& item);
46 protected slots:
47 void OnMenuAdd();
48 void OnMenuDelete();
49 void OnMenuAddWithSingleClick();
50 void OnMenuAssignHotkey();
51 private:
52 struct MouseHandler;
53 struct SelectionHandler;
54 struct DragHandler;
56 void UpdateLayout();
57 void ItemClicked(int mouseButton);
58 void AssignHotkey(int hotkey);
60 void paintEvent(QPaintEvent* ev) override;
61 void mousePressEvent(QMouseEvent* ev) override;
62 void mouseMoveEvent(QMouseEvent* ev) override;
63 void mouseReleaseEvent(QMouseEvent* ev) override;
64 void mouseDoubleClickEvent(QMouseEvent* ev) override;
65 void keyPressEvent(QKeyEvent* ev) override;
66 void resizeEvent(QResizeEvent* ev) override;
67 void wheelEvent(QWheelEvent* ev) override;
69 std::unique_ptr<BlockPaletteContent> m_content;
70 std::unique_ptr<BlockPaletteLayout> m_layout;
71 std::unique_ptr<MouseHandler> m_mouseHandler;
73 std::vector<int> m_selectedItems;
74 std::vector<int> m_draggedItems;
75 std::vector<int> m_hotkeys;
76 bool m_addWithSingleClick;