Skip to content

Commit

Permalink
Highlights cells under cursor while dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
CammyVee committed Mar 26, 2016
1 parent 545ed3e commit 773adc0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 40 deletions.
42 changes: 3 additions & 39 deletions mscore/palette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,33 +580,6 @@ int Palette::idx(const QPoint& p) const
return idx;
}

//---------------------------------------------------------
// idx2
// returns indexes outside of cells.size()
//---------------------------------------------------------

int Palette::idx2(const QPoint& p) const
{
if (columns() == 0)
return -1;
int rightBorder = width() % hgrid;
int hhgrid = hgrid + (rightBorder / columns());

int x = p.x();
int y = p.y();

int row = y / vgrid;
int col = x / hhgrid;

int nc = columns();
if (col > nc)
return -1;

int idx = row * nc + col;
if (idx < 0)
return -1;
return idx;
}

//---------------------------------------------------------
// idxRect
Expand Down Expand Up @@ -1007,20 +980,11 @@ void Palette::dragMoveEvent(QDragMoveEvent* ev)
if (i == -1)
return;

int n = cells.size();
int ii = i;
for (; ii < n; ++ii) {
if (cells[ii] == 0)
break;
}
if (ii == n)
return;

QRect r;
if (currentIdx != -1)
r = idxRect(currentIdx);
update(r | idxRect(ii));
currentIdx = i; //highlight cell under cursor
update(r | idxRect(i));
currentIdx = i;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -1100,7 +1064,7 @@ void Palette::dropEvent(QDropEvent* event)
e->setSelected(false);
bool ok = false;
if (event->source() == this) {
int i = idx2(event->pos());
int i = idx(event->pos());
if (i == -1) {
//Append
cells.append(cells[dragSrcIdx]);
Expand Down
1 change: 0 additions & 1 deletion mscore/palette.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ class Palette : public QWidget {
virtual void contextMenuEvent(QContextMenuEvent*);

int idx(const QPoint&) const;
int idx2(const QPoint&) const;
QRect idxRect(int);
void layoutCell(PaletteCell*);

Expand Down

0 comments on commit 773adc0

Please sign in to comment.