JANITORIAL: Formatting fixes

This commit is contained in:
av-dx 2021-08-01 16:48:17 +05:30 committed by Eugene Sandulenko
parent 0ef92b04bb
commit 477407f14c
4 changed files with 26 additions and 25 deletions

View File

@ -40,6 +40,7 @@ GridItemWidget::GridItemWidget(GridWidget *boss, int x, int y, int w, int h)
_grid = boss;
isHighlighted = false;
}
GridItemWidget::GridItemWidget(GridWidget *boss)
: GridItemWidget(boss, 0, 0, 0, 0) {}
@ -69,7 +70,8 @@ void GridItemWidget::move(int x, int y) {
void GridItemWidget::drawWidget() {
if (_activeEntry->isHeader) {
g_gui.theme()->drawFoldIndicator(Common::Rect(_x, _y, _x + _h, _y + _h), _grid->groupExpanded(_activeEntry->entryID));
g_gui.theme()->drawText(Common::Rect(_x + _h, _y, _x + _w, _y + _h), Common::U32String(_activeEntry->title), ThemeEngine::kStateEnabled, Graphics::kTextAlignLeft);
g_gui.theme()->drawText(Common::Rect(_x + _h, _y, _x + _w, _y + _h), Common::U32String(_activeEntry->title),
ThemeEngine::kStateEnabled, Graphics::kTextAlignLeft);
return;
}
int thumbHeight = _grid->getThumbnailHeight();
@ -197,17 +199,15 @@ void GridItemWidget::handleMouseDown(int x, int y, int button, int clickCount) {
if (_activeEntry->isHeader) {
_grid->_selectedEntry = nullptr;
_grid->toggleGroup(_activeEntry->entryID);
}
else if (isHighlighted && isVisible()) {
} else if (isHighlighted && isVisible()) {
_grid->_selectedEntry = _activeEntry;
sendCommand(kItemClicked, 0);
// Since user expected to click on "entry" and not the "widget", we
// must open the tray where the user expects it to be, which might
// not be at the new widget location.
// TODO: Make a scrollToSelection() function which does this
int offsetY = 0;
if (_y > (_grid->getHeight() - _h - _grid->_trayHeight)) {
offsetY = _y - (_grid->getHeight() - _h - _grid->_trayHeight);
int offsetY = _y - (_grid->getHeight() - _h - _grid->_trayHeight);
sendCommand(kSetPositionCmd, _grid->getScrollPos() + offsetY);
_grid->scrollBarRecalc();
_grid->markAsDirty();
@ -817,13 +817,14 @@ void GridWidget::reflowLayout() {
}
void GridWidget::openTray(int x, int y, int entryId) {
_tray = new GridItemTray(this, x - _gridXSpacing / 3, y, _gridItemWidth + 2 * (_gridXSpacing / 3), _trayHeight, entryId, this);
_tray = new GridItemTray(this, x - _gridXSpacing / 3, y, _gridItemWidth + 2 * (_gridXSpacing / 3), _trayHeight, entryId, this);
_tray->runModal();
}
void GridWidget::openTrayAtSelected() {
if (_selectedEntry) {
_tray = new GridItemTray(this, _x + _selectedEntry->rect.left - _gridXSpacing / 3, _y + _selectedEntry->rect.bottom - _scrollPos, _gridItemWidth + 2 * (_gridXSpacing / 3), _trayHeight, _selectedEntry->entryID, this);
_tray = new GridItemTray(this, _x + _selectedEntry->rect.left - _gridXSpacing / 3, _y + _selectedEntry->rect.bottom - _scrollPos,
_gridItemWidth + 2 * (_gridXSpacing / 3), _trayHeight, _selectedEntry->entryID, this);
_tray->runModal();
}
}

View File

@ -85,9 +85,9 @@ struct GridItemInfo {
/* GridItemTray */
class GridItemTray: public Dialog, public CommandSender {
int _entryID;
GridWidget *_grid;
GuiObject *_boss;
int _entryID;
GridWidget *_grid;
GuiObject *_boss;
public:
GridItemTray(GuiObject *boss, int x, int y, int w, int h, int entryID, GridWidget *grid);
@ -107,9 +107,9 @@ protected:
// Images are mapped by filename -> surface.
Common::HashMap<String, const Graphics::ManagedSurface *> _loadedSurfaces;
Common::Array<GridItemInfo> _dataEntryList;
Common::Array<GridItemInfo> _sortedEntryList;
Common::Array<GridItemInfo *> _visibleEntryList;
Common::Array<GridItemInfo> _dataEntryList;
Common::Array<GridItemInfo> _sortedEntryList;
Common::Array<GridItemInfo *> _visibleEntryList;
String _groupingAttribute;
Common::HashMap<U32String, int> _groupValueIndex;
@ -119,11 +119,11 @@ protected:
Common::Array<U32String> _groupHeaders;
Common::HashMap<int, Common::Array<int>> _itemsInGroup;
Common::Array<GridItemWidget *> _gridItems;
Common::Array<GridItemWidget *> _gridItems;
ScrollBarWidget *_scrollBar;
int _scrollBarWidth;
int _scrollBarWidth;
int _scrollWindowHeight;
int _scrollWindowWidth;
int _scrollSpeed;
@ -138,19 +138,19 @@ protected:
int _itemsPerRow;
int _firstVisibleItem;
int _itemsOnScreen;
GridItemTray *_tray;
String _iconDir;
GridItemTray *_tray;
String _iconDir;
public:
int _gridItemHeight;
int _gridItemWidth;
int _gridHeaderHeight;
int _gridHeaderWidth;
int _gridHeaderWidth;
int _gridXSpacing;
int _gridYSpacing;
int _trayHeight;
bool _isTitlesVisible;
bool _isTitlesVisible;
GridItemInfo *_selectedEntry;
@ -203,9 +203,9 @@ class GridItemWidget : public ContainerWidget, public CommandSender {
protected:
Graphics::ManagedSurface _thumbGfx;
GridItemInfo *_activeEntry;
GridWidget *_grid;
bool isHighlighted;
GridItemInfo *_activeEntry;
GridWidget *_grid;
bool isHighlighted;
public:
GridItemWidget(GridWidget *boss, int x, int y, int w, int h);

View File

@ -329,7 +329,7 @@ void GroupedListWidget::drawWidget() {
// Draw a thin frame around the list.
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h),
ThemeEngine::kWidgetBackgroundBorder);
ThemeEngine::kWidgetBackgroundBorder);
// Draw the list items
for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++) {

View File

@ -47,14 +47,14 @@ public:
void setList(const U32StringArray &list, const ColorList *colors = nullptr);
void setAttributeValues(const U32StringArray &attrValues);
const U32StringArray &getList() const { return _dataList; }
const U32StringArray &getList() const { return _dataList; }
void append(const String &s, ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal);
void setGroupHeaderFormat(const U32String &prefix, const U32String &suffix);
void groupByAttribute();
void setSelected(int item);
int getSelected() const { return (_selectedItem == -1) ? _selectedItem : _listIndex[_selectedItem]; }
int getSelected() const { return (_selectedItem == -1) ? _selectedItem : _listIndex[_selectedItem]; }
void handleMouseDown(int x, int y, int button, int clickCount) override;
void handleMouseUp(int x, int y, int button, int clickCount) override;