1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-03 17:19:43 +02:00
audacity/mac/wxMac_additions/focusrings.patch
Paul Licameli b6b9840d06 Enh1444 and Bug1435 fixed by CHANGED MAC BUILD PROCEURE...
Enh1444 is to make pinch and spread gestures work.

Bug1435 is to bring focus rings back for types of controls that lost them in
version 2.1.2.  This importantly includes pushbuttons and choice controls
(drop-down menus).  Less importantly, date picker (as in the Timer Record
dialog) and Listbox (as in the dialog to choose label font).

There is one more type of control that lost focus rings, and is not fixed:
List controls (distinct from list boxes), such as in the Manage Curves dialog
that opens from Equalization.
2016-07-12 20:31:55 -04:00

124 lines
4.2 KiB
Diff

From 148b0ed936b023b9b87d7703ecb86c4279f1182a Mon Sep 17 00:00:00 2001
From: Paul Licameli <paul.licameli@audacityteam.org>
Date: Wed, 6 Jul 2016 14:18:17 -0400
Subject: [PATCH 2/2] Focus rings are back for buttons, choice, listbox,
dateTimePicker controls
---
include/wx/button.h | 2 ++
include/wx/choice.h | 2 ++
include/wx/datetimectrl.h | 2 ++
include/wx/listbox.h | 2 ++
include/wx/window.h | 2 ++
src/osx/cocoa/window.mm | 22 +++++++++++++++++++++-
6 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/include/wx/button.h b/include/wx/button.h
index 71dbee4..6aa75d3 100644
--- include/wx/button.h
+++ include/wx/button.h
@@ -42,6 +42,8 @@ public:
// returns the default button size for this platform
static wxSize GetDefaultSize();
+ virtual bool NeedsFocusRing() const { return true; }
+
protected:
wxDECLARE_NO_COPY_CLASS(wxButtonBase);
};
diff --git a/include/wx/choice.h b/include/wx/choice.h
index 3a848f9..421a9a7 100644
--- include/wx/choice.h
+++ include/wx/choice.h
@@ -57,6 +57,8 @@ public:
// override wxItemContainer::IsSorted
virtual bool IsSorted() const { return HasFlag(wxCB_SORT); }
+ virtual bool NeedsFocusRing() const { return true; }
+
protected:
// The generic implementation doesn't determine the height correctly and
// doesn't account for the width of the arrow but does take into account
diff --git a/include/wx/datetimectrl.h b/include/wx/datetimectrl.h
index 30f23df..d51c6c1 100644
--- include/wx/datetimectrl.h
+++ include/wx/datetimectrl.h
@@ -32,6 +32,8 @@ public:
// Set/get the date or time (in the latter case, time part is ignored).
virtual void SetValue(const wxDateTime& dt) = 0;
virtual wxDateTime GetValue() const = 0;
+
+ virtual bool NeedsFocusRing() const { return true; }
};
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
diff --git a/include/wx/listbox.h b/include/wx/listbox.h
index afb0220..b9d47f0 100644
--- include/wx/listbox.h
+++ include/wx/listbox.h
@@ -94,6 +94,8 @@ public:
int HitTest(const wxPoint& point) const { return DoListHitTest(point); }
int HitTest(int x, int y) const { return DoListHitTest(wxPoint(x, y)); }
+ virtual bool NeedsFocusRing() const { return true; }
+
protected:
virtual void DoSetFirstItem(int n) = 0;
diff --git a/include/wx/window.h b/include/wx/window.h
index 7dffad4..bbe727d 100644
--- include/wx/window.h
+++ include/wx/window.h
@@ -260,6 +260,8 @@ public:
// moving/resizing
// ---------------
+ virtual bool NeedsFocusRing() const { return false; }
+
// set the window size and/or position
void SetSize( int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO )
diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm
index d9fa4ae..881d0e9 100644
--- src/osx/cocoa/window.mm
+++ src/osx/cocoa/window.mm
@@ -17,6 +17,7 @@
#include "wx/textctrl.h"
#include "wx/combobox.h"
#include "wx/radiobut.h"
+ #include "wx/button.h"
#endif
#ifdef __WXMAC__
@@ -1660,7 +1661,26 @@ void wxWidgetCocoaImpl::drawRect(void* rect, WXWidget slf, void *WXUNUSED(_cmd))
// call super
SEL _cmd = @selector(drawRect:);
wxOSX_DrawRectHandlerPtr superimpl = (wxOSX_DrawRectHandlerPtr) [[slf superclass] instanceMethodForSelector:_cmd];
- superimpl(slf, _cmd, *(NSRect*)rect);
+
+ wxWindow *peer = GetWXPeer();
+ bool hasFocus = peer->HasFocus();
+ if (hasFocus &&
+ peer->NeedsFocusRing()) {
+ superimpl(slf, _cmd, *(NSRect*)rect);
+
+ // Paint it again, without text, causing focus halo to be
+ // superimposed about all else
+ HIThemeBeginFocus( context, kHIThemeFocusRingOnly, NULL );
+ CGContextSetTextDrawingMode( context, kCGTextInvisible );
+ superimpl(slf, _cmd, *(NSRect*)rect);
+ HIThemeEndFocus( context );
+
+ CGContextRestoreGState( context );
+ CGContextSaveGState( context );
+ }
+ else
+ superimpl(slf, _cmd, *(NSRect*)rect);
+
CGContextRestoreGState( context );
CGContextSaveGState( context );
}
--
2.3.2 (Apple Git-55)