Browse Source

Auto-set FileBrowserOptions::className for UI, cleanup

Signed-off-by: falkTX <falktx@falktx.com>
pull/498/head
falkTX 2 months ago
parent
commit
8ae007d2f1
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 11 additions and 8 deletions
  1. +9
    -7
      dgl/src/WindowPrivateData.cpp
  2. +2
    -1
      distrho/DistrhoUI.hpp

+ 9
- 7
dgl/src/WindowPrivateData.cpp View File

@@ -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,
@@ -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);

@@ -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;
@@ -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));
@@ -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)
@@ -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;
@@ -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;


+ 2
- 1
distrho/DistrhoUI.hpp View File

@@ -185,7 +185,8 @@ public:
#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.


Loading…
Cancel
Save