22 #ifndef GUI_WIDGETS_GRID_H 23 #define GUI_WIDGETS_GRID_H 25 #include "gui/dialog.h" 26 #include "gui/widgets/scrollbar.h" 27 #include "common/str.h" 30 #include "image/png.h" 31 #include "graphics/svg.h" 35 class ScrollBarWidget;
41 kPlayButtonCmd =
'PLAY',
42 kEditButtonCmd =
'EDIT',
43 kLoadButtonCmd =
'LOAD',
44 kOpenTrayCmd =
'OPTR',
45 kItemClicked =
'LBX1',
46 kItemDoubleClickedCmd =
'LBX2',
52 bool isHeader, validEntry;
70 : entryID(
id), gameid(gid), engineid(eid), title(t), description(d), extra(e), language(l), platform(p), validEntry(v), canLoadGame(cl), isHeader(
false) {
75 isHeader(
true), validEntry(
true), entryID(groupID), language(Common::UNK_LANG), platform(Common::kPlatformUnknown) {
90 void enableLoadButton(
bool canLoad) { _loadButton->setEnabled(canLoad); }
92 void reflowLayout()
override;
94 void handleCommand(
CommandSender *sender, uint32 cmd, uint32 data)
override;
95 void handleMouseDown(
int x,
int y,
int button,
int clickCount)
override;
96 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
97 void handleMouseWheel(
int x,
int y,
int direction)
override;
98 void handleMouseMoved(
int x,
int y,
int button)
override;
138 int _scrollWindowHeight;
139 int _scrollWindowWidth;
144 int _thumbnailHeight;
148 int _platformIconHeight;
149 int _platformIconWidth;
150 int _extraIconHeight;
152 int _minGridXSpacing;
153 int _minGridYSpacing;
156 int _firstVisibleItem;
157 int _lastVisibleItem;
160 int _scrollWindowPaddingX;
161 int _scrollWindowPaddingY;
162 int _gridHeaderHeight;
163 int _gridHeaderWidth;
166 bool _multiSelectEnabled;
169 void *_filterMatcherArg;
174 bool _selectionPending;
175 int _dragStartY, _dragLastY;
176 uint32 _mouseDownTime;
177 static const int kDragThreshold = 5;
186 int _thumbnailMargin;
188 bool _isTitlesVisible;
204 bool calcVisibleEntries();
208 void setTitlesVisible(
bool vis);
209 void markGridAsInvalid() { _isGridInvalid =
true; }
214 bool groupExpanded(
int groupID) {
return _groupExpanded[groupID]; }
215 void toggleGroup(
int groupID);
219 void reloadThumbnails();
220 void loadFlagIcons();
221 void loadPlatformIcons();
222 void loadExtraIcons();
225 void calcInnerHeight();
226 void calcEntrySizes();
228 void move(
int x,
int y);
229 void scrollToEntry(
int id,
bool forceToTop);
230 void assignEntriesToItems();
232 int getItemPos(
int item);
233 int getNewSel(
int index);
234 int getVisualPos(
int entryID)
const;
235 void selectVisualRange(
int startPos,
int endPos);
236 float getScrollPos()
const {
return _scrollPos; }
237 int getSelected()
const {
return ((_selectedEntry ==
nullptr) ? -1 : _selectedEntry->entryID); }
238 int getThumbnailHeight()
const {
return _thumbnailHeight; }
239 int getThumbnailWidth()
const {
return _thumbnailWidth; }
241 void handleMouseWheel(
int x,
int y,
int direction)
override;
242 void handleMouseDown(
int x,
int y,
int button,
int clickCount)
override;
243 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
244 void handleMouseMoved(
int x,
int y,
int button)
override;
245 void handleTickle()
override;
246 void applyScrollPos();
247 void handleCommand(
CommandSender *sender, uint32 cmd, uint32 data)
override;
248 void reflowLayout()
override;
250 bool wantsFocus()
override {
return true; }
254 void openTrayAtSelected();
255 void scrollBarRecalc();
257 void setSelected(
int id);
259 void setFilterMatcher(FilterMatcher matcher,
void *arg) { _filterMatcher = matcher; _filterMatcherArg = arg; }
262 void setMultiSelectEnabled(
bool enabled) { _multiSelectEnabled = enabled; }
263 bool isMultiSelectEnabled()
const {
return _multiSelectEnabled; }
265 int _lastSelectedEntryID = -1;
266 bool isItemSelected(
int entryID)
const;
267 void markSelectedItem(
int entryID,
bool state);
268 void clearSelection();
276 Graphics::AlphaType _thumbAlpha;
285 void move(
int x,
int y);
290 void drawWidget()
override;
292 void handleMouseWheel(
int x,
int y,
int direction)
override;
293 void handleMouseEntered(
int button)
override;
294 void handleMouseLeft(
int button)
override;
295 void handleMouseDown(
int x,
int y,
int button,
int clickCount)
override;
296 void handleMouseUp(
int x,
int y,
int button,
int clickCount)
override;
297 void handleMouseMoved(
int x,
int y,
int button)
override;
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: printman.h:30
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: keyboard.h:294
Language
Definition: language.h:45