mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-18 00:50:05 +02:00
Now let's try out a few new language features...
Rvalue refs, move ctor, =delete, range-for, auto, std:vector<>::emplace_back() There are also performance improvements from eliminating an indirection and using move of strings instead of copy.
This commit is contained in:
parent
4fefad1028
commit
6ec7c619fe
@ -41,9 +41,6 @@ hold information about one contributor to Audacity.
|
|||||||
#include "ShuttleGui.h"
|
#include "ShuttleGui.h"
|
||||||
#include "widgets/LinkingHtmlWindow.h"
|
#include "widgets/LinkingHtmlWindow.h"
|
||||||
|
|
||||||
#include <wx/listimpl.cpp>
|
|
||||||
WX_DEFINE_LIST(AboutDialogCreditItemsList);
|
|
||||||
|
|
||||||
#include "Theme.h"
|
#include "Theme.h"
|
||||||
#include "AllThemeResources.h"
|
#include "AllThemeResources.h"
|
||||||
|
|
||||||
@ -209,7 +206,6 @@ AboutDialog::AboutDialog(wxWindow * parent)
|
|||||||
|
|
||||||
void AboutDialog::PopulateAudacityPage( ShuttleGui & S )
|
void AboutDialog::PopulateAudacityPage( ShuttleGui & S )
|
||||||
{
|
{
|
||||||
creditItems.DeleteContents(true); // Switch on automatic deletion of list items.
|
|
||||||
CreateCreditsList();
|
CreateCreditsList();
|
||||||
|
|
||||||
wxString par1Str = _(
|
wxString par1Str = _(
|
||||||
@ -866,24 +862,20 @@ wxT("POSSIBILITY OF SUCH DAMAGES.\n");
|
|||||||
S.EndNotebookPage();
|
S.EndNotebookPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutDialog::AddCredit(const wxString& description, Role role)
|
void AboutDialog::AddCredit(wxString &&description, Role role)
|
||||||
{
|
{
|
||||||
AboutDialogCreditItem* item = new AboutDialogCreditItem();
|
creditItems.emplace_back(std::move(description), role);
|
||||||
item->description = description;
|
|
||||||
item->role = role;
|
|
||||||
creditItems.Append(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString AboutDialog::GetCreditsByRole(AboutDialog::Role role)
|
wxString AboutDialog::GetCreditsByRole(AboutDialog::Role role)
|
||||||
{
|
{
|
||||||
wxString s;
|
wxString s;
|
||||||
|
|
||||||
for (AboutDialogCreditItemsList::compatibility_iterator p=creditItems.GetFirst(); p; p = p->GetNext())
|
for (const auto &item : creditItems)
|
||||||
{
|
{
|
||||||
AboutDialogCreditItem* item = p->GetData();
|
if (item.role == role)
|
||||||
if (item->role == role)
|
|
||||||
{
|
{
|
||||||
s += item->description;
|
s += item.description;
|
||||||
s += wxT("<br>");
|
s += wxT("<br>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#ifndef __AUDACITY_ABOUT_DLG__
|
#ifndef __AUDACITY_ABOUT_DLG__
|
||||||
#define __AUDACITY_ABOUT_DLG__
|
#define __AUDACITY_ABOUT_DLG__
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include <wx/dialog.h>
|
#include <wx/dialog.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
#include <wx/statbmp.h>
|
#include <wx/statbmp.h>
|
||||||
@ -21,9 +22,26 @@ class ShuttleGui;
|
|||||||
struct AboutDialogCreditItem {
|
struct AboutDialogCreditItem {
|
||||||
wxString description;
|
wxString description;
|
||||||
int role;
|
int role;
|
||||||
|
|
||||||
|
AboutDialogCreditItem(wxString &&description_, int role_)
|
||||||
|
: description(description_), role(role_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
// No copy
|
||||||
|
AboutDialogCreditItem(const AboutDialogCreditItem&) = delete;
|
||||||
|
AboutDialogCreditItem& operator= (const AboutDialogCreditItem&) = delete;
|
||||||
|
|
||||||
|
// Move constructor, because wxString lacks one
|
||||||
|
AboutDialogCreditItem(AboutDialogCreditItem &&moveMe)
|
||||||
|
: role(moveMe.role)
|
||||||
|
{
|
||||||
|
description.swap(moveMe.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
~AboutDialogCreditItem() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
WX_DECLARE_LIST(AboutDialogCreditItem, AboutDialogCreditItemsList);
|
using AboutDialogCreditItemsList = std::vector<AboutDialogCreditItem>;
|
||||||
|
|
||||||
class AboutDialog:public wxDialog {
|
class AboutDialog:public wxDialog {
|
||||||
DECLARE_DYNAMIC_CLASS(AboutDialog)
|
DECLARE_DYNAMIC_CLASS(AboutDialog)
|
||||||
@ -57,7 +75,7 @@ class AboutDialog:public wxDialog {
|
|||||||
void PopulateInformationPage (ShuttleGui & S );
|
void PopulateInformationPage (ShuttleGui & S );
|
||||||
|
|
||||||
void CreateCreditsList();
|
void CreateCreditsList();
|
||||||
void AddCredit(const wxString& description, Role role);
|
void AddCredit(wxString &&description, Role role);
|
||||||
wxString GetCreditsByRole(AboutDialog::Role role);
|
wxString GetCreditsByRole(AboutDialog::Role role);
|
||||||
|
|
||||||
void AddBuildinfoRow( wxString* htmlstring, const wxChar * libname, const wxChar * libdesc, wxString status);
|
void AddBuildinfoRow( wxString* htmlstring, const wxChar * libname, const wxChar * libdesc, wxString status);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user