Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Small fixes #72

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
24 changes: 22 additions & 2 deletions WDL/IPlug/IGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ IGraphics::IGraphics(IPlugBase* pPlug, int w, int h, int refreshFPS)
, mCursorHidden(false)
, mHiddenMousePointX(-1)
, mHiddenMousePointY(-1)
, mCursor(NULL)
, mEnableTooltips(false)
, mShowControlBounds(false)
{
Expand Down Expand Up @@ -774,8 +775,8 @@ bool IGraphics::Draw(IRECT* pR)
if (!(pControl->IsHidden()) && pR->Intersects(pControl->GetRECT()))
{
pControl->Draw(this);
pControl->SetClean();
}
pControl->SetClean();
}
}
else
Expand Down Expand Up @@ -816,9 +817,9 @@ bool IGraphics::Draw(IRECT* pR)
//printf("control %i and %i \n", i, j);

pControl2->Draw(this);
pControl->SetClean();
}
}
pControl->SetClean();
}
}
}
Expand Down Expand Up @@ -854,6 +855,7 @@ void IGraphics::OnMouseDown(int x, int y, IMouseMod* pMod)
{
ReleaseMouseCapture();
int c = GetMouseControlIdx(x, y);
mPlug->OnMouseDown(x, y, pMod, c);
if (c >= 0)
{
mMouseCapture = c;
Expand Down Expand Up @@ -1018,6 +1020,24 @@ bool IGraphics::OnKeyDown(int x, int y, int key)
return false;
}

void IGraphics::SetMouseCursor(HCURSOR cursor)
{
mCursor = cursor;
UpdateMouseCursor();
}

void IGraphics::UpdateMouseCursor()
{
if (mCursor != NULL)
{
SetCursor(mCursor);
}
else
{
SetCursor(LoadCursor(NULL, IDC_ARROW));
}
}

int IGraphics::GetMouseControlIdx(int x, int y, bool mo)
{
if (mMouseCapture >= 0)
Expand Down
5 changes: 5 additions & 0 deletions WDL/IPlug/IGraphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ class IGraphics
void OnMouseWheel(int x, int y, IMouseMod* pMod, int d);
bool OnKeyDown(int x, int y, int key);

void SetMouseCursor(HCURSOR cursor);

virtual void HideMouseCursor() {};
virtual void ShowMouseCursor() {};

Expand Down Expand Up @@ -256,6 +258,9 @@ class IGraphics
inline int GetMouseX() const { return mMouseX; }
inline int GetMouseY() const { return mMouseY; }
inline bool TooltipsEnabled() const { return mEnableTooltips; }

HCURSOR mCursor;
void UpdateMouseCursor();

virtual LICE_IBitmap* OSLoadBitmap(int ID, const char* name) = 0;

Expand Down
2 changes: 2 additions & 0 deletions WDL/IPlug/IGraphicsCarbon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ pascal void IGraphicsCarbon::TimerHandler(EventLoopTimerRef pTimer, void* pGraph
{
IGraphicsCarbon* _this = (IGraphicsCarbon*) pGraphicsCarbon;

_this->mGraphicsMac->GetPlug()->OnGUITimer();

IRECT r;

if (_this->mGraphicsMac->IsDirty(&r))
Expand Down
3 changes: 3 additions & 0 deletions WDL/IPlug/IGraphicsCocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ NSString* ToNSString(const char* cStr);
IControl* mEdControl; // the control linked to the open text edit
IParam* mEdParam; // the param linked to the open text edit (optional)
int mPrevX, mPrevY;
NSTrackingArea* mTrackingArea;
@public
IGraphicsMac* mGraphics;
}
Expand All @@ -84,6 +85,8 @@ NSString* ToNSString(const char* cStr);
- (void) rightMouseUp: (NSEvent*) pEvent;
- (void) rightMouseDragged: (NSEvent*) pEvent;
- (void) mouseMoved: (NSEvent*) pEvent;
- (void) updateTrackingAreas;
- (void) mouseExited: (NSEvent*) pEvent;
- (void) scrollWheel: (NSEvent*) pEvent;
- (void) keyDown: (NSEvent *)pEvent;
- (void) killTimer;
Expand Down
27 changes: 25 additions & 2 deletions WDL/IPlug/IGraphicsCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,14 @@ - (void) drawRect: (NSRect) rect
- (void) onTimer: (NSTimer*) pTimer
{
IRECT r;
if (pTimer == mTimer && mGraphics && mGraphics->IsDirty(&r))
if (pTimer == mTimer && mGraphics)
{
[self setNeedsDisplayInRect:ToNSRect(mGraphics, &r)];
mGraphics->GetPlug()->OnGUITimer();

if (mGraphics->IsDirty(&r))
{
[self setNeedsDisplayInRect:ToNSRect(mGraphics, &r)];
}
}
}

Expand Down Expand Up @@ -397,6 +402,24 @@ - (void) mouseMoved: (NSEvent*) pEvent
}
}

- (void) updateTrackingAreas
{
if (mTrackingArea != nil) {
[self removeTrackingArea:mTrackingArea];
}

mTrackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways owner:self userInfo:nil];
[self addTrackingArea:mTrackingArea];
}

