mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-13 15:17:42 +02:00
More flexible toolbar layout routines; now scrub bar can stick left
This commit is contained in:
commit
35ba92560d
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,8 @@
|
|||||||
#ifndef __AUDACITY_TOOLDOCK__
|
#ifndef __AUDACITY_TOOLDOCK__
|
||||||
#define __AUDACITY_TOOLDOCK__
|
#define __AUDACITY_TOOLDOCK__
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "../MemoryX.h" // for std::move
|
||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
|
|
||||||
@ -45,23 +47,271 @@ enum
|
|||||||
DockCount = 2
|
DockCount = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ToolBarConfiguration
|
||||||
|
{
|
||||||
|
struct Tree;
|
||||||
|
using Forest = std::vector<Tree>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void Swap(ToolBarConfiguration &that)
|
||||||
|
{
|
||||||
|
mForest.swap(that.mForest);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
mForest.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Position {
|
||||||
|
ToolBar *rightOf {};
|
||||||
|
ToolBar *below {};
|
||||||
|
bool adopt {true};
|
||||||
|
bool valid {true};
|
||||||
|
|
||||||
|
// Default constructor
|
||||||
|
Position() {}
|
||||||
|
|
||||||
|
Position(
|
||||||
|
ToolBar *r,
|
||||||
|
ToolBar *b = nullptr,
|
||||||
|
bool shouldAdopt = true
|
||||||
|
)
|
||||||
|
: rightOf{ r }, below{ b }, adopt{ shouldAdopt }
|
||||||
|
{}
|
||||||
|
|
||||||
|
// Constructor for the invalid value
|
||||||
|
explicit Position(bool /* dummy */) : valid{ false } {}
|
||||||
|
|
||||||
|
friend inline bool operator ==
|
||||||
|
(const Position &lhs, const Position &rhs)
|
||||||
|
{ return lhs.valid == rhs.valid &&
|
||||||
|
(!lhs.valid ||
|
||||||
|
(lhs.rightOf == rhs.rightOf
|
||||||
|
&& lhs.below == rhs.below
|
||||||
|
&& lhs.adopt == rhs.adopt
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline bool operator !=
|
||||||
|
(const Position &lhs, const Position &rhs)
|
||||||
|
{ return !(lhs == rhs); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Position UnspecifiedPosition;
|
||||||
|
|
||||||
|
struct Place {
|
||||||
|
Tree *pTree {};
|
||||||
|
Position position;
|
||||||
|
};
|
||||||
|
|
||||||
|
// This iterator visits the nodes of the forest in pre-order, and at each
|
||||||
|
// stop, makes the parent, previous sibling, and children accessible.
|
||||||
|
class Iterator
|
||||||
|
: public std::iterator<std::forward_iterator_tag, Place>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const Place &operator * () const { return mPlace; }
|
||||||
|
const Place *operator -> () const { return &**this; }
|
||||||
|
Iterator &operator ++ ()
|
||||||
|
{
|
||||||
|
// This is a feature: advance position even at the end
|
||||||
|
mPlace.position =
|
||||||
|
{ mPlace.pTree ? mPlace.pTree->pBar : nullptr };
|
||||||
|
|
||||||
|
if (!mIters.empty())
|
||||||
|
{
|
||||||
|
auto triple = &mIters.back();
|
||||||
|
auto &children = triple->current->children;
|
||||||
|
if (children.empty()) {
|
||||||
|
while (++triple->current == triple->end) {
|
||||||
|
mIters.pop_back();
|
||||||
|
if (mIters.empty())
|
||||||
|
break;
|
||||||
|
triple = &mIters.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto b = children.begin();
|
||||||
|
mIters.push_back( Triple { b, b, children.end() } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mIters.empty()) {
|
||||||
|
mPlace.pTree = nullptr;
|
||||||
|
// Leave mPlace.position as above
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const auto &triple = mIters.back();
|
||||||
|
mPlace.pTree = &*triple.current;
|
||||||
|
|
||||||
|
if (mIters.size() == 1)
|
||||||
|
mPlace.position.rightOf = nullptr;
|
||||||
|
else
|
||||||
|
mPlace.position.rightOf = (mIters.rbegin() + 1)->current->pBar;
|
||||||
|
|
||||||
|
if (triple.begin == triple.current)
|
||||||
|
mPlace.position.below = nullptr;
|
||||||
|
else
|
||||||
|
mPlace.position.below = (triple.current - 1)->pBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This may be called on the end iterator, and then returns empty
|
||||||
|
std::vector<int> GetPath() const
|
||||||
|
{
|
||||||
|
std::vector<int> path;
|
||||||
|
path.reserve(mIters.size());
|
||||||
|
for (const auto &triple : mIters)
|
||||||
|
path.push_back(triple.current - triple.begin);
|
||||||
|
return std::move(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline bool operator ==
|
||||||
|
(const Iterator &lhs, const Iterator &rhs)
|
||||||
|
{
|
||||||
|
const auto &li = lhs.mIters;
|
||||||
|
const auto &ri = rhs.mIters;
|
||||||
|
return li.size() == ri.size() &&
|
||||||
|
std::equal(li.begin(), li.end(), ri.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline bool operator !=
|
||||||
|
(const Iterator &lhs, const Iterator &rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend ToolBarConfiguration;
|
||||||
|
Iterator () {}
|
||||||
|
explicit Iterator(ToolBarConfiguration &conf)
|
||||||
|
{
|
||||||
|
auto &forest = conf.mForest;
|
||||||
|
if (!forest.empty()) {
|
||||||
|
auto b = forest.begin();
|
||||||
|
mIters.push_back( Triple { b, b, forest.end() } );
|
||||||
|
mPlace.pTree = &*b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Place mPlace;
|
||||||
|
|
||||||
|
using FIter = Forest::iterator;
|
||||||
|
struct Triple
|
||||||
|
{
|
||||||
|
Triple (FIter b, FIter c, FIter e)
|
||||||
|
: begin{b}, current{c}, end{e} {}
|
||||||
|
FIter begin, current, end;
|
||||||
|
|
||||||
|
friend inline bool operator ==
|
||||||
|
(const Triple &lhs, const Triple &rhs)
|
||||||
|
{
|
||||||
|
// Really need only to compare current
|
||||||
|
return
|
||||||
|
// lhs.begin == rhs.begin &&
|
||||||
|
lhs.current == rhs.current
|
||||||
|
// lhs.end == rhs.end
|
||||||
|
;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::vector<Triple> mIters;
|
||||||
|
};
|
||||||
|
|
||||||
|
Iterator begin() { return Iterator { *this }; }
|
||||||
|
Iterator end() const { return Iterator {}; }
|
||||||
|
|
||||||
|
Position Find(const ToolBar *bar) const;
|
||||||
|
|
||||||
|
bool Contains(const ToolBar *bar) const
|
||||||
|
{
|
||||||
|
return Find(bar) != UnspecifiedPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default position inserts at the end
|
||||||
|
void Insert(ToolBar *bar,
|
||||||
|
Position position = UnspecifiedPosition);
|
||||||
|
void InsertAtPath(ToolBar *bar, const std::vector<int> &path);
|
||||||
|
void Remove(const ToolBar *bar);
|
||||||
|
|
||||||
|
// Future: might allow a state that the configuration remembers
|
||||||
|
// a hidden bar, but for now, it's equivalent to Contains():
|
||||||
|
bool Shows(const ToolBar *bar) const { return Contains(bar); }
|
||||||
|
|
||||||
|
void Show(ToolBar *bar);
|
||||||
|
void Hide(ToolBar *bar);
|
||||||
|
|
||||||
|
bool IsRightmost(const ToolBar *bar) const;
|
||||||
|
|
||||||
|
struct Legacy {
|
||||||
|
std::vector<ToolBar*> bars;
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool Read
|
||||||
|
(ToolBarConfiguration *pConfiguration,
|
||||||
|
ToolManager *pManager,
|
||||||
|
Legacy *pLegacy,
|
||||||
|
ToolBar *bar, bool &visible, bool defaultVisible);
|
||||||
|
void PostRead(Legacy &legacy);
|
||||||
|
|
||||||
|
static void Write
|
||||||
|
(const ToolBarConfiguration *pConfiguration, const ToolBar *bar);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void Remove(Forest &forest, Forest::iterator iter);
|
||||||
|
void RemoveNulls(Forest &forest);
|
||||||
|
|
||||||
|
struct Tree
|
||||||
|
{
|
||||||
|
ToolBar *pBar {};
|
||||||
|
Forest children;
|
||||||
|
|
||||||
|
void swap(Tree &that)
|
||||||
|
{
|
||||||
|
std::swap(pBar, that.pBar);
|
||||||
|
children.swap(that.children);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Iterator FindPlace(const ToolBar *bar) const;
|
||||||
|
std::pair<Forest*, Forest::iterator> FindParent(const ToolBar *bar);
|
||||||
|
|
||||||
|
Forest mForest;
|
||||||
|
};
|
||||||
|
|
||||||
class ToolDock final : public wxPanel
|
class ToolDock final : public wxPanel
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
public:
|
|
||||||
|
|
||||||
ToolDock( ToolManager *manager, wxWindow *parent, int dockid );
|
ToolDock( ToolManager *manager, wxWindow *parent, int dockid );
|
||||||
~ToolDock();
|
~ToolDock();
|
||||||
|
|
||||||
bool AcceptsFocus() const override { return false; };
|
bool AcceptsFocus() const override { return false; };
|
||||||
|
|
||||||
|
void LoadConfig(ToolBar *bars[]);
|
||||||
void LayoutToolBars();
|
void LayoutToolBars();
|
||||||
void Expose( int type, bool show );
|
void Expose( int type, bool show );
|
||||||
int Find(ToolBar *bar) const;
|
|
||||||
int GetOrder( ToolBar *bar );
|
int GetOrder( ToolBar *bar );
|
||||||
void Dock( ToolBar *bar, bool deflate, int ndx = -1 );
|
void Dock( ToolBar *bar, bool deflate,
|
||||||
|
ToolBarConfiguration::Position ndx
|
||||||
|
= ToolBarConfiguration::UnspecifiedPosition);
|
||||||
void Undock( ToolBar *bar );
|
void Undock( ToolBar *bar );
|
||||||
int PositionBar( ToolBar *t, wxPoint & pos, wxRect & rect );
|
ToolBarConfiguration::Position
|
||||||
|
PositionBar( ToolBar *t, const wxPoint & pos, wxRect & rect );
|
||||||
|
|
||||||
|
ToolBarConfiguration &GetConfiguration()
|
||||||
|
{ return mConfiguration; }
|
||||||
|
|
||||||
|
// backup gets old contents of the configuration; the configuration is
|
||||||
|
// set to the wrapped configuration.
|
||||||
|
void WrapConfiguration(ToolBarConfiguration &backup);
|
||||||
|
|
||||||
|
// Reverse what was done by WrapConfiguration.
|
||||||
|
void RestoreConfiguration(ToolBarConfiguration &backup);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -72,6 +322,9 @@ class ToolDock final : public wxPanel
|
|||||||
void OnMouseEvents(wxMouseEvent &event);
|
void OnMouseEvents(wxMouseEvent &event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
class LayoutVisitor;
|
||||||
|
void VisitLayout(LayoutVisitor &visitor,
|
||||||
|
ToolBarConfiguration *pWrappedConfiguration = nullptr);
|
||||||
|
|
||||||
void Updated();
|
void Updated();
|
||||||
|
|
||||||
@ -80,7 +333,12 @@ class ToolDock final : public wxPanel
|
|||||||
|
|
||||||
ToolManager *mManager;
|
ToolManager *mManager;
|
||||||
|
|
||||||
wxArrayPtrVoid mDockedBars;
|
// Stores adjacency relations that we want to realize in the dock layout
|
||||||
|
ToolBarConfiguration mConfiguration;
|
||||||
|
|
||||||
|
// Configuration as modified by the constraint of the main window width
|
||||||
|
ToolBarConfiguration mWrappedConfiguration;
|
||||||
|
|
||||||
ToolBar *mBars[ ToolBarCount ];
|
ToolBar *mBars[ ToolBarCount ];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -498,16 +498,59 @@ ToolManager::~ToolManager()
|
|||||||
delete mDown;
|
delete mDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This table describes the default configuration of the toolbars as
|
||||||
|
// a "tree" and must be kept in pre-order traversal.
|
||||||
|
|
||||||
|
// In fact this tree is more of a broom -- nothing properly branches except
|
||||||
|
// at the root.
|
||||||
|
|
||||||
|
// "Root" corresponds to left edge of the main window, and successive siblings
|
||||||
|
// go from top to bottom. But in practice layout may wrap this abstract
|
||||||
|
// configuration if the window size is narrow.
|
||||||
|
|
||||||
|
static struct DefaultConfigEntry {
|
||||||
|
int barID;
|
||||||
|
int rightOf; // parent
|
||||||
|
int below; // preceding sibling
|
||||||
|
} DefaultConfigTable [] = {
|
||||||
|
// Top dock row, may wrap
|
||||||
|
{ TransportBarID, NoBarID, NoBarID },
|
||||||
|
{ ToolsBarID, TransportBarID, NoBarID },
|
||||||
|
{ RecordMeterBarID, ToolsBarID, NoBarID },
|
||||||
|
{ PlayMeterBarID, RecordMeterBarID, NoBarID },
|
||||||
|
{ MixerBarID, PlayMeterBarID, NoBarID },
|
||||||
|
{ EditBarID, MixerBarID, NoBarID },
|
||||||
|
{ TranscriptionBarID, EditBarID, NoBarID },
|
||||||
|
|
||||||
|
// start another top dock row
|
||||||
|
{ ScrubbingBarID, NoBarID, TransportBarID },
|
||||||
|
{ DeviceBarID, ScrubbingBarID, NoBarID },
|
||||||
|
|
||||||
|
// Hidden by default in top dock
|
||||||
|
{ MeterBarID, NoBarID, NoBarID },
|
||||||
|
|
||||||
|
// Bottom dock
|
||||||
|
{ SelectionBarID, NoBarID, NoBarID },
|
||||||
|
|
||||||
|
// Hidden by default in bottom dock
|
||||||
|
{ SpectralSelectionBarID, NoBarID, NoBarID },
|
||||||
|
};
|
||||||
|
|
||||||
void ToolManager::Reset()
|
void ToolManager::Reset()
|
||||||
{
|
{
|
||||||
int ndx;
|
|
||||||
|
|
||||||
// Disconnect all docked bars
|
// Disconnect all docked bars
|
||||||
for( ndx = 0; ndx < ToolBarCount; ndx++ )
|
for ( const auto &entry : DefaultConfigTable )
|
||||||
{
|
{
|
||||||
|
int ndx = entry.barID;
|
||||||
|
ToolBar *bar = mBars[ ndx ];
|
||||||
|
|
||||||
|
ToolBarConfiguration::Position position {
|
||||||
|
(entry.rightOf == NoBarID) ? nullptr : mBars[ entry.rightOf ],
|
||||||
|
(entry.below == NoBarID) ? nullptr : mBars[ entry.below ]
|
||||||
|
};
|
||||||
|
|
||||||
wxWindow *floater;
|
wxWindow *floater;
|
||||||
ToolDock *dock;
|
ToolDock *dock;
|
||||||
ToolBar *bar = mBars[ ndx ];
|
|
||||||
bool expose = true;
|
bool expose = true;
|
||||||
|
|
||||||
// Disconnect the bar
|
// Disconnect the bar
|
||||||
@ -558,7 +601,7 @@ void ToolManager::Reset()
|
|||||||
if( dock != NULL )
|
if( dock != NULL )
|
||||||
{
|
{
|
||||||
// when we dock, we reparent, so bar is no longer a child of floater.
|
// when we dock, we reparent, so bar is no longer a child of floater.
|
||||||
dock->Dock( bar, false );
|
dock->Dock( bar, false, position );
|
||||||
Expose( ndx, expose );
|
Expose( ndx, expose );
|
||||||
//OK (and good) to DELETE floater, as bar is no longer in it.
|
//OK (and good) to DELETE floater, as bar is no longer in it.
|
||||||
if( floater )
|
if( floater )
|
||||||
@ -613,30 +656,23 @@ void ToolManager::ReadConfig()
|
|||||||
{
|
{
|
||||||
wxString oldpath = gPrefs->GetPath();
|
wxString oldpath = gPrefs->GetPath();
|
||||||
wxArrayInt unordered[ DockCount ];
|
wxArrayInt unordered[ DockCount ];
|
||||||
int order[ DockCount ][ ToolBarCount ];
|
|
||||||
bool show[ ToolBarCount ];
|
bool show[ ToolBarCount ];
|
||||||
int width[ ToolBarCount ];
|
int width[ ToolBarCount ];
|
||||||
int height[ ToolBarCount ];
|
int height[ ToolBarCount ];
|
||||||
int x, y;
|
int x, y;
|
||||||
int dock, ord, ndx;
|
int dock, ndx;
|
||||||
|
bool someFound { false };
|
||||||
|
|
||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
// Disable window animation
|
// Disable window animation
|
||||||
wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
|
wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Invalidate all order entries
|
|
||||||
for( dock = 0; dock < DockCount; dock++ )
|
|
||||||
{
|
|
||||||
for( ord = 0; ord < ToolBarCount; ord++ )
|
|
||||||
{
|
|
||||||
order[ dock ][ ord ] = NoBarID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change to the bar root
|
// Change to the bar root
|
||||||
gPrefs->SetPath( wxT("/GUI/ToolBars") );
|
gPrefs->SetPath( wxT("/GUI/ToolBars") );
|
||||||
|
|
||||||
|
ToolBarConfiguration::Legacy topLegacy, botLegacy;
|
||||||
|
|
||||||
// Load and apply settings for each bar
|
// Load and apply settings for each bar
|
||||||
for( ndx = 0; ndx < ToolBarCount; ndx++ )
|
for( ndx = 0; ndx < ToolBarCount; ndx++ )
|
||||||
{
|
{
|
||||||
@ -665,9 +701,28 @@ void ToolManager::ReadConfig()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Read in all the settings
|
// Read in all the settings
|
||||||
gPrefs->Read( wxT("Dock"), &dock, defaultDock );
|
gPrefs->Read( wxT("Dock"), &dock, -1);
|
||||||
gPrefs->Read( wxT("Order"), &ord, NoBarID );
|
const bool found = (dock != -1);
|
||||||
gPrefs->Read( wxT("Show"), &show[ ndx ], bShownByDefault);
|
if (found)
|
||||||
|
someFound = true;
|
||||||
|
if (!found)
|
||||||
|
dock = defaultDock;
|
||||||
|
|
||||||
|
ToolDock *d;
|
||||||
|
ToolBarConfiguration::Legacy *pLegacy;
|
||||||
|
switch(dock)
|
||||||
|
{
|
||||||
|
case TopDockID: d = mTopDock; pLegacy = &topLegacy; break;
|
||||||
|
case BotDockID: d = mBotDock; pLegacy = &botLegacy; break;
|
||||||
|
default: d = nullptr; pLegacy = nullptr; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ordered = ToolBarConfiguration::Read
|
||||||
|
(d ? &d->GetConfiguration() : nullptr,
|
||||||
|
this,
|
||||||
|
pLegacy,
|
||||||
|
bar, show[ ndx ], bShownByDefault)
|
||||||
|
&& found;
|
||||||
|
|
||||||
gPrefs->Read( wxT("X"), &x, -1 );
|
gPrefs->Read( wxT("X"), &x, -1 );
|
||||||
gPrefs->Read( wxT("Y"), &y, -1 );
|
gPrefs->Read( wxT("Y"), &y, -1 );
|
||||||
@ -727,15 +782,8 @@ void ToolManager::ReadConfig()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Is order within range and unoccupied?
|
|
||||||
if( ( ord >= 0 ) &&
|
if (!ordered)
|
||||||
( ord < ToolBarCount ) &&
|
|
||||||
( order[ dock - 1 ][ ord ] == NoBarID ) )
|
|
||||||
{
|
|
||||||
// Insert at ordered location
|
|
||||||
order[ dock - 1 ][ ord ] = ndx;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// These must go at the end
|
// These must go at the end
|
||||||
unordered[ dock - 1 ].Add( ndx );
|
unordered[ dock - 1 ].Add( ndx );
|
||||||
@ -776,31 +824,18 @@ void ToolManager::ReadConfig()
|
|||||||
gPrefs->SetPath( wxT("/GUI/ToolBars") );
|
gPrefs->SetPath( wxT("/GUI/ToolBars") );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mTopDock->GetConfiguration().PostRead(topLegacy);
|
||||||
|
mBotDock->GetConfiguration().PostRead(botLegacy);
|
||||||
|
|
||||||
// Add all toolbars to their target dock
|
// Add all toolbars to their target dock
|
||||||
for( dock = 0; dock < DockCount; dock++ )
|
for( dock = 0; dock < DockCount; dock++ )
|
||||||
{
|
{
|
||||||
ToolDock *d = ( dock + 1 == TopDockID ? mTopDock : mBotDock );
|
ToolDock *d = ( dock + 1 == TopDockID ? mTopDock : mBotDock );
|
||||||
|
|
||||||
// Add all ordered toolbars
|
d->LoadConfig(mBars);
|
||||||
for( ord = 0; ord < ToolBarCount; ord++ )
|
|
||||||
{
|
|
||||||
ndx = order[ dock ][ ord ];
|
|
||||||
|
|
||||||
// Bypass empty slots
|
|
||||||
if( ndx != NoBarID )
|
|
||||||
{
|
|
||||||
ToolBar *t = mBars[ ndx ];
|
|
||||||
|
|
||||||
// Dock it
|
|
||||||
d->Dock( t, false );
|
|
||||||
|
|
||||||
// Show or hide it
|
|
||||||
Expose( t->GetId(), show[ t->GetId() ] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add all unordered toolbars
|
// Add all unordered toolbars
|
||||||
for( ord = 0; ord < (int) unordered[ dock ].GetCount(); ord++ )
|
for( int ord = 0; ord < (int) unordered[ dock ].GetCount(); ord++ )
|
||||||
{
|
{
|
||||||
ToolBar *t = mBars[ unordered[ dock ][ ord ] ];
|
ToolBar *t = mBars[ unordered[ dock ][ ord ] ];
|
||||||
|
|
||||||
@ -819,6 +854,9 @@ void ToolManager::ReadConfig()
|
|||||||
// Reinstate original transition
|
// Reinstate original transition
|
||||||
wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
|
wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!someFound)
|
||||||
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -846,13 +884,14 @@ void ToolManager::WriteConfig()
|
|||||||
gPrefs->SetPath( bar->GetSection() );
|
gPrefs->SetPath( bar->GetSection() );
|
||||||
|
|
||||||
// Search both docks for toolbar order
|
// Search both docks for toolbar order
|
||||||
int to = mTopDock->GetOrder( bar );
|
bool to = mTopDock->GetConfiguration().Contains( bar );
|
||||||
int bo = mBotDock->GetOrder( bar );
|
bool bo = mBotDock->GetConfiguration().Contains( bar );
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
gPrefs->Write( wxT("Dock"), (int) (to ? TopDockID : bo ? BotDockID : NoDockID ));
|
gPrefs->Write( wxT("Dock"), (int) (to ? TopDockID : bo ? BotDockID : NoDockID ));
|
||||||
gPrefs->Write( wxT("Order"), to + bo );
|
auto dock = to ? mTopDock : bo ? mBotDock : nullptr;
|
||||||
gPrefs->Write( wxT("Show"), IsVisible( ndx ) );
|
ToolBarConfiguration::Write
|
||||||
|
(dock ? &dock->GetConfiguration() : nullptr, bar);
|
||||||
|
|
||||||
wxPoint pos( -1, -1 );
|
wxPoint pos( -1, -1 );
|
||||||
wxSize sz = bar->GetSize();
|
wxSize sz = bar->GetSize();
|
||||||
@ -866,13 +905,17 @@ void ToolManager::WriteConfig()
|
|||||||
gPrefs->Write( wxT("W"), sz.x );
|
gPrefs->Write( wxT("W"), sz.x );
|
||||||
gPrefs->Write( wxT("H"), sz.y );
|
gPrefs->Write( wxT("H"), sz.y );
|
||||||
|
|
||||||
// Kill the bar
|
|
||||||
bar->Destroy();
|
|
||||||
|
|
||||||
// Change back to the bar root
|
// Change back to the bar root
|
||||||
gPrefs->SetPath( wxT("..") );
|
gPrefs->SetPath( wxT("..") );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Kill the bars
|
||||||
|
for( ndx = 0; ndx < ToolBarCount; ndx++ )
|
||||||
|
{
|
||||||
|
ToolBar *bar = mBars[ ndx ];
|
||||||
|
bar->Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
// Restore original config path
|
// Restore original config path
|
||||||
gPrefs->SetPath( oldpath );
|
gPrefs->SetPath( oldpath );
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
@ -1253,7 +1296,8 @@ void ToolManager::OnGrabber( GrabberEvent & event )
|
|||||||
if (mDragBar->IsDocked()) {
|
if (mDragBar->IsDocked()) {
|
||||||
mPrevDock = dynamic_cast<ToolDock*>(mDragBar->GetParent());
|
mPrevDock = dynamic_cast<ToolDock*>(mDragBar->GetParent());
|
||||||
wxASSERT(mPrevDock);
|
wxASSERT(mPrevDock);
|
||||||
mPrevSlot = mPrevDock->Find(mDragBar);
|
mPrevSlot = mPrevDock->GetConfiguration().Find(mDragBar);
|
||||||
|
mPrevDock->WrapConfiguration(mPrevConfiguration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mPrevPosition = mDragBar->GetParent()->GetPosition();
|
mPrevPosition = mDragBar->GetParent()->GetPosition();
|
||||||
@ -1315,6 +1359,7 @@ void ToolManager::HandleEscapeKey()
|
|||||||
// Why don't you leave me alone?
|
// Why don't you leave me alone?
|
||||||
// Well, I feel so break up
|
// Well, I feel so break up
|
||||||
// I want to go home.
|
// I want to go home.
|
||||||
|
mPrevDock->RestoreConfiguration(mPrevConfiguration);
|
||||||
mPrevDock->Dock( mDragBar, true, mPrevSlot );
|
mPrevDock->Dock( mDragBar, true, mPrevSlot );
|
||||||
|
|
||||||
// Done with the floater
|
// Done with the floater
|
||||||
@ -1348,7 +1393,8 @@ void ToolManager::DoneDragging()
|
|||||||
mDragDock = NULL;
|
mDragDock = NULL;
|
||||||
mDragBar = NULL;
|
mDragBar = NULL;
|
||||||
mPrevDock = NULL;
|
mPrevDock = NULL;
|
||||||
mPrevSlot = -1;
|
mPrevSlot = { ToolBarConfiguration::UnspecifiedPosition };
|
||||||
|
mPrevConfiguration.Clear();
|
||||||
mLastPos.x = mBarPos.x = -1;
|
mLastPos.x = mBarPos.x = -1;
|
||||||
mLastPos.y = mBarPos.y = -1;
|
mLastPos.y = mBarPos.y = -1;
|
||||||
mTimer.Stop();
|
mTimer.Stop();
|
||||||
|
@ -91,7 +91,7 @@ class ToolManager final : public wxEvtHandler
|
|||||||
ToolDock *mDragDock;
|
ToolDock *mDragDock;
|
||||||
ToolBar *mDragBar {};
|
ToolBar *mDragBar {};
|
||||||
wxPoint mDragOffset;
|
wxPoint mDragOffset;
|
||||||
int mDragBefore;
|
ToolBarConfiguration::Position mDragBefore {};
|
||||||
|
|
||||||
wxPoint mLastPos;
|
wxPoint mLastPos;
|
||||||
wxRect mBarPos;
|
wxRect mBarPos;
|
||||||
@ -115,7 +115,9 @@ class ToolManager final : public wxEvtHandler
|
|||||||
|
|
||||||
wxPoint mPrevPosition {};
|
wxPoint mPrevPosition {};
|
||||||
ToolDock *mPrevDock {};
|
ToolDock *mPrevDock {};
|
||||||
int mPrevSlot {-1};
|
ToolBarConfiguration::Position mPrevSlot
|
||||||
|
{ ToolBarConfiguration::UnspecifiedPosition };
|
||||||
|
ToolBarConfiguration mPrevConfiguration;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user