GUI: Set tray height according to line height

This commit is contained in:
av-dx 2021-06-27 12:57:59 +05:30 committed by Eugene Sandulenko
parent e9f068f497
commit af36819694
2 changed files with 8 additions and 9 deletions

View File

@ -148,18 +148,19 @@ void GridItemWidget::handleMouseMoved(int x, int y, int button) {
void GridItemWidget::handleMouseDown(int x, int y, int button, int clickCount) {
if (isHighlighted) {
// Work in progress
_grid->openTray(getAbsX() - _grid->_gridXSpacing / 3, getAbsY() + _h, _w + 2 * (_grid->_gridXSpacing / 3), _h / 3, _activeEntry->entryID);
_grid->openTray(getAbsX() - _grid->_gridXSpacing / 3, getAbsY() + _h, _w + 2 * (_grid->_gridXSpacing / 3), kLineHeight * 3, _activeEntry->entryID);
_grid->_tray->runModal();
}
}
#pragma mark -
GridItemTray::GridItemTray(GuiObject *boss, int x, int y, int w, int h, int entryID)
GridItemTray::GridItemTray(GuiObject *boss, int x, int y, int w, int h, int entryID, GridWidget *grid)
: Dialog(x, y, w, h), CommandSender(boss) {
_entryID = entryID;
_boss = boss;
_grid = grid;
int buttonWidth = w / 3;
int buttonHeight = h / 3;
@ -198,10 +199,7 @@ void GridItemTray::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
void GridItemTray::handleMouseDown(int x, int y, int button, int clickCount) {
Dialog::handleMouseDown(x, y, button, clickCount);
// HACK: Tray height is determined relative to grid item height
// hence we know the grid item height from within the tray.
// We might want to make tray height independent of grid item height.
if ((x < 0 || x > _w) || (y > _h || y < -(_h * 3))) {
if ((x < 0 || x > _w) || (y > _h || y < -(_grid->_gridItemHeight))) {
// Close on clicking outside
close();
} else if (y < 0 && clickCount >= 2) {
@ -608,7 +606,7 @@ void GridWidget::reflowLayout() {
for (int k = 0; k < _itemsOnScreen; ++k) {
GridItemWidget *newItem = new GridItemWidget(this,
_minGridXSpacing + col * (_gridItemWidth + _gridXSpacing),
2 * _minGridXSpacing + col * (_gridItemWidth + _gridXSpacing),
(_scrollPos % (_gridItemHeight + _gridYSpacing)) + _gridYSpacing + (row - 1) * (_gridItemHeight + _gridYSpacing),
_gridItemWidth,
_gridItemHeight);
@ -627,7 +625,7 @@ void GridWidget::reflowLayout() {
}
void GridWidget::openTray(int x, int y, int w, int h, int entryId) {
_tray = new GridItemTray(_boss, x, y, w, h, entryId);
_tray = new GridItemTray(_boss, x, y, w, h, entryId, this);
}
void GridWidget::scrollBarRecalc() {

View File

@ -89,6 +89,7 @@ struct GridItemInfo
/* GridItemTray */
class GridItemTray: public Dialog, public CommandSender {
int _entryID;
GridWidget *_grid;
GuiObject *_boss;
public:
typedef Common::String String;
@ -97,7 +98,7 @@ public:
typedef Common::U32String U32String;
typedef Common::Array<Common::U32String> U32StringArray;
GridItemTray(GuiObject *boss, int x, int y, int w, int h, int entryID);
GridItemTray(GuiObject *boss, int x, int y, int w, int h, int entryID, GridWidget *grid);
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
void handleMouseDown(int x, int y, int button, int clickCount) override;