Skip to content

Commit

Permalink
Fixed and simplified Playlist dragging creation on both x11 and Wayland.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Jun 4, 2024
1 parent 09313e3 commit 13d28a1
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 62 deletions.
1 change: 1 addition & 0 deletions mrv2/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ v1.1.9
Y coordinate of the panel and using X instead.
- Improved UI behavior when docking, undocking and showing/hiding the
scrollbars.
- Fixed Playlist creation on Wayland and simplified code.
- Fixed Panel Windows under Wayland. Now they respect their position, albeit
they are parented to the main window.
- Fixed a random crash when opening the Flmm_ColorA_Chooser for the first time
Expand Down
18 changes: 5 additions & 13 deletions mrv2/lib/mrvPanels/mrvPanelWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,13 @@ namespace mrv
end_group();
}

math::Box2i PanelWidget::box() const
math::Box2i PanelWidget::global_box() const
{
math::Box2i b;
if (!g->docked())
{
auto w = g->get_window();
b = math::Box2i(
g->x() + w->x(), g->y() + w->y(), g->w(), g->h());
}
else
{
b = math::Box2i(g->x(), g->y(), g->w(), g->h());
}
return b;
const Fl_Window* w = g->window();
return math::Box2i(
g->x() + w->x(), g->y() + w->y(), g->w(), g->h());
}

void PanelWidget::begin_group()
{
g->clear();
Expand Down
6 changes: 4 additions & 2 deletions mrv2/lib/mrvPanels/mrvPanelWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ namespace mrv
void clear_controls();
void refresh();

math::Box2i box() const;

//! Return the group box in global coordinates.
math::Box2i global_box() const;

bool is_panel() const { return g->docked(); };

virtual void save();

virtual void dock();
Expand Down
25 changes: 12 additions & 13 deletions mrv2/lib/mrvPanels/mrvPlaylistPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ namespace mrv
_r(new Private),
ThumbnailPanel(ui)
{
MRV2_R();

add_group("Playlist");
g->bind_image(load_svg("Playlist.svg"));

Expand All @@ -73,19 +75,19 @@ namespace mrv
},
ui);

_r->filesObserver = observer::
r.filesObserver = observer::
ListObserver<std::shared_ptr<FilesModelItem> >::create(
ui->app->filesModel()->observeFiles(),
[this](const std::vector< std::shared_ptr<FilesModelItem> >&
value) { refresh(); });

_r->activeObserver = observer::
r.activeObserver = observer::
ListObserver<std::shared_ptr<FilesModelItem> >::create(
ui->app->filesModel()->observeActive(),
[this](const std::vector< std::shared_ptr<FilesModelItem> >&
value) { redraw(); });

_r->aIndexObserver = observer::ValueObserver<int>::create(
r.aIndexObserver = observer::ValueObserver<int>::create(
ui->app->filesModel()->observeAIndex(),
[this](int value) { redraw(); });
}
Expand Down Expand Up @@ -302,16 +304,11 @@ namespace mrv
{
int aIndex = -1;
bool validDrop = false;
math::Vector2i win;
if (!is_panel())
{
auto window = g->get_window();
win.x = window->x();
win.y = window->y();
}
int winX = g->window()->x();
int winY = g->window()->y();
if (_r->map.empty())
{
math::Box2i box(g->x() + win.x, g->y() + win.y, g->w(), 68);
math::Box2i box = global_box();
if (box.contains(pos))
{
validDrop = true;
Expand All @@ -328,8 +325,8 @@ namespace mrv
for (auto& m : _r->map)
{
PlaylistButton* b = m.second;
math::Box2i box(
b->x() + win.x, b->y() + win.y, b->w(), b->h());
const math::Box2i box(
b->x() + winX, b->y() + winY, b->w(), b->h());
if (box.contains(pos))
{
aIndex = static_cast<int>(m.first);
Expand All @@ -346,6 +343,8 @@ namespace mrv
add_clip_to_timeline_cb(index, ui);
}
}


} // namespace panel

} // namespace mrv
28 changes: 5 additions & 23 deletions mrv2/lib/mrvWidgets/mrvFileButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "mrvEdit/mrvEditCallbacks.h"

#include "mrvUI/mrvDesktop.h"

#include "mrvPanels/mrvPanelsCallbacks.h"

#include "mrvApp/mrvFilesModel.h"
Expand Down Expand Up @@ -126,14 +128,7 @@ namespace mrv

if (playlistPanel)
{
math::Box2i box = playlistPanel->box();
if (playlistPanel->is_panel())
{
auto w = window();
pos.x -= w->x();
pos.y -= w->y();
}

const math::Box2i& box = playlistPanel->global_box();
if (box.contains(pos))
{
playlistPanel->add(pos, p.index, ui);
Expand Down Expand Up @@ -175,22 +170,9 @@ namespace mrv
int X = Fl::event_x_root();
int Y = Fl::event_y_root();
auto window = p.drag->window();
#ifdef __linux__
# ifdef FLTK_USE_WAYLAND
if (fl_wl_display())
{
window->resize(X, Y, window->w(), window->h());
}
else
{
window->position(X, Y);
}
# else
window->position(X, Y);
# endif
#else
window->position(X, Y);
#endif
if (window->parent())
window->parent()->init_sizes();
return 1;
}
}
Expand Down
17 changes: 6 additions & 11 deletions mrv2/lib/mrvWidgets/mrvFileDragger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#include <FL/Fl_Box.H>
#include <FL/Fl_Double_Window.H>

#include "mrvWidgets/mrvMainWindow.h"
#include "mrvWidgets/mrvFileDragger.h"

#include "mrvUI/mrvDesktop.h"

#include "mrViewer.h"

#include <FL/platform.H>
Expand All @@ -16,7 +17,6 @@ namespace mrv
{
struct FileDragger::Private
{
MainWindow* parent;
MainWindow* window;
Fl_Box* box;
};
Expand All @@ -28,18 +28,12 @@ namespace mrv

int X = Fl::event_x_root();
int Y = Fl::event_y_root();
#ifdef FLTK_USE_WAYLAND
if (fl_wl_display())
{
p.parent = App::ui->uiMain;

Fl_Group::current(p.parent);

X -= p.parent->x();
Y -= p.parent->y();
if (desktop::Wayland())
{
Fl_Group::current(App::ui->uiMain);
}
else
#endif
{
Fl_Group::current(0);
}
Expand All @@ -48,6 +42,7 @@ namespace mrv
const int H = 80;

p.window = new MainWindow(X, Y, W, H);
p.window->allow_expand_outside_parent();
p.window->border(0);
p.window->begin();
p.box = new Fl_Box(0, 0, W, H);
Expand Down

0 comments on commit 13d28a1

Please sign in to comment.