Skip to content

Commit

Permalink
Auto-set FileBrowserOptions::className for UI, cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Feb 15, 2025
1 parent e35799c commit 8ae007d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 9 additions & 7 deletions dgl/src/WindowPrivateData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ bool Window::PrivateData::openFileBrowser(const FileBrowserOptions& options)
if (options2.title == nullptr)
options2.title = puglGetViewString(view, PUGL_WINDOW_TITLE);

options2.className = puglGetViewString(view, PUGL_CLASS_NAME);

fileBrowserHandle = fileBrowserCreate(isEmbed,
puglGetNativeView(view),
autoScaling ? autoScaleFactor : scaleFactor,
Expand Down Expand Up @@ -594,8 +596,8 @@ void Window::PrivateData::onPuglConfigure(const uint width, const uint height)
autoScaleFactor = 1.0;
}

const uint uwidth = static_cast<uint>(width / autoScaleFactor + 0.5);
const uint uheight = static_cast<uint>(height / autoScaleFactor + 0.5);
const uint uwidth = d_roundToUnsignedInt(width / autoScaleFactor);
const uint uheight = d_roundToUnsignedInt(height / autoScaleFactor);

self->onReshape(uwidth, uheight);

Expand Down Expand Up @@ -960,7 +962,7 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu
Widget::KeyboardEvent ev;
ev.mod = event->key.state;
ev.flags = event->key.flags;
ev.time = static_cast<uint>(event->key.time * 1000.0 + 0.5);
ev.time = d_roundToUnsignedInt(event->key.time * 1000.0);
ev.press = event->type == PUGL_KEY_PRESS;
ev.key = event->key.key;
ev.keycode = event->key.keycode;
Expand All @@ -983,7 +985,7 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu
Widget::CharacterInputEvent ev;
ev.mod = event->text.state;
ev.flags = event->text.flags;
ev.time = static_cast<uint>(event->text.time * 1000.0 + 0.5);
ev.time = d_roundToUnsignedInt(event->text.time * 1000.0);
ev.keycode = event->text.keycode;
ev.character = event->text.character;
std::strncpy(ev.string, event->text.string, sizeof(ev.string));
Expand All @@ -1006,7 +1008,7 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu
Widget::MouseEvent ev;
ev.mod = event->button.state;
ev.flags = event->button.flags;
ev.time = static_cast<uint>(event->button.time * 1000.0 + 0.5);
ev.time = d_roundToUnsignedInt(event->button.time * 1000.0);
ev.button = event->button.button + 1;
ev.press = event->type == PUGL_BUTTON_PRESS;
if (pData->autoScaling && 0)
Expand All @@ -1029,7 +1031,7 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu
Widget::MotionEvent ev;
ev.mod = event->motion.state;
ev.flags = event->motion.flags;
ev.time = static_cast<uint>(event->motion.time * 1000.0 + 0.5);
ev.time = d_roundToUnsignedInt(event->motion.time * 1000.0);
if (pData->autoScaling && 0)
{
const double scaleFactor = pData->autoScaleFactor;
Expand All @@ -1050,7 +1052,7 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu
Widget::ScrollEvent ev;
ev.mod = event->scroll.state;
ev.flags = event->scroll.flags;
ev.time = static_cast<uint>(event->scroll.time * 1000.0 + 0.5);
ev.time = d_roundToUnsignedInt(event->scroll.time * 1000.0);
if (pData->autoScaling && 0)
{
const double scaleFactor = pData->autoScaleFactor;
Expand Down
3 changes: 2 additions & 1 deletion distrho/DistrhoUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ class UI : public UIWidget
#if DISTRHO_UI_FILE_BROWSER
/**
Open a file browser dialog with this window as transient parent.@n
A few options can be specified to setup the dialog.
A few options can be specified to setup the dialog.@n
The @a DISTRHO_NAMESPACE::FileBrowserOptions::className variable is automatically set in this call.
If a path is selected, onFileSelected() will be called with the user chosen path.
If the user cancels or does not pick a file, onFileSelected() will be called with nullptr as filename.
Expand Down

0 comments on commit 8ae007d

Please sign in to comment.