Skip to content

Commit

Permalink
Some work on resizability and resize request on Mac (#209)
Browse files Browse the repository at this point in the history
- Implmenet gui_can_resize etc... properly
- Have a callback so various hosts can do request_resize properly

With this short circuit zoom menu works on the clap-wraper side
even though the short circuit side and clap juce shim is still
kinda broken
  • Loading branch information
baconpaul authored and defiantnerd committed Feb 11, 2024
1 parent a47a300 commit ca037d4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
10 changes: 10 additions & 0 deletions src/detail/standalone/macos/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "detail/standalone/entry.h"
#include "detail/standalone/standalone_details.h"
#include "detail/standalone/standalone_host.h"

#include "detail/clap/fsutil.h"

Expand Down Expand Up @@ -102,6 +103,15 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
ui->show(p);
}

freeaudio::clap_wrapper::standalone::getStandaloneHost()->onRequestResize =
[self](uint32_t w, uint32_t h)
{
NSSize sz;
sz.width = w;
sz.height = h;
[[self window] setContentSize:sz];
return false;
};
freeaudio::clap_wrapper::standalone::mainStartAudio();
}

Expand Down
24 changes: 22 additions & 2 deletions src/detail/standalone/standalone_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ void StandaloneHost::setupAudioBusses(const clap_plugin_t *plugin,
for (auto i = 0U; i < numAudioInputs; ++i)
{
audioports->get(plugin, i, true, &info);
LOG << " - input " << i << " " << info.name << std::endl;
// LOG << " - input " << i << " " << info.name << std::endl;
inputChannelByBus.push_back(info.channel_count);
totalInputChannels += info.channel_count;
if (info.flags & CLAP_AUDIO_PORT_IS_MAIN) mainInput = i;
}
for (auto i = 0U; i < numAudioOutputs; ++i)
{
audioports->get(plugin, i, false, &info);
LOG << " - output " << i << " " << info.name << std::endl;
// LOG << " - output " << i << " " << info.name << std::endl;
outputChannelByBus.push_back(info.channel_count);
totalOutputChannels += info.channel_count;
if (info.flags & CLAP_AUDIO_PORT_IS_MAIN) mainOutput = i;
Expand Down Expand Up @@ -218,6 +218,26 @@ void StandaloneHost::clapProcess(void *pOutput, const void *pInput, uint32_t fra
}
}

bool StandaloneHost::gui_can_resize()
{
if (!clapPlugin) return false;

auto g = clapPlugin->_ext._gui;
if (!g) return false;

auto res = g->can_resize(clapPlugin->_plugin);
return res;
}

bool StandaloneHost::gui_request_resize(uint32_t width, uint32_t height)
{
if (onRequestResize)
{
return onRequestResize(width, height);
}
return false;
}

#if LIN

bool StandaloneHost::register_timer(uint32_t period_ms, clap_id *timer_id)
Expand Down
16 changes: 6 additions & 10 deletions src/detail/standalone/standalone_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,12 @@ struct StandaloneHost : Clap::IHost
void param_request_flush() override
{
}
bool gui_can_resize() override
{
TRACE;
return false;
}
bool gui_request_resize(uint32_t width, uint32_t height) override
{
TRACE;
return false;
}

bool gui_can_resize() override;

std::function<bool(uint32_t, uint32_t)> onRequestResize = [](auto, auto) { return false; };
bool gui_request_resize(uint32_t width, uint32_t height) override;

bool gui_request_show() override
{
TRACE;
Expand Down

0 comments on commit ca037d4

Please sign in to comment.