Merge pull request #3819 from arnova/subtitles_for_stacks
[vuplus_xbmc] / xbmc / dialogs / GUIDialogContextMenu.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include "guilib/GUIDialog.h"
24
25 class CMediaSource;
26
27 enum CONTEXT_BUTTON { CONTEXT_BUTTON_CANCELLED = 0,
28                       CONTEXT_BUTTON_LAUNCH,
29                       CONTEXT_BUTTON_RENAME,
30                       CONTEXT_BUTTON_DELETE,
31                       CONTEXT_BUTTON_COPY,
32                       CONTEXT_BUTTON_MOVE,
33                       CONTEXT_BUTTON_ADD_FAVOURITE,
34                       CONTEXT_BUTTON_SETTINGS,
35                       CONTEXT_BUTTON_GOTO_ROOT,
36                       CONTEXT_BUTTON_PLAY_DISC,
37                       CONTEXT_BUTTON_RESUME_DISC,
38                       CONTEXT_BUTTON_RIP_CD,
39                       CONTEXT_BUTTON_CANCEL_RIP_CD,
40                       CONTEXT_BUTTON_RIP_TRACK,
41                       CONTEXT_BUTTON_EJECT_DISC,
42                       CONTEXT_BUTTON_EJECT_DRIVE,
43                       CONTEXT_BUTTON_ADD_SOURCE,
44                       CONTEXT_BUTTON_EDIT_SOURCE,
45                       CONTEXT_BUTTON_REMOVE_SOURCE,
46                       CONTEXT_BUTTON_SET_DEFAULT,
47                       CONTEXT_BUTTON_CLEAR_DEFAULT,
48                       CONTEXT_BUTTON_SET_THUMB,
49                       CONTEXT_BUTTON_ADD_LOCK,
50                       CONTEXT_BUTTON_REMOVE_LOCK,
51                       CONTEXT_BUTTON_CHANGE_LOCK,
52                       CONTEXT_BUTTON_RESET_LOCK,
53                       CONTEXT_BUTTON_REACTIVATE_LOCK,
54                       CONTEXT_BUTTON_VIEW_SLIDESHOW,
55                       CONTEXT_BUTTON_RECURSIVE_SLIDESHOW,
56                       CONTEXT_BUTTON_REFRESH_THUMBS,
57                       CONTEXT_BUTTON_SWITCH_MEDIA,
58                       CONTEXT_BUTTON_MOVE_ITEM,
59                       CONTEXT_BUTTON_MOVE_HERE,
60                       CONTEXT_BUTTON_CANCEL_MOVE,
61                       CONTEXT_BUTTON_MOVE_ITEM_UP,
62                       CONTEXT_BUTTON_MOVE_ITEM_DOWN,
63                       CONTEXT_BUTTON_SAVE,
64                       CONTEXT_BUTTON_LOAD,
65                       CONTEXT_BUTTON_CLEAR,
66                       CONTEXT_BUTTON_QUEUE_ITEM,
67                       CONTEXT_BUTTON_PLAY_ITEM,
68                       CONTEXT_BUTTON_PLAY_WITH,
69                       CONTEXT_BUTTON_PLAY_PARTYMODE,
70                       CONTEXT_BUTTON_PLAY_PART,
71                       CONTEXT_BUTTON_RESUME_ITEM,
72                       CONTEXT_BUTTON_RESTART_ITEM,
73                       CONTEXT_BUTTON_EDIT,
74                       CONTEXT_BUTTON_EDIT_SMART_PLAYLIST,
75                       CONTEXT_BUTTON_INFO,
76                       CONTEXT_BUTTON_INFO_ALL,
77                       CONTEXT_BUTTON_CDDB,
78                       CONTEXT_BUTTON_REFRESH,
79                       CONTEXT_BUTTON_SCAN,
80                       CONTEXT_BUTTON_STOP_SCANNING,
81                       CONTEXT_BUTTON_SET_ARTIST_THUMB,
82                       CONTEXT_BUTTON_SET_SEASON_ART,
83                       CONTEXT_BUTTON_CANCEL_PARTYMODE,
84                       CONTEXT_BUTTON_MARK_WATCHED,
85                       CONTEXT_BUTTON_MARK_UNWATCHED,
86                       CONTEXT_BUTTON_SET_CONTENT,
87                       CONTEXT_BUTTON_ADD_TO_LIBRARY,
88                       CONTEXT_BUTTON_SONG_INFO,
89                       CONTEXT_BUTTON_EDIT_PARTYMODE,
90                       CONTEXT_BUTTON_LINK_MOVIE,
91                       CONTEXT_BUTTON_UNLINK_MOVIE,
92                       CONTEXT_BUTTON_GO_TO_ARTIST,
93                       CONTEXT_BUTTON_GO_TO_ALBUM,
94                       CONTEXT_BUTTON_PLAY_OTHER,
95                       CONTEXT_BUTTON_SET_ACTOR_THUMB,
96                       CONTEXT_BUTTON_UNLINK_BOOKMARK,
97                       CONTEXT_BUTTON_PLUGIN_SETTINGS,
98                       CONTEXT_BUTTON_SCRIPT_SETTINGS,
99                       CONTEXT_BUTTON_LASTFM_UNLOVE_ITEM,
100                       CONTEXT_BUTTON_LASTFM_UNBAN_ITEM,
101                       CONTEXT_BUTTON_HIDE,
102                       CONTEXT_BUTTON_SHOW_HIDDEN,
103                       CONTEXT_BUTTON_ADD,
104                       CONTEXT_BUTTON_ACTIVATE,
105                       CONTEXT_BUTTON_START_RECORD,
106                       CONTEXT_BUTTON_STOP_RECORD,
107                       CONTEXT_BUTTON_GROUP_MANAGER,
108                       CONTEXT_BUTTON_CHANNEL_MANAGER,
109                       CONTEXT_BUTTON_FILTER,
110                       CONTEXT_BUTTON_SET_MOVIESET_ART,
111                       CONTEXT_BUTTON_BEGIN,
112                       CONTEXT_BUTTON_END,
113                       CONTEXT_BUTTON_NOW,
114                       CONTEXT_BUTTON_FIND,
115                       CONTEXT_BUTTON_DELETE_PLUGIN,
116                       CONTEXT_BUTTON_SORTASC,
117                       CONTEXT_BUTTON_SORTBY,
118                       CONTEXT_BUTTON_SORTBY_CHANNEL,
119                       CONTEXT_BUTTON_SORTBY_NAME,
120                       CONTEXT_BUTTON_SORTBY_DATE,
121                       CONTEXT_BUTTON_MENU_HOOKS,
122                       CONTEXT_BUTTON_PLAY_AND_QUEUE,
123                       CONTEXT_BUTTON_PLAY_ONLY_THIS,
124                       CONTEXT_BUTTON_UPDATE_EPG,
125                       CONTEXT_BUTTON_RECORD_ITEM,
126                       CONTEXT_BUTTON_TAGS_ADD_ITEMS,
127                       CONTEXT_BUTTON_TAGS_REMOVE_ITEMS,
128                       CONTEXT_BUTTON_SET_MOVIESET,
129                       CONTEXT_BUTTON_MOVIESET_ADD_REMOVE_ITEMS,
130                       CONTEXT_BUTTON_BROWSE_INTO,
131                       CONTEXT_BUTTON_EDIT_SORTTITLE,
132                       CONTEXT_BUTTON_USER1,
133                       CONTEXT_BUTTON_USER2,
134                       CONTEXT_BUTTON_USER3,
135                       CONTEXT_BUTTON_USER4,
136                       CONTEXT_BUTTON_USER5,
137                       CONTEXT_BUTTON_USER6,
138                       CONTEXT_BUTTON_USER7,
139                       CONTEXT_BUTTON_USER8,
140                       CONTEXT_BUTTON_USER9,
141                       CONTEXT_BUTTON_USER10
142                     };
143
144 class CContextButtons : public std::vector< std::pair<unsigned int, CStdString> >
145 {
146 public:
147   void Add(unsigned int, const CStdString &label);
148   void Add(unsigned int, int label);
149 };
150
151 class CGUIDialogContextMenu :
152       public CGUIDialog
153 {
154 public:
155   CGUIDialogContextMenu(void);
156   virtual ~CGUIDialogContextMenu(void);
157   virtual bool OnMessage(CGUIMessage &message);
158   virtual bool OnAction(const CAction& action);
159   virtual void SetPosition(float posX, float posY);
160
161   static bool SourcesMenu(const CStdString &strType, const CFileItemPtr item, float posX, float posY);
162   static void SwitchMedia(const CStdString& strType, const CStdString& strPath);
163
164   static void GetContextButtons(const CStdString &type, const CFileItemPtr item, CContextButtons &buttons);
165   static bool OnContextButton(const CStdString &type, const CFileItemPtr item, CONTEXT_BUTTON button);
166
167   /*! \brief Show the context menu with the given choices
168    \param choices the choices available for the user.
169    \return -1 if no choice is made, else the chosen option.
170    */
171   static int ShowAndGetChoice(const CContextButtons &choices);
172
173 protected:
174   void SetupButtons();
175
176   /*! \brief Position the context menu in the middle of the focused control.
177    If no control is available it is positioned in the middle of the screen.
178    */
179   void PositionAtCurrentFocus();
180
181   virtual float GetWidth() const;
182   virtual float GetHeight() const;
183   virtual void OnInitWindow();
184   virtual void OnWindowLoaded();
185   virtual void OnDeinitWindow(int nextWindowID);
186   static CStdString GetDefaultShareNameByType(const CStdString &strType);
187   static void SetDefault(const CStdString &strType, const CStdString &strDefault);
188   static void ClearDefault(const CStdString &strType);
189   static CMediaSource *GetShare(const CStdString &type, const CFileItem *item);
190
191 private:
192   float m_coordX, m_coordY;
193   /// \brief Stored size of background image (height or width depending on grouplist orientation)
194   float m_backgroundImageSize;
195   int m_clickedButton;
196   CContextButtons m_buttons;
197 };