Skip to content

Commit

Permalink
UI: Fix compiling error on Ubuntu
Browse files Browse the repository at this point in the history
Makes sure ceil function uses std namespace
  • Loading branch information
cg2121 authored and Lain-B committed May 21, 2023
1 parent 1d45881 commit 2089628
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions UI/scene-tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QDropEvent>
#include <QPushButton>
#include <QTimer>
#include <cmath>

SceneTree::SceneTree(QWidget *parent_) : QListWidget(parent_)
{
Expand Down Expand Up @@ -81,7 +82,7 @@ void SceneTree::resizeEvent(QResizeEvent *event)
}

int wid = contentsRect().width() - scrollWid - 1;
int items = (int)ceil((float)wid / maxWidth);
int items = (int)std::ceil((float)wid / maxWidth);
int itemWidth = wid / items;

setGridSize(QSize(itemWidth, itemHeight));
Expand Down Expand Up @@ -133,10 +134,10 @@ void SceneTree::dropEvent(QDropEvent *event)
QPoint point = event->pos();
#endif

int x = (float)point.x() / wid * ceil(wid / maxWidth);
int x = (float)point.x() / wid * std::ceil(wid / maxWidth);
int y = (point.y() + firstItemY) / itemHeight;

int r = x + y * ceil(wid / maxWidth);
int r = x + y * std::ceil(wid / maxWidth);

QListWidgetItem *item = takeItem(selectedIndexes()[0].row());
insertItem(r, item);
Expand Down Expand Up @@ -178,10 +179,10 @@ void SceneTree::RepositionGrid(QDragMoveEvent *event)
QPoint point = event->pos();
#endif

int x = (float)point.x() / wid * ceil(wid / maxWidth);
int x = (float)point.x() / wid * std::ceil(wid / maxWidth);
int y = (point.y() + firstItemY) / itemHeight;

int r = x + y * ceil(wid / maxWidth);
int r = x + y * std::ceil(wid / maxWidth);
int orig = selectedIndexes()[0].row();

for (int i = 0; i < count(); i++) {
Expand All @@ -196,8 +197,8 @@ void SceneTree::RepositionGrid(QDragMoveEvent *event)
(i > orig && i > r ? 1 : 0) -
(i > orig && i == r ? 2 : 0);

int xPos = (i + off) % (int)ceil(wid / maxWidth);
int yPos = (i + off) / (int)ceil(wid / maxWidth);
int xPos = (i + off) % (int)std::ceil(wid / maxWidth);
int yPos = (i + off) / (int)std::ceil(wid / maxWidth);
QSize g = gridSize();

QPoint position(xPos * g.width(), yPos * g.height());
Expand All @@ -212,8 +213,8 @@ void SceneTree::RepositionGrid(QDragMoveEvent *event)

QModelIndex index = indexFromItem(wItem);

int xPos = i % (int)ceil(wid / maxWidth);
int yPos = i / (int)ceil(wid / maxWidth);
int xPos = i % (int)std::ceil(wid / maxWidth);
int yPos = i / (int)std::ceil(wid / maxWidth);
QSize g = gridSize();

QPoint position(xPos * g.width(), yPos * g.height());
Expand Down

0 comments on commit 2089628

Please sign in to comment.