mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-26 00:58:37 +02:00
Flicker-Free Grabbers and Mic/Speaker icons.
Previously we were clearing in Erase Background, giving lots of flicker when resizing some toolbar. Also fixed a mac Slider background painting issue.
This commit is contained in:
parent
cbd0f8aba3
commit
7178879397
@ -44,6 +44,7 @@
|
||||
#include "../widgets/Grabber.h"
|
||||
#include "../DeviceManager.h"
|
||||
#include "../widgets/ErrorDialog.h"
|
||||
#include "../widgets/Grabber.h"
|
||||
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
#include "../widgets/WindowAccessible.h"
|
||||
@ -104,7 +105,7 @@ void DeviceToolBar::Populate()
|
||||
Add(mHost, 0, wxALIGN_CENTER);
|
||||
|
||||
// Input device
|
||||
Add(safenew wxStaticBitmap(this,
|
||||
Add(safenew AStaticBitmap(this,
|
||||
wxID_ANY,
|
||||
theTheme.Bitmap(bmpMic)), 0, wxALIGN_CENTER);
|
||||
mInput = safenew wxChoice(this,
|
||||
@ -128,7 +129,7 @@ void DeviceToolBar::Populate()
|
||||
Add(mInputChannels, 0, wxALIGN_CENTER);
|
||||
|
||||
// Output device
|
||||
Add(safenew wxStaticBitmap(this,
|
||||
Add(safenew AStaticBitmap(this,
|
||||
wxID_ANY,
|
||||
theTheme.Bitmap(bmpSpeaker)), 0, wxALIGN_CENTER);
|
||||
mOutput = safenew wxChoice(this,
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "../Project.h"
|
||||
#include "../Theme.h"
|
||||
#include "../widgets/ASlider.h"
|
||||
#include "../widgets/Grabber.h"
|
||||
|
||||
IMPLEMENT_CLASS(MixerToolBar, ToolBar);
|
||||
|
||||
@ -74,7 +75,7 @@ void MixerToolBar::Populate()
|
||||
{
|
||||
SetBackgroundColour( theTheme.Colour( clrMedium ) );
|
||||
// Recording icon and slider
|
||||
Add(safenew wxStaticBitmap(this,
|
||||
Add(safenew AStaticBitmap(this,
|
||||
wxID_ANY,
|
||||
theTheme.Bitmap(bmpMic)), 0, wxALIGN_CENTER);
|
||||
mInputSlider = safenew ASlider(this, wxID_ANY, _("Recording Volume"),
|
||||
@ -83,7 +84,7 @@ void MixerToolBar::Populate()
|
||||
Add(mInputSlider, 0, wxALIGN_CENTER);
|
||||
|
||||
// Playback icon and slider
|
||||
Add(safenew wxStaticBitmap(this,
|
||||
Add(safenew AStaticBitmap(this,
|
||||
wxID_ANY,
|
||||
theTheme.Bitmap(bmpSpeaker)), 0, wxALIGN_CENTER);
|
||||
mOutputSlider = safenew ASlider(this, wxID_ANY, _("Playback Volume"),
|
||||
|
@ -860,8 +860,8 @@ void ToolBar::OnErase( wxEraseEvent & WXUNUSED(event) )
|
||||
//
|
||||
void ToolBar::OnPaint( wxPaintEvent & event )
|
||||
{
|
||||
wxPaintDC dc( (wxWindow *) event.GetEventObject() );
|
||||
|
||||
//wxPaintDC dc( (wxWindow *) event.GetEventObject() );
|
||||
wxPaintDC dc( this );
|
||||
// Start with a clean background
|
||||
//
|
||||
// Under GTK, we specifically set the toolbar background to the background
|
||||
|
@ -573,12 +573,12 @@ void LWSlider::OnPaint(wxDC &dc, bool highlight)
|
||||
thumbPos += 8-mThumbHeight/2;
|
||||
}
|
||||
|
||||
#if !defined(__WXMAC__)
|
||||
// Previously not done on mac, but with wx3.1.1. it
|
||||
// needs to be.
|
||||
if( mHW )
|
||||
{
|
||||
dc.Clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
dc.DrawBitmap(*mBitmap, mLeft, mTop, true);
|
||||
const auto &thumbBitmap =
|
||||
|
@ -45,6 +45,7 @@ BEGIN_EVENT_TABLE(Grabber, wxWindow)
|
||||
EVT_ENTER_WINDOW(Grabber::OnEnter)
|
||||
EVT_LEAVE_WINDOW(Grabber::OnLeave)
|
||||
EVT_LEFT_DOWN(Grabber::OnLeftDown)
|
||||
EVT_ERASE_BACKGROUND( Grabber::OnErase )
|
||||
EVT_PAINT(Grabber::OnPaint)
|
||||
EVT_KEY_DOWN(Grabber::OnKeyDown)
|
||||
END_EVENT_TABLE()
|
||||
@ -238,6 +239,11 @@ void Grabber::OnLeave(wxMouseEvent & WXUNUSED(event))
|
||||
}
|
||||
}
|
||||
|
||||
void Grabber::OnErase( wxEraseEvent & WXUNUSED(event) )
|
||||
{
|
||||
// Ignore it to prevent flashing
|
||||
}
|
||||
|
||||
//
|
||||
// Handle the paint events
|
||||
//
|
||||
@ -260,3 +266,11 @@ void Grabber::OnKeyDown(wxKeyEvent &event)
|
||||
SendEvent(EVT_GRABBER_CLICKED, wxPoint{ -1, -1 }, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Piggy back in same source file as Grabber.
|
||||
// Audcaity Flicker-free StaticBitmap.
|
||||
BEGIN_EVENT_TABLE(AStaticBitmap,wxStaticBitmap)
|
||||
EVT_ERASE_BACKGROUND(AStaticBitmap::OnErase)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
@ -30,6 +30,7 @@ around to NEW positions.
|
||||
#include "wx/event.h"
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/window.h"
|
||||
#include <wx/statbmp.h>
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Grabber Class
|
||||
@ -118,6 +119,7 @@ class Grabber final : public wxWindow
|
||||
void OnLeftDown(wxMouseEvent & event);
|
||||
void OnEnter(wxMouseEvent & event);
|
||||
void OnLeave(wxMouseEvent & event);
|
||||
void OnErase(wxEraseEvent & event);
|
||||
void OnPaint(wxPaintEvent & event);
|
||||
void OnKeyDown(wxKeyEvent & event);
|
||||
|
||||
@ -135,4 +137,32 @@ class Grabber final : public wxWindow
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// Piggy back in same source file as Grabber.
|
||||
// Audcaity Flicker-free StaticBitmap.
|
||||
class AStaticBitmap : public wxStaticBitmap {
|
||||
public:
|
||||
AStaticBitmap(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxBitmap& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxStaticBitmapNameStr) :
|
||||
|
||||
wxStaticBitmap(parent,
|
||||
id,
|
||||
label,
|
||||
pos ,
|
||||
size ,
|
||||
style,
|
||||
name )
|
||||
{};
|
||||
void OnErase(wxEraseEvent& event) {
|
||||
static_cast<void>(event);
|
||||
};
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user