COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 05-23-2021, 12:10 AM   #1
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 70
Default How to use Swell?

How to use Swell for OSX?

I can not compile the plugins or any application if I add Swell. I tried everything: IPlug 2, Oli and Tale version.

Where do I find instructions on how to use it? I added the Swell directory to the project and I inserted #include "swell.h" but receive lot of errors in XCode like:

Code:
error: invalid use of incomplete type 'struct HWND__'
error: forward declaration of 'struct HWND__'
error: invalid use of incomplete type 'struct HWND__'
TonyGlover is offline   Reply With Quote
Old 05-23-2021, 02:37 AM   #2
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

I think I include only specific parts of SWELL in my IPlug version, namely:
  • swell.h
  • swell-gdi.mm
  • swell-internal.h
Tale is offline   Reply With Quote
Old 05-23-2021, 04:48 AM   #3
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 70
Default

The error has changed: duplicate symbol SelectObject(HDC__*, HGDIOBJ__*)
TonyGlover is offline   Reply With Quote
Old 05-23-2021, 08:09 AM   #4
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

If it's for use in a REAPER plugin: don't build any of the SWELL source files. The implementation of the SWELL functions should be loaded at runtime from REAPER instead. (So that future updates to SWELL are applied to the plugin, and to reduce unnecessary duplication.)

Define SWELL_PROVIDED_BY_APP before including swell.h and only build the loader: swell-modstub.mm (swell-modstub-generic.cpp on Linux).
cfillion is offline   Reply With Quote
Old 05-23-2021, 09:34 AM   #5
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 70
Default

Error again
TonyGlover is offline   Reply With Quote
Old 05-25-2021, 03:30 AM   #6
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 70
Default

I just managed to reduce the number of errors to one:

swell-gdi.mm:162: error: conversion from 'objc_object*' to non-scalar type '_NSRect' requested

This error occurs when I try to compile the sample_project from WDL>Swell
TonyGlover is offline   Reply With Quote
Old 05-28-2021, 04:50 PM   #7
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

IPlug2 app target is using swell. It's a good example to follow. Or you can look at the swell sample_project in WDL or the lice demo.
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 06-04-2021, 04:46 AM   #8
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 70
Default

I added swell-modstub.mm to the project to be compiled. I added to the header file of the plugin #include "../../../WDL-tale/WDL/swell/swell.h"
But I receive this error:
Code:
  "SWELL_LoadCursor(char const*)", referenced from:
      MyBar::ValToMouse(int, int, bool, bool)in Main.o
ld: symbol(s) not found
If I add swell-kb.mm the project to be compiled. I get this error:
Code:
  "SWELL_CStringToCFString(char const*)", referenced from:
      swell_imageFromCursorString(char const*, POINT*)in swell-kb.o
      swell_imageFromCursorString(char const*, POINT*)in swell-kb.o
  "GetTickCount()", referenced from:
      swell_imageFromCursorString(char const*, POINT*)in swell-kb.o
  "GetTempPath(int, char*)", referenced from:
      swell_imageFromCursorString(char const*, POINT*)in swell-kb.o
  "GetModuleFileName(void*, char*, unsigned int)", referenced from:
      swell_imageFromCursorString(char const*, POINT*)in swell-kb.o
ld: symbol(s) not found
TonyGlover is offline   Reply With Quote
Old 06-04-2021, 05:10 AM   #9
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

you're on the right track. The compiler reports missing symbols, so you need to add the implementation file with those missing things.

SWELL_CStringToCFString is in swell-misc.mm

https://github.com/justinfrankel/WDL...ll-misc.mm#L87

If you don't compile that with your code you'll get an error.


BUT - if you are trying to do something with modstub, you have to link against swell.dylib, rather than compiling swell-misc.mm etc with your project

https://github.com/justinfrankel/WDL...modstub.mm#L29
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 06-04-2021, 08:39 AM   #10
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by TonyGlover View Post
I added swell-modstub.mm to the project to be compiled. I added to the header file of the plugin #include "../../../WDL-tale/WDL/swell/swell.h"
But I receive this error:
Code:
  "SWELL_LoadCursor(char const*)", referenced from:
      MyBar::ValToMouse(int, int, bool, bool)in Main.o
ld: symbol(s) not found
Was SWELL_PROVIDED_BY_APP defined before main.cpp included swell.h?
cfillion is offline   Reply With Quote
Old 06-04-2021, 10:43 AM   #11
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 70
Default

Quote:
Originally Posted by olilarkin View Post
you're on the right track. The compiler reports missing symbols, so you need to add the implementation file with those missing things.

SWELL_CStringToCFString is in swell-misc.mm

https://github.com/justinfrankel/WDL...ll-misc.mm#L87

If you don't compile that with your code you'll get an error.


BUT - if you are trying to do something with modstub, you have to link against swell.dylib, rather than compiling swell-misc.mm etc with your project

https://github.com/justinfrankel/WDL...modstub.mm#L29
Thanks Oli, worked

I added swell-misc.mm and swell.cpp.

Thanks to everyone for your great help!!!
TonyGlover is offline   Reply With Quote
Old 06-25-2021, 05:19 AM   #12
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 70
Default

One more question please.

How to use SWELL_InitiateDragDrop ?