- (void) mouseExited: (NSEvent*) pEvent
{
if (mGraphics)
{
mGraphics->OnMouseOut();
}
}

- (void)keyDown: (NSEvent *)pEvent
{
NSString *s = [pEvent charactersIgnoringModifiers];
Expand Down
9 changes: 8 additions & 1 deletion WDL/IPlug/IGraphicsWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ LRESULT CALLBACK IGraphicsWin::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARA
{
if (wParam == IPLUG_TIMER_ID)
{
pGraphics->GetPlug()->OnGUITimer();

if (pGraphics->mParamEditWnd && pGraphics->mParamEditMsg != kNone)
{
Expand Down Expand Up @@ -336,7 +337,13 @@ LRESULT CALLBACK IGraphicsWin::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARA
return 0;
}

case WM_CTLCOLOREDIT:
case WM_SETCURSOR:
{
pGraphics->UpdateMouseCursor();
return TRUE;
}

case WM_CTLCOLOREDIT:
{

if(!pGraphics->mEdControl)
Expand Down
3 changes: 3 additions & 0 deletions WDL/IPlug/IParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ void IParam::GetDisplayForHost(double value, bool normalized, char* rDisplay, bo

double displayValue = value;

double roundScale = pow(10, mDisplayPrecision);
displayValue = round(displayValue * roundScale) / roundScale;

if (mNegateDisplay) displayValue = -displayValue;

if (mDisplayPrecision == 0)
Expand Down
2 changes: 1 addition & 1 deletion WDL/IPlug/IPlugAU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ OSStatus IPlugAU::RenderProc(void* pPlug, AudioUnitRenderActionFlags* pFlags, co

IPlugAU* _this = (IPlugAU*) pPlug;

if (!(pTimestamp->mFlags & kAudioTimeStampSampleTimeValid) || outputBusIdx >= _this->mOutBuses.GetSize() || nFrames > _this->GetBlockSize())
if (outputBusIdx >= _this->mOutBuses.GetSize() || nFrames > _this->GetBlockSize())
{
return kAudioUnitErr_InvalidPropertyValue;
}
Expand Down
4 changes: 4 additions & 0 deletions WDL/IPlug/IPlugBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ class IPlugBase
virtual void OnGUIOpen() { TRACE; }
virtual void OnGUIClose() { TRACE; }

virtual void OnMouseDown(int x, int y, IMouseMod* pMod, int controlIdx) {}

// This is an idle call from the audio processing thread, as opposed to
// IGraphics::OnGUIIdle which is called from the GUI thread.
// Only active if USE_IDLE_CALLS is defined.
virtual void OnIdle() {}

virtual void OnGUITimer() {}

// Not usually needed ... Reset is called on activate regardless of whether this is implemented.
// Also different hosts have different interpretations of "activate".
// Implementations should set a mutex lock like in the no-op!
Expand Down