Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions source/gui/mostlyharmless_WebviewBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ namespace mostly_harmless::gui {
void create() {
m_clientView = helpers::macos::createView(m_initialWidth, m_initialHeight);
m_webview = std::make_unique<choc::ui::WebView>(m_options);
helpers::macos::setViewSize(m_clientView, m_initialWidth, m_initialHeight);
}

void destroy() {
Expand All @@ -198,9 +197,8 @@ namespace mostly_harmless::gui {
helpers::macos::getViewSize(m_clientView, width, height);
}

void setSize(std::uint32_t width, std::uint32_t height) {
helpers::macos::setViewSize(m_clientView, width, height);
helpers::macos::setViewSize(m_webview->getViewHandle(), width, height);
void setSize(std::uint32_t /*width*/, std::uint32_t /*height*/) {
// Because we're using autolayout and autoresizemask on macOS, this is handled already via the config in setParent
}

void setParent(void* parentHandle) {
Expand Down
10 changes: 9 additions & 1 deletion source/gui/platform/mostlyharmless_GuiHelpersMacOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ void getViewSize(void* viewHandle, std::uint32_t* width, std::uint32_t* height)
}

void reparentView(void* hostViewHandle, void* clientViewHandle, void* childViewHandle, Colour backgroundColour) {
createView(0, 0);
auto* host = static_cast<NSView*>(hostViewHandle);
auto* client = static_cast<NSView*>(clientViewHandle);
auto* child = static_cast<NSView*>(childViewHandle);
Expand All @@ -45,6 +44,15 @@ void reparentView(void* hostViewHandle, void* clientViewHandle, void* childViewH
CGFloat f32B = static_cast<CGFloat>(b) / 255.0f;
auto* color = [NSColor colorWithCalibratedRed:f32R green:f32G blue:f32B alpha:1];
[[client layer] setBackgroundColor:color.CGColor];
host.autoresizesSubviews = YES;
host.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
host.translatesAutoresizingMaskIntoConstraints = true;
client.autoresizesSubviews = YES;
client.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
client.translatesAutoresizingMaskIntoConstraints = true;
child.autoresizesSubviews = YES;
child.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
child.translatesAutoresizingMaskIntoConstraints = true;
client.frame = host.bounds;
child.frame = host.bounds;
[client addSubview:child];
Expand Down
9 changes: 7 additions & 2 deletions source/mostlyharmless_PluginBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ namespace mostly_harmless::internal {
_host.paramsRescan(CLAP_PARAM_RESCAN_VALUES);
},
.requestGuiResize = [this](std::uint32_t width, std::uint32_t height) -> bool {
return _host.guiRequestResize(width, height);
if (!_host.guiRequestResize(width, height)) {
return false;
}
if (!guiAdjustSize(&width, &height)) {
return false;
}
return guiSetSize(width, height);
}
};
m_state = m_pluginEntry->createState(std::move(context));
Expand Down Expand Up @@ -433,7 +439,6 @@ namespace mostly_harmless::internal {
bool PluginBase::guiAdjustSize(std::uint32_t* width, std::uint32_t* height) noexcept {
MH_LOG("GUI: guiAdjustSize()");
if (!m_editor) return false;
if (!m_editor->allowResize()) return false;
m_editor->onResizeRequested(width, height);
return true;
}
Expand Down