2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "guilib/GUIDialog.h"
22 CONTEXT_BUTTON_CANCELLED
= 0,
23 CONTEXT_BUTTON_RENAME
,
24 CONTEXT_BUTTON_DELETE
,
26 CONTEXT_BUTTON_SETTINGS
,
27 CONTEXT_BUTTON_RIP_CD
,
28 CONTEXT_BUTTON_CANCEL_RIP_CD
,
29 CONTEXT_BUTTON_RIP_TRACK
,
30 CONTEXT_BUTTON_EJECT_DRIVE
,
31 CONTEXT_BUTTON_EDIT_SOURCE
,
32 CONTEXT_BUTTON_REMOVE_SOURCE
,
33 CONTEXT_BUTTON_SET_DEFAULT
,
34 CONTEXT_BUTTON_CLEAR_DEFAULT
,
35 CONTEXT_BUTTON_SET_THUMB
,
36 CONTEXT_BUTTON_ADD_LOCK
,
37 CONTEXT_BUTTON_REMOVE_LOCK
,
38 CONTEXT_BUTTON_CHANGE_LOCK
,
39 CONTEXT_BUTTON_RESET_LOCK
,
40 CONTEXT_BUTTON_REACTIVATE_LOCK
,
41 CONTEXT_BUTTON_VIEW_SLIDESHOW
,
42 CONTEXT_BUTTON_RECURSIVE_SLIDESHOW
,
43 CONTEXT_BUTTON_REFRESH_THUMBS
,
44 CONTEXT_BUTTON_SWITCH_MEDIA
,
45 CONTEXT_BUTTON_MOVE_ITEM
,
46 CONTEXT_BUTTON_MOVE_HERE
,
47 CONTEXT_BUTTON_CANCEL_MOVE
,
48 CONTEXT_BUTTON_MOVE_ITEM_UP
,
49 CONTEXT_BUTTON_MOVE_ITEM_DOWN
,
51 CONTEXT_BUTTON_PLAY_ITEM
,
52 CONTEXT_BUTTON_PLAY_PARTYMODE
,
53 CONTEXT_BUTTON_PLAY_PART
,
55 CONTEXT_BUTTON_EDIT_SMART_PLAYLIST
,
57 CONTEXT_BUTTON_INFO_ALL
,
60 CONTEXT_BUTTON_SCAN_TO_LIBRARY
,
61 CONTEXT_BUTTON_SET_ARTIST_THUMB
,
62 CONTEXT_BUTTON_SET_ART
,
63 CONTEXT_BUTTON_CANCEL_PARTYMODE
,
64 CONTEXT_BUTTON_MARK_WATCHED
,
65 CONTEXT_BUTTON_MARK_UNWATCHED
,
66 CONTEXT_BUTTON_SET_CONTENT
,
67 CONTEXT_BUTTON_EDIT_PARTYMODE
,
68 CONTEXT_BUTTON_LINK_MOVIE
,
69 CONTEXT_BUTTON_UNLINK_MOVIE
,
70 CONTEXT_BUTTON_GO_TO_ARTIST
,
71 CONTEXT_BUTTON_GO_TO_ALBUM
,
72 CONTEXT_BUTTON_PLAY_OTHER
,
73 CONTEXT_BUTTON_SET_ACTOR_THUMB
,
74 CONTEXT_BUTTON_UNLINK_BOOKMARK
,
75 CONTEXT_BUTTON_ACTIVATE
,
76 CONTEXT_BUTTON_GROUP_MANAGER
,
77 CONTEXT_BUTTON_CHANNEL_MANAGER
,
78 CONTEXT_BUTTON_PLAY_AND_QUEUE
,
79 CONTEXT_BUTTON_PLAY_ONLY_THIS
,
80 CONTEXT_BUTTON_UPDATE_EPG
,
81 CONTEXT_BUTTON_TAGS_ADD_ITEMS
,
82 CONTEXT_BUTTON_TAGS_REMOVE_ITEMS
,
83 CONTEXT_BUTTON_SET_MOVIESET
,
84 CONTEXT_BUTTON_MOVIESET_ADD_REMOVE_ITEMS
,
85 CONTEXT_BUTTON_EDIT_SORTTITLE
,
86 CONTEXT_BUTTON_DELETE_ALL
,
88 CONTEXT_BUTTON_PLAY_NEXT
,
89 CONTEXT_BUTTON_NAVIGATE
,
90 CONTEXT_BUTTON_MANAGE_VIDEOVERSIONS
,
93 class CContextButtons
: public std::vector
< std::pair
<size_t, std::string
> >
96 void Add(unsigned int, const std::string
&label
);
97 void Add(unsigned int, int label
);
100 class CGUIDialogContextMenu
:
104 CGUIDialogContextMenu(void);
105 ~CGUIDialogContextMenu(void) override
;
106 bool OnMessage(CGUIMessage
&message
) override
;
107 bool OnAction(const CAction
& action
) override
;
108 void SetPosition(float posX
, float posY
) override
;
110 static bool SourcesMenu(const std::string
&strType
, const CFileItemPtr
& item
, float posX
, float posY
);
111 static void SwitchMedia(const std::string
& strType
, const std::string
& strPath
);
113 static void GetContextButtons(const std::string
&type
, const CFileItemPtr
& item
, CContextButtons
&buttons
);
114 static bool OnContextButton(const std::string
&type
, const CFileItemPtr
& item
, CONTEXT_BUTTON button
);
116 /*! Show the context menu with the given choices and return the index of the selected item,
119 static int Show(const CContextButtons
& choices
, int focusedButton
= 0);
121 /*! Legacy method that returns the context menu id, or -1 on cancel */
122 static int ShowAndGetChoice(const CContextButtons
&choices
);
127 /*! \brief Position the context menu in the middle of the focused control.
128 If no control is available it is positioned in the middle of the screen.
130 void PositionAtCurrentFocus();
132 float GetWidth() const override
;
133 float GetHeight() const override
;
134 void OnInitWindow() override
;
135 void OnWindowLoaded() override
;
136 void OnDeinitWindow(int nextWindowID
) override
;
137 static std::string
GetDefaultShareNameByType(const std::string
&strType
);
138 static void SetDefault(const std::string
&strType
, const std::string
&strDefault
);
139 static void ClearDefault(const std::string
&strType
);
140 static CMediaSource
*GetShare(const std::string
&type
, const CFileItem
*item
);
143 float m_coordX
, m_coordY
;
144 /// \brief Stored size of background image (height or width depending on grouplist orientation)
145 float m_backgroundImageSize
;
146 int m_initiallyFocusedButtonIdx
= 0;
148 CContextButtons m_buttons
;
149 const CGUIControl
*m_backgroundImage
= nullptr;