1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-07 23:51:14 +02:00

Improve repainting after a theme change.

Now most things repaint properly after a theme change.  The sliders on the tracks don't yet.
This commit is contained in:
James Crook 2017-04-04 14:43:47 +01:00
parent 017990fac0
commit c17a7f535e
17 changed files with 27 additions and 36 deletions

View File

@ -245,6 +245,7 @@ void Theme::ApplyUpdatedImages()
{
AColor::ReInit();
AudacityProject *p = GetActiveProject();
p->SetBackgroundColour( theTheme.Colour( clrMedium ) );
p->ResetColours();
for( int ii = 0; ii < ToolBarCount; ++ii )
{

View File

@ -3203,6 +3203,7 @@ void TrackArtist::UpdatePrefs()
{
mdBrange = gPrefs->Read(ENV_DB_KEY, mdBrange);
mShowClipping = gPrefs->Read(wxT("/GUI/ShowClipping"), mShowClipping);
SetColours();
}
// Draws the sync-lock bitmap, tiled; always draws stationary relative to the DC

View File

@ -165,6 +165,7 @@ void ControlToolBar::MakeAlternateImages(AButton &button, int idx,
void ControlToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
MakeButtonBackgroundsLarge();
mPause = MakeButton(bmpPause, bmpPause, bmpPauseDisabled,

View File

@ -59,8 +59,6 @@ END_EVENT_TABLE()
DeviceToolBar::DeviceToolBar()
: ToolBar(DeviceBarID, _("Device"), wxT("Device"), true)
{
mPlayBitmap = NULL;
mRecordBitmap = NULL;
}
DeviceToolBar::~DeviceToolBar()
@ -87,6 +85,7 @@ void DeviceToolBar::DeinitChildren()
void DeviceToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
DeinitChildren();
// Hosts
mHost = safenew wxChoice(this,
@ -97,19 +96,15 @@ void DeviceToolBar::Populate()
Add(mHost, 0, wxALIGN_CENTER);
// Input device
if( mRecordBitmap == NULL )
mRecordBitmap = std::make_unique<wxBitmap>(theTheme.Bitmap(bmpMic));
Add(safenew wxStaticBitmap(this,
wxID_ANY,
*mRecordBitmap), 0, wxALIGN_CENTER);
theTheme.Bitmap(bmpMic)), 0, wxALIGN_CENTER);
mInput = safenew wxChoice(this,
wxID_ANY,
wxDefaultPosition,
wxDefaultSize);
// Input channels
Add(mInput, 0, wxALIGN_CENTER);
mInputChannels = safenew wxChoice(this,
wxID_ANY,
wxDefaultPosition,
@ -117,12 +112,9 @@ void DeviceToolBar::Populate()
Add(mInputChannels, 0, wxALIGN_CENTER);
// Output device
if( mPlayBitmap == NULL )
mPlayBitmap = std::make_unique<wxBitmap>(theTheme.Bitmap(bmpSpeaker));
Add(safenew wxStaticBitmap(this,
wxID_ANY,
*mPlayBitmap), 0, wxALIGN_CENTER);
theTheme.Bitmap(bmpSpeaker)), 0, wxALIGN_CENTER);
mOutput = safenew wxChoice(this,
wxID_ANY,
wxDefaultPosition,
@ -473,8 +465,8 @@ void DeviceToolBar::RepositionCombos()
while (constrained && ratioUnused > 0.01f && i < 5) {
i++;
constrained = RepositionCombo(mHost, w, desiredHost, hostRatio, ratioUnused, 0, true);
constrained |= RepositionCombo(mInput, w, desiredInput, inputRatio, ratioUnused, mRecordBitmap->GetWidth(), true);
constrained |= RepositionCombo(mOutput, w, desiredOutput, outputRatio, ratioUnused, mPlayBitmap->GetWidth(), true);
constrained |= RepositionCombo(mInput, w, desiredInput, inputRatio, ratioUnused, theTheme.Bitmap(bmpMic).GetWidth(), true);
constrained |= RepositionCombo(mOutput, w, desiredOutput, outputRatio, ratioUnused, theTheme.Bitmap(bmpSpeaker).GetWidth(), true);
constrained |= RepositionCombo(mInputChannels, w, desiredChannels, channelsRatio, ratioUnused, 0, true);
}

View File

@ -65,11 +65,8 @@ class DeviceToolBar final : public ToolBar {
void RepositionCombos();
void SetNames();
void RegenerateTooltips() override;
void ShowComboDialog(wxChoice *combo, const wxString &title);
std::unique_ptr<wxBitmap> mPlayBitmap, mRecordBitmap;
wxChoice *mInput;
wxChoice *mOutput;
wxChoice *mInputChannels;

View File

@ -124,6 +124,7 @@ AButton *EditToolBar::AddButton(
void EditToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
MakeButtonBackgroundsSmall();
/* Buttons */

View File

@ -31,7 +31,7 @@
#include <wx/gbsizer.h>
#include "MeterToolBar.h"
#include "../AllThemeResources.h"
#include "../AudioIO.h"
#include "../Project.h"
#include "../widgets/Meter.h"
@ -105,6 +105,7 @@ void MeterToolBar::ReCreateButtons()
void MeterToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
wxASSERT(mProject); // to justify safenew
Add((mSizer = safenew wxGridBagSizer()), 1, wxEXPAND);

View File

@ -57,8 +57,6 @@ END_EVENT_TABLE()
MixerToolBar::MixerToolBar()
: ToolBar(MixerBarID, _("Mixer"), wxT("Mixer"))
{
mPlayBitmap = NULL;
mRecordBitmap = NULL;
mInputSliderVolume = 0.0;
mOutputSliderVolume = 0.0;
}
@ -74,26 +72,21 @@ void MixerToolBar::Create(wxWindow *parent)
void MixerToolBar::Populate()
{
if( mRecordBitmap == NULL )
mRecordBitmap = std::make_unique<wxBitmap>(theTheme.Bitmap(bmpMic));
SetBackgroundColour( theTheme.Colour( clrMedium ) );
// Recording icon and slider
Add(safenew wxStaticBitmap(this,
wxID_ANY,
*mRecordBitmap), 0, wxALIGN_CENTER);
theTheme.Bitmap(bmpMic)), 0, wxALIGN_CENTER);
mInputSlider = safenew ASlider(this, wxID_ANY, _("Recording Volume"),
wxDefaultPosition, wxSize(130, 25));
mInputSlider->SetScroll(0.1f, 2.0f);
mInputSlider->SetName(_("Slider Recording"));
Add(mInputSlider, 0, wxALIGN_CENTER);
if( mPlayBitmap == NULL )
mPlayBitmap = std::make_unique<wxBitmap>(theTheme.Bitmap(bmpSpeaker));
// Playback icon and slider
Add(safenew wxStaticBitmap(this,
wxID_ANY,
*mPlayBitmap), 0, wxALIGN_CENTER);
theTheme.Bitmap(bmpSpeaker)), 0, wxALIGN_CENTER);
mOutputSlider = safenew ASlider(this, wxID_ANY, _("Playback Volume"),
wxDefaultPosition, wxSize(130, 25));
mOutputSlider->SetScroll(0.1f, 2.0f);

View File

@ -61,8 +61,6 @@ class MixerToolBar final : public ToolBar {
void InitializeMixerToolBar();
void SetToolTips();
std::unique_ptr<wxBitmap> mPlayBitmap, mRecordBitmap;
ASlider *mInputSlider;
ASlider *mOutputSlider;

View File

@ -103,6 +103,7 @@ AButton *ScrubbingToolBar::AddButton
void ScrubbingToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
MakeButtonBackgroundsSmall();
/* Buttons */

View File

@ -111,6 +111,7 @@ void SelectionBar::Create(wxWindow * parent)
void SelectionBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
mLeftTime = mRightTime = mAudioTime = nullptr;
// This will be inherited by all children:

View File

@ -52,6 +52,7 @@ with changes in the SpectralSelectionBar.
#include "SpectralSelectionBar.h"
#include "../Prefs.h"
#include "../AllThemeResources.h"
#include "../SelectedRegion.h"
#include "../widgets/NumericTextCtrl.h"
@ -106,6 +107,7 @@ void SpectralSelectionBar::Create(wxWindow * parent)
void SpectralSelectionBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
gPrefs->Read(preferencePath, &mbCenterAndWidth, true);
// This will be inherited by all children:

View File

@ -142,9 +142,9 @@ void ToolBarResizer::OnPaint( wxPaintEvent & event )
// Under GTK, we specifically set the toolbar background to the background
// colour in the system theme.
#if defined( __WXGTK__ )
dc.SetBackground( wxBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ) ) );
// dc.SetBackground( wxBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ) ) );
#endif
dc.SetBackground( wxBrush( theTheme.Colour( clrMedium ) ) );
dc.Clear();
wxSize sz = GetSize();

View File

@ -874,9 +874,8 @@ void ToolDock::OnPaint( wxPaintEvent & WXUNUSED(event) )
//
// Under GTK, we don't set the toolbar background to the background
// colour in the system theme. Instead we use our own colour.
#if defined( __WXGTK__ )
dc.SetBackground( wxBrush( theTheme.Colour( clrMedium )));
#endif
dc.Clear();
// Set the gap color

View File

@ -1285,6 +1285,7 @@ void ToolManager::OnIndicatorPaint( wxPaintEvent & event )
// TODO: Better to use a bitmap than a triangular region.
wxWindow *w = (wxWindow *)event.GetEventObject();
wxPaintDC dc( w );
// TODO: Better (faster) to use the existing spare brush.
wxBrush brush( theTheme.Colour( clrTrackPanelText ) );
dc.SetBackground( brush );
dc.Clear();

View File

@ -186,6 +186,7 @@ AButton * ToolsToolBar::MakeTool( teBmps eTool,
void ToolsToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
MakeButtonBackgroundsSmall();
Add(mToolSizer = safenew wxGridSizer(2, 3, 1, 1));

View File

@ -172,6 +172,7 @@ void TranscriptionToolBar::MakeAlternateImages(
void TranscriptionToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
// Very similar to code in ControlToolBar...
// Very similar to code in EditToolBar
MakeButtonBackgroundsSmall();