Skip to content

Commit

Permalink
Cleaned up code.
Browse files Browse the repository at this point in the history
Bug on X11 at least when cursor does not change when color of widget
is changed.
  • Loading branch information
ggarra13 committed May 12, 2024
1 parent aec88da commit 5e79a05
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
2 changes: 0 additions & 2 deletions mrv2/lib/mrvGL/mrvTimelineViewportEvents.cpp
Expand Up @@ -898,8 +898,6 @@ namespace mrv
case FL_LEAVE:
{
p.lastEvent = 0;

set_cursor(FL_CURSOR_DEFAULT);
const float NaN = std::numeric_limits<float>::quiet_NaN();
image::Color4f rgba(NaN, NaN, NaN, NaN);
_updatePixelBar(rgba);
Expand Down
41 changes: 22 additions & 19 deletions mrv2/lib/mrvWidgets/mrvTile.cpp
Expand Up @@ -83,12 +83,14 @@

#include "mrvGL/mrvTimelineViewport.h"

namespace mrv
namespace
{
#define DRAGV 2
#define GRABAREA 4
const int kDRAGV = 2;
const int kGRABAREA = 4;
} // namespace

#define CROSS
namespace mrv
{

struct WidgetData
{
Expand Down Expand Up @@ -194,7 +196,7 @@ namespace mrv
static void tile_set_dragbar_color(Fl_Tile* t, Fl_Cursor c)
{
Fl_Widget* tg = t->child(2); // mrv::TimelineGroup
if (c != cursors[DRAGV])
if (c != cursors[kDRAGV])
{
tg->color(51); // default color;
}
Expand All @@ -211,8 +213,8 @@ namespace mrv
if (cursor == c || !t->window())
return;
cursor = c;
t->window()->cursor(c);
tile_set_dragbar_color(t, c);
t->window()->cursor(c);
}

int Tile::handle(int event)
Expand Down Expand Up @@ -250,8 +252,8 @@ namespace mrv
Fl_Widget* o = *a++;
if (o == resizable())
continue;
if (p->r() < q->r() && o->y() <= my + GRABAREA &&
o->y() + o->h() >= my - GRABAREA)
if (p->r() < q->r() && o->y() <= my + kGRABAREA &&
o->y() + o->h() >= my - kGRABAREA)
{
int t = mx - (o->x() + o->w());
if (abs(t) < mindx)
Expand All @@ -261,8 +263,8 @@ namespace mrv
oldx = p->r();
}
}
if (p->b() < q->b() && o->x() <= mx + GRABAREA &&
o->x() + o->w() >= mx - GRABAREA)
if (p->b() < q->b() && o->x() <= mx + kGRABAREA &&
o->x() + o->w() >= mx - kGRABAREA)
{
int t = my - (o->y() + o->h());
if (abs(t) < mindy)
Expand All @@ -275,12 +277,14 @@ namespace mrv
}
sdrag = 0;
sx = sy = 0;
if (mindy <= GRABAREA)
if (mindy <= kGRABAREA)
{
sdrag |= DRAGV;
sdrag |= kDRAGV;
sy = oldy;
}
tile_set_cursor(this, cursors[sdrag]);

Fl_Cursor cursor = cursors[sdrag];
tile_set_cursor(this, cursor);
if (sdrag)
return 1;
return Fl_Group::handle(event);
Expand All @@ -302,7 +306,7 @@ namespace mrv
r = this;
int newx = sx;
int newy;
if (sdrag & DRAGV)
if (sdrag & kDRAGV)
{
newy = Fl::event_y() - sdy;
if (newy < r->y())
Expand Down Expand Up @@ -347,8 +351,8 @@ namespace mrv
Fl_Widget* o = *a++;
if (o == resizable())
continue;
if (p->b() < q->b() && o->x() <= mx + GRABAREA &&
o->x() + o->w() >= mx - GRABAREA)
if (p->b() < q->b() && o->x() <= mx + kGRABAREA &&
o->x() + o->w() >= mx - kGRABAREA)
{
int t = my - (o->y() + o->h());
if (abs(t) < mindy)
Expand All @@ -361,14 +365,13 @@ namespace mrv
}
sdrag = 0;
sx = sy = 0;
if (mindy <= GRABAREA)
if (mindy <= kGRABAREA)
{
sdrag |= DRAGV;
sdrag |= kDRAGV;
sy = oldy;
}

Fl_Cursor cursor = cursors[sdrag];

tile_set_cursor(this, cursor);
}

Expand Down

0 comments on commit 5e79a05

Please sign in to comment.