I want to make my own Control that accepts drag and drops files on the control area. How do I make that?
TonyGlover is offline   Reply With Quote
Old 06-25-2021, 01:31 PM   #13
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

That's for dragging. For dropping files, enable the WS_EX_ACCEPTFILES exstyle and handle the WM_DROPFILES message.
cfillion is offline   Reply With Quote
Old 06-26-2021, 02:48 AM   #14
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 70
Default

Where to set WS_EX_ACCEPTFILES exstyle ?

The window was created, SetExtendedStyle do not exist, DragAcceptFiles(hWnd, true); do not exist.

I see internal swellSetExtendedStyle(WS_EX_ACCEPTFILES) but how to use it ?
TonyGlover is offline   Reply With Quote
Old 06-26-2021, 03:25 AM   #15
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Code:
SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_ACCEPTFILES); // (might want to preserve existing styles)

Last edited by cfillion; 06-26-2021 at 03:32 AM.
cfillion is offline   Reply With Quote
Old 06-26-2021, 07:38 AM   #16
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 70
Default

I tried like this, but it doesn't work.

Cannot work exactly like windows I suppose, there is a variable m_supports_ddrop which is false, this disable drop actions.

Maybe must call swellSetExtendedStyle to set m_supports_ddrop=true
TonyGlover is offline   Reply With Quote
Old 06-26-2021, 01:57 PM   #17
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by TonyGlover View Post
I tried like this, but it doesn't work.

Cannot work exactly like windows I suppose, there is a variable m_supports_ddrop which is false, this disable drop actions.

Maybe must call swellSetExtendedStyle to set m_supports_ddrop=true
SetWindowLong calls swellSetExtendedStyle. (WS_EX_ACCEPTFILES can also be put in the resource file, mac_resgen.php supports it.)

This works here:

Code:
WDL_DLGRET DialogProc(HWND handle, UINT msg, WPARAM wParam, LPARAM lParam)
{
  switch(msg) {
  case WM_INITDIALOG:
    SetWindowLong(handle, GWL_EXSTYLE, WS_EX_ACCEPTFILES);
    return 0;
  case WM_DROPFILES: {
    HDROP drop { reinterpret_cast<HDROP>(wParam) };
    unsigned int count { DragQueryFile(drop, -1, nullptr, 0) };
    printf("dropped %d files\n", count);
    DragFinish(drop);
    return 0;
  }
  // ...
  }
}
cfillion is offline   Reply With Quote
Old 06-27-2021, 04:37 AM   #18
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 70
Default

I tested with trace to check but do not accept drag & drop for any file. Trace are not called when drop any file on plugin area.

Please can you give an example how to use what you say to make a plugin with framework Iplug OLi, Iplug Tale or even Iplug 2 ?

I tried in VST CTOR after AttachGraphics(pGraphics);:

Code:
SetWindowLong((HWND)pGraphics->GetWindow(), GWL_EXSTYLE, WS_EX_ACCEPTFILES);
TonyGlover is offline   Reply With Quote
Old 06-27-2021, 02:51 PM   #19
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

I don't have experience with those plugin frameworks. Here's a few ideas:
  1. Is pGraphics->GetWindow() an instance of REAPERSwell_hwnd (alias for SWELL_hwndChild, a subclass of NSView)? This can be checked in Objective-C:
    Code:
    NSLog(@"%@", NSStringFromClass([(__bridge NSView*)pGraphics->GetWindow() class]));
  2. If yes, your plugin's SetWindowLong is probably failing to detect it's class because you're building a different copy of SWELL in your plugin rather than using REAPER's (modstub.mm). Using REAPER's SetWindowLong should fix that.
  3. If not, adding a subcontrol might be an option.
  4. If not, then bypassing SWELL and directly using the macOS API (Objective-C or Swift) is always an option.
    https://developer.apple.com/library/...tingdrags.html
    Code:
    - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender;
    - (void)draggingExited:(id<NSDraggingInfo>)sender;
    - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender;

Last edited by cfillion; 06-27-2021 at 02:58 PM.
cfillion is offline   Reply With Quote
Old 06-29-2021, 07:37 AM   #20
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 70
Default

Thanks, it's finally working:

I modified the file IGraphicsCocoa.mm

In initWithIGraphics: (IGraphicsMac*) pGraphics added:
Code:
[self registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
then
Code:
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>) sender {
    NSPasteboard *pboard = [sender draggingPasteboard]; 
    return (([pboard.types containsObject:NSFilenamesPboardType]) ? NSDragOperationLink : NSDragOperationNone);
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>) sender {
    NSPasteboard *pboard = [sender draggingPasteboard];
    if ( [[pboard types] containsObject:NSFilenamesPboardType] ) { 
      NSPoint pt = [self convertPoint:[sender draggingLocation] fromView:nil]; 
      for (NSString *path in [pboard propertyListForType:NSFilenamesPboardType]) {
        const char* tmp=[path UTF8String];
        if (mGraphics)  {
          mGraphics->OnMouseDragDrop(pt.x, mGraphics->Height() - pt.y, (char*)tmp);
          break;
        }
      }
    }
    return YES;
}
Two questions:

How can I limit dragging on two types of files: wav and aif

This code also works on new versions of macOS, from Sierra above?
TonyGlover is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:24 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.