- Deleted MetadataKeyValue and MetadataValue from core. No idea what these

are/were, but they're not used anymore
- Deleted OutputWindow.h -- not necessary to subclass
- Moved ListView::SetAdapter functionality into the ScrollableWindow base
  class
- Cleaned up adapter ownership by using shared, instead of raw, pointers.
This commit is contained in:
casey langen 2017-01-09 23:13:57 -08:00
parent 05afff01ad
commit f6403bd5f7
24 changed files with 115 additions and 452 deletions

View File

@ -18,8 +18,6 @@ set(CORE_SOURCES
./library/Indexer.cpp
./library/LibraryFactory.cpp
./library/LocalLibrary.cpp
./library/metadata/MetadataKeyValue.cpp
./library/metadata/MetadataValue.cpp
./library/query/QueryBase.cpp
./library/track/IndexerTrack.cpp
./library/track/LibraryTrack.cpp

View File

@ -277,7 +277,7 @@ void PlaybackService::ProcessMessage(IMessage &message) {
(*it)->OnPlaybackStateChanged((PlaybackState) eventType);
}
this->PlaybackEvent(eventType);
this->PlaybackEvent((PlaybackState) eventType);
}
else if (type == MESSAGE_PREPARE_NEXT_TRACK) {
if (transport.GetPlaybackState() != PlaybackStopped) {

View File

@ -98,7 +98,6 @@
<ClCompile Include="library\Indexer.cpp" />
<ClCompile Include="library\LocalLibrary.cpp" />
<ClCompile Include="library\LibraryFactory.cpp" />
<ClCompile Include="library\metadata\MetadataValue.cpp" />
<ClCompile Include="Library\query\QueryBase.cpp" />
<ClCompile Include="library\track\IndexerTrack.cpp" />
<ClCompile Include="library\track\LibraryTrack.cpp" />
@ -142,7 +141,6 @@
<ClInclude Include="library\LocalLibrary.h" />
<ClInclude Include="library\LibraryFactory.h" />
<ClInclude Include="library\LocalLibraryConstants.h" />
<ClInclude Include="library\metadata\MetadataValue.h" />
<ClInclude Include="Library\query\QueryBase.h" />
<ClInclude Include="library\track\IndexerTrack.h" />
<ClInclude Include="library\track\LibraryTrack.h" />

View File

@ -29,9 +29,6 @@
<Filter Include="src\plugin">
<UniqueIdentifier>{928fef19-2739-4485-83ae-1e18892247b0}</UniqueIdentifier>
</Filter>
<Filter Include="src\library\metadata">
<UniqueIdentifier>{9f9ee41d-111b-4dab-8663-946253eeb46f}</UniqueIdentifier>
</Filter>
<Filter Include="src\db">
<UniqueIdentifier>{9c63f496-9ae4-4032-8b1d-b1cdcd09a1d2}</UniqueIdentifier>
</Filter>
@ -91,9 +88,6 @@
<ClCompile Include="plugin\PluginFactory.cpp">
<Filter>src\plugin</Filter>
</ClCompile>
<ClCompile Include="library\metadata\MetadataValue.cpp">
<Filter>src\library\metadata</Filter>
</ClCompile>
<ClCompile Include="debug.cpp">
<Filter>src</Filter>
</ClCompile>
@ -219,9 +213,6 @@
<ClInclude Include="plugin\PluginFactory.h">
<Filter>src\plugin</Filter>
</ClInclude>
<ClInclude Include="library\metadata\MetadataValue.h">
<Filter>src\library\metadata</Filter>
</ClInclude>
<ClInclude Include="sdk\IMetadataReader.h">
<Filter>src\sdk</Filter>
</ClInclude>

View File

@ -1,50 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.hpp"
#include <core/library/metadata/MetadataKeyValue.h>
using namespace musik::core;
MetadataKeyValue::MetadataKeyValue(const DBID newId, const char *value)
: id (newId) {
if (value) {
this->value = value;
}
}
MetadataKeyValue::~MetadataKeyValue() {
}

View File

@ -1,58 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/config.h>
#include <boost/shared_ptr.hpp>
#include <string>
#include <vector>
namespace musik { namespace core {
class MetadataKeyValue {
public:
MetadataKeyValue(const DBID newId, const char *value);
~MetadataKeyValue();
DBID id;
std::string value;
};
typedef std::shared_ptr<MetadataKeyValue> MetadataKeyValuePtr;
typedef std::vector<MetadataKeyValuePtr> MetadataKeyValueList;
} }

View File

@ -1,51 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2016 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.hpp"
#include <core/library/metadata/MetadataValue.h>
using namespace musik::core;
MetadataValue::MetadataValue(const DBID newId, const char *value)
: id(newId) {
if (value) {
this->value = value;
}
}
MetadataValue::MetadataValue() {
}
MetadataValue::~MetadataValue() {
}

View File

@ -1,59 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2016 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/config.h>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <string>
#include <vector>
namespace musik { namespace core {
class MetadataValue{
public:
MetadataValue(void);
MetadataValue(const DBID newId,const char *value);
~MetadataValue(void);
DBID id;
std::string value;
};
typedef std::shared_ptr<MetadataValue> MetadataValuePtr;
typedef std::vector<MetadataValuePtr> MetadataValueVector;
} }

View File

@ -19,7 +19,6 @@ set (BOX_SRCS
./app/window/CategoryListView.cpp
./app/window/EntryWithHeader.cpp
./app/window/LogWindow.cpp
./app/window/OutputWindow.cpp
./app/window/TrackListView.cpp
./app/window/TransportWindow.cpp
./cursespp/App.cpp

View File

@ -37,6 +37,8 @@
#include "ConsoleLayout.h"
#include <cursespp/Screen.h>
#include <cursespp/MultiLineEntry.h>
#include <cursespp/Colors.h>
#include <core/sdk/IPlugin.h>
#include <core/plugin/PluginFactory.h>
@ -59,14 +61,19 @@ using namespace musik::core::sdk;
using namespace musik::box;
using namespace cursespp;
typedef IScrollAdapter::EntryPtr EntryPtr;
ConsoleLayout::ConsoleLayout(ITransport& transport, LibraryPtr library)
: LayoutBase()
, transport(transport)
, library(library) {
this->SetFrameVisible(false);
this->outputAdapter.reset(new SimpleScrollAdapter());
this->outputAdapter->SetMaxEntries(500);
this->logs.reset(new LogWindow(this));
this->output.reset(new OutputWindow(this));
this->output.reset(new ScrollableWindow(this->outputAdapter, this));
this->commands.reset(new cursespp::TextInput());
this->commands->SetFocusOrder(0);
@ -115,15 +122,20 @@ void ConsoleLayout::SetShortcutsWindow(ShortcutsWindow* shortcuts) {
}
}
void ConsoleLayout::WriteOutput(const std::string& str, int64 attrs) {
this->outputAdapter->AddEntry(EntryPtr(new MultiLineEntry(str, attrs)));
this->output->OnAdapterChanged();
}
void ConsoleLayout::OnEnterPressed(TextInput *input) {
std::string command = this->commands->GetText();
this->commands->SetText("");
output->WriteLine("> " + command + "\n", COLOR_PAIR(CURSESPP_TEXT_DEFAULT));
this->WriteOutput("> " + command + "\n", COLOR_PAIR(CURSESPP_TEXT_DEFAULT));
if (!this->ProcessCommand(command)) {
if (command.size()) {
output->WriteLine(
this->WriteOutput(
"illegal command: '" +
command +
"'\n", COLOR_PAIR(CURSESPP_TEXT_ERROR));
@ -157,26 +169,26 @@ void ConsoleLayout::SetVolume(float volume) {
void ConsoleLayout::Help() {
int64 s = -1;
this->output->WriteLine("help:\n", s);
this->output->WriteLine(" <tab> to switch between windows", s);
this->output->WriteLine("", s);
this->output->WriteLine(" addir <dir>: add a music directory", s);
this->output->WriteLine(" rmdir <dir>: remove a music directory", s);
this->output->WriteLine(" lsdirs: list scanned directories", s);
this->output->WriteLine(" rescan: rescan paths for new metadata", s);
this->output->WriteLine("", s);
this->output->WriteLine(" play <uri>: play audio at <uri>", s);
this->output->WriteLine(" pause: pause/resume", s);
this->output->WriteLine(" stop: stop and clean up everything", s);
this->output->WriteLine(" volume: <0 - 100>: set % volume", s);
this->output->WriteLine(" clear: clear the log window", s);
this->output->WriteLine(" seek <seconds>: seek to <seconds> into track", s);
this->output->WriteLine("", s);
this->output->WriteLine(" plugins: list loaded plugins", s);
this->output->WriteLine("", s);
this->output->WriteLine(" version: show musikbox app version", s);
this->output->WriteLine("", s);
this->output->WriteLine(" <ctrl+d>: quit\n", s);
this->WriteOutput("help:\n", s);
this->WriteOutput(" <tab> to switch between windows", s);
this->WriteOutput("", s);
this->WriteOutput(" addir <dir>: add a music directory", s);
this->WriteOutput(" rmdir <dir>: remove a music directory", s);
this->WriteOutput(" lsdirs: list scanned directories", s);
this->WriteOutput(" rescan: rescan paths for new metadata", s);
this->WriteOutput("", s);
this->WriteOutput(" play <uri>: play audio at <uri>", s);
this->WriteOutput(" pause: pause/resume", s);
this->WriteOutput(" stop: stop and clean up everything", s);
this->WriteOutput(" volume: <0 - 100>: set % volume", s);
this->WriteOutput(" clear: clear the log window", s);
this->WriteOutput(" seek <seconds>: seek to <seconds> into track", s);
this->WriteOutput("", s);
this->WriteOutput(" plugins: list loaded plugins", s);
this->WriteOutput("", s);
this->WriteOutput(" version: show musikbox app version", s);
this->WriteOutput("", s);
this->WriteOutput(" <ctrl+d>: quit\n", s);
}
bool ConsoleLayout::ProcessCommand(const std::string& cmd) {
@ -210,7 +222,7 @@ bool ConsoleLayout::ProcessCommand(const std::string& cmd) {
}
else if (name == "version") {
const std::string v = boost::str(boost::format("v%s") % VERSION);
this->output->WriteLine(v, -1);
this->WriteOutput(v, -1);
}
else if (name == "play" || name == "pl" || name == "p") {
return this->PlayFile(args);
@ -226,11 +238,11 @@ bool ConsoleLayout::ProcessCommand(const std::string& cmd) {
else if (name == "lsdirs") {
std::vector<std::string> paths;
library->Indexer()->GetPaths(paths);
this->output->WriteLine("paths:");
this->WriteOutput("paths:");
for (size_t i = 0; i < paths.size(); i++) {
this->output->WriteLine(" " + paths.at(i));
this->WriteOutput(" " + paths.at(i));
}
this->output->WriteLine("");
this->WriteOutput("");
}
else if (name == "rescan" || name == "scan" || name == "index") {
library->Indexer()->Synchronize();
@ -251,7 +263,7 @@ bool ConsoleLayout::ProcessCommand(const std::string& cmd) {
this->ListPlugins();
}
else if (name == "sdk") {
this->output->WriteLine(" sdk/api revision: " +
this->WriteOutput(" sdk/api revision: " +
std::to_string(musik::core::sdk::SdkVersion));
}
else if (name == "v" || name == "volume") {
@ -288,7 +300,7 @@ void ConsoleLayout::Stop() {
this->transport.Stop();
}
void ConsoleLayout::ListPlugins() const {
void ConsoleLayout::ListPlugins() {
using musik::core::sdk::IPlugin;
using musik::core::PluginFactory;
@ -305,6 +317,6 @@ void ConsoleLayout::ListPlugins() const {
" version: " + std::string((*it)->Version()) + "\n"
" by " + std::string((*it)->Author()) + "\n";
this->output->WriteLine(format, COLOR_PAIR(CURSESPP_TEXT_DEFAULT));
this->WriteOutput(format, COLOR_PAIR(CURSESPP_TEXT_DEFAULT));
}
}

View File

@ -37,9 +37,9 @@
#include <cursespp/LayoutBase.h>
#include <cursespp/TextInput.h>
#include <cursespp/ShortcutsWindow.h>
#include <cursespp/ScrollableWindow.h>
#include <app/window/LogWindow.h>
#include <app/window/OutputWindow.h>
#include <app/window/TransportWindow.h>
#include <vector>
@ -71,7 +71,7 @@ namespace musik {
private:
void OnEnterPressed(cursespp::TextInput* input);
void ListPlugins() const;
void ListPlugins();
bool ProcessCommand(const std::string& cmd);
bool PlayFile(const std::vector<std::string>& args);
void Pause();
@ -81,9 +81,12 @@ namespace musik {
void SetVolume(float volume);
void Help();
void WriteOutput(const std::string& str, int64 attrs = -1);
std::shared_ptr<LogWindow> logs;
std::shared_ptr<cursespp::TextInput> commands;
std::shared_ptr<OutputWindow> output;
std::shared_ptr<cursespp::ScrollableWindow> output;
std::shared_ptr<cursespp::SimpleScrollAdapter> outputAdapter;
musik::core::audio::ITransport& transport;
musik::core::LibraryPtr library;
};

View File

@ -91,6 +91,8 @@ SettingsLayout::SettingsLayout(
, transport(transport) {
this->libraryPrefs = Preferences::ForComponent(core::prefs::components::Settings);
this->indexer->PathsUpdated.connect(this, &SettingsLayout::RefreshAddedPaths);
this->browseAdapter.reset(new DirectoryAdapter());
this->addedPathsAdapter.reset(new SimpleScrollAdapter());
this->InitializeWindows();
}
@ -104,7 +106,7 @@ void SettingsLayout::OnCheckboxChanged(cursespp::Checkbox* cb, bool checked) {
}
else if (cb == dotfileCheckbox.get()) {
showDotfiles = !showDotfiles;
this->browseAdapter.SetDotfilesVisible(showDotfiles);
this->browseAdapter->SetDotfilesVisible(showDotfiles);
this->browseList->OnAdapterChanged();
}
else if (cb == focusShortcutsCheckbox.get()) {
@ -189,7 +191,7 @@ void SettingsLayout::OnLayout() {
}
void SettingsLayout::RefreshAddedPaths() {
this->addedPathsAdapter.Clear();
this->addedPathsAdapter->Clear();
std::vector<std::string> paths;
this->indexer->GetPaths(paths);
@ -197,7 +199,7 @@ void SettingsLayout::RefreshAddedPaths() {
for (size_t i = 0; i < paths.size(); i++) {
auto v = paths.at(i);
auto e = EntryPtr(new SingleLineEntry(v));
this->addedPathsAdapter.AddEntry(e);
this->addedPathsAdapter->AddEntry(e);
}
this->addedPathsList->OnAdapterChanged();
@ -229,8 +231,8 @@ void SettingsLayout::InitializeWindows() {
this->addedPathsLabel.reset(new TextLabel());
this->addedPathsLabel->SetText("indexed paths (BACKSPACE to remove)", text::AlignCenter);
this->addedPathsList.reset(new cursespp::ListWindow(&this->addedPathsAdapter));
this->browseList.reset(new cursespp::ListWindow(&this->browseAdapter));
this->addedPathsList.reset(new cursespp::ListWindow(this->addedPathsAdapter));
this->browseList.reset(new cursespp::ListWindow(this->browseAdapter));
ScrollAdapterBase::ItemDecorator decorator =
std::bind(
@ -241,8 +243,8 @@ void SettingsLayout::InitializeWindows() {
std::placeholders::_3,
std::placeholders::_4);
this->addedPathsAdapter.SetItemDecorator(decorator);
this->browseAdapter.SetItemDecorator(decorator);
this->addedPathsAdapter->SetItemDecorator(decorator);
this->browseAdapter->SetItemDecorator(decorator);
this->outputDropdown.reset(new TextLabel());
this->outputDropdown->Activated.connect(this, &SettingsLayout::OnOutputDropdownActivated);
@ -354,7 +356,7 @@ void SettingsLayout::LoadPreferences() {
void SettingsLayout::AddSelectedDirectory() {
size_t index = this->browseList->GetSelectedIndex();
std::string path = this->browseAdapter.GetFullPathAt(index);
std::string path = this->browseAdapter->GetFullPathAt(index);
if (path.size()) {
this->indexer->AddPath(path);
@ -369,7 +371,7 @@ void SettingsLayout::RemoveSelectedDirectory() {
}
void SettingsLayout::DrillIntoSelectedDirectory() {
this->browseAdapter.Select(this->browseList->GetSelectedIndex());
this->browseAdapter->Select(this->browseList->GetSelectedIndex());
this->browseList->SetSelectedIndex(0);
this->browseList->OnAdapterChanged();
}

View File

@ -128,8 +128,8 @@ namespace musik {
std::shared_ptr<cursespp::DialogOverlay> firstRunDialog;
cursespp::SimpleScrollAdapter addedPathsAdapter;
DirectoryAdapter browseAdapter;
std::shared_ptr<cursespp::SimpleScrollAdapter> addedPathsAdapter;
std::shared_ptr<DirectoryAdapter> browseAdapter;
};
}
}

View File

@ -52,7 +52,7 @@ typedef IScrollAdapter::IEntry IEntry;
this->PostMessage(REFRESH, 0, 0, 250);
LogWindow::LogWindow(IWindow *parent)
: ScrollableWindow(parent) {
: ScrollableWindow(nullptr, parent) {
this->adapter = new SimpleScrollAdapter();
this->adapter->SetMaxEntries(500);

View File

@ -1,67 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2016 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "OutputWindow.h"
#include <cursespp/Screen.h>
#include <cursespp/Colors.h>
#include <cursespp/MultiLineEntry.h>
using namespace musik::box;
using namespace cursespp;
typedef IScrollAdapter::EntryPtr EntryPtr;
OutputWindow::OutputWindow(IWindow *parent)
: ScrollableWindow(parent) {
this->adapter = new SimpleScrollAdapter();
this->adapter->SetDisplaySize(this->GetContentWidth(), this->GetContentHeight());
this->adapter->SetMaxEntries(500);
}
OutputWindow::~OutputWindow() {
delete this->adapter;
this->adapter = nullptr;
}
IScrollAdapter& OutputWindow::GetScrollAdapter() {
return (IScrollAdapter&) *this->adapter;
}
void OutputWindow::WriteLine(const std::string& text, int64 attrs) {
this->adapter->AddEntry(EntryPtr(new MultiLineEntry(text, attrs)));
this->OnAdapterChanged();
}

View File

@ -1,61 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2016 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <cursespp/curses_config.h>
#include <cursespp/ScrollableWindow.h>
#include <cursespp/SimpleScrollAdapter.h>
#include <cursespp/Colors.h>
namespace musik {
namespace box {
class OutputWindow :
public cursespp::ScrollableWindow
#if (__clang_major__ == 7 && __clang_minor__ == 3)
, public std::enable_shared_from_this<OutputWindow>
#endif
{
public:
OutputWindow(cursespp::IWindow *parent = NULL);
virtual ~OutputWindow();
void WriteLine(const std::string& line, int64 attrs = -1);
virtual cursespp::IScrollAdapter& GetScrollAdapter();
private:
cursespp::SimpleScrollAdapter* adapter;
};
}
}

View File

@ -40,7 +40,6 @@
#include <core/runtime/IMessage.h>
#include <core/audio/PlaybackService.h>
#include <sigslot/sigslot.h>
#include "OutputWindow.h"
namespace musik {
namespace box {

View File

@ -101,7 +101,7 @@ ListOverlay& ListOverlay::SetTitle(const std::string& title) {
ListOverlay& ListOverlay::SetAdapter(IScrollAdapterPtr adapter) {
if (this->adapter != adapter) {
this->adapter = adapter;
this->listWindow->SetAdapter(adapter.get());
this->listWindow->SetAdapter(adapter);
}
return *this;

View File

@ -42,47 +42,26 @@ typedef IScrollAdapter::ScrollPosition ScrollPos;
size_t ListWindow::NO_SELECTION = (size_t) -1;
class EmptyAdapter : public IScrollAdapter {
public:
virtual void SetDisplaySize(size_t width, size_t height) { }
virtual size_t GetEntryCount() { return 0; }
virtual EntryPtr GetEntry(cursespp::ScrollableWindow* window, size_t index) { return IScrollAdapter::EntryPtr(); }
virtual void DrawPage(ScrollableWindow* window, size_t index, ScrollPosition *result = NULL) { }
};
static EmptyAdapter emptyAdapter;
ListWindow::ListWindow(IScrollAdapter* adapter, IWindow *parent)
: ScrollableWindow(parent)
, adapter(adapter)
ListWindow::ListWindow(std::shared_ptr<IScrollAdapter> adapter, IWindow *parent)
: ScrollableWindow(adapter, parent)
, selectedIndex(0) {
}
ListWindow::ListWindow(IWindow *parent)
: ListWindow(std::shared_ptr<IScrollAdapter>(), parent) {
}
ListWindow::~ListWindow() {
}
void ListWindow::SetAdapter(IScrollAdapter* adapter) {
if (adapter != this->adapter) {
this->adapter = adapter;
this->ScrollToTop();
}
}
void ListWindow::ScrollToTop() {
this->SetSelectedIndex(0);
this->ScrollTo(0);
}
IScrollAdapter& ListWindow::GetScrollAdapter() {
if (this->adapter) {
return *this->adapter;
}
return emptyAdapter;
}
void ListWindow::ScrollToBottom() {
IScrollAdapter& adapter = this->GetScrollAdapter();
this->SetSelectedIndex(std::max((size_t) 0, adapter.GetEntryCount() - 1));

View File

@ -52,7 +52,9 @@ namespace cursespp {
sigslot::signal3<ListWindow*, size_t, size_t> SelectionChanged;
sigslot::signal2<ListWindow*, size_t> Invalidated;
ListWindow(IScrollAdapter* adapter = nullptr, IWindow *parent = nullptr);
ListWindow(std::shared_ptr<IScrollAdapter> adapter, IWindow *parent = nullptr);
ListWindow(IWindow *parent = nullptr);
virtual ~ListWindow();
virtual void ScrollToTop();
@ -66,8 +68,6 @@ namespace cursespp {
virtual size_t GetSelectedIndex();
virtual void SetSelectedIndex(size_t index);
virtual void SetAdapter(IScrollAdapter* adapter);
virtual void OnAdapterChanged();
virtual const IScrollAdapter::ScrollPosition& GetScrollPosition();
@ -77,13 +77,11 @@ namespace cursespp {
virtual void OnInvalidated();
virtual void OnDimensionsChanged();
virtual IScrollAdapter& GetScrollAdapter();
virtual IScrollAdapter::ScrollPosition& GetMutableScrollPosition();
private:
virtual bool IsSelectedItemCompletelyVisible();
IScrollAdapter* adapter;
IScrollAdapter::ScrollPosition scrollPosition;
size_t selectedIndex;
};

View File

@ -47,6 +47,16 @@ static const size_t INVALID_INDEX = (size_t) -1;
typedef IScrollAdapter::ScrollPosition ScrollPos;
class EmptyAdapter : public IScrollAdapter {
public:
virtual void SetDisplaySize(size_t width, size_t height) { }
virtual size_t GetEntryCount() { return 0; }
virtual EntryPtr GetEntry(cursespp::ScrollableWindow* window, size_t index) { return IScrollAdapter::EntryPtr(); }
virtual void DrawPage(ScrollableWindow* window, size_t index, ScrollPosition *result = NULL) { }
};
static EmptyAdapter emptyAdapter;
#define REDRAW_VISIBLE_PAGE() \
{ \
ScrollPos& pos = GetMutableScrollPosition(); \
@ -56,14 +66,34 @@ typedef IScrollAdapter::ScrollPosition ScrollPos;
&pos); \
} \
ScrollableWindow::ScrollableWindow(IWindow *parent)
ScrollableWindow::ScrollableWindow(std::shared_ptr<IScrollAdapter> adapter, IWindow *parent)
: Window(parent)
, adapter(adapter)
, allowArrowKeyPropagation(false) {
}
ScrollableWindow::ScrollableWindow(IWindow *parent)
: ScrollableWindow(std::shared_ptr<IScrollAdapter>(), parent) {
}
ScrollableWindow::~ScrollableWindow() {
}
void ScrollableWindow::SetAdapter(std::shared_ptr<IScrollAdapter> adapter) {
if (adapter != this->adapter) {
this->adapter = adapter;
this->ScrollToTop();
}
}
IScrollAdapter& ScrollableWindow::GetScrollAdapter() {
if (this->adapter) {
return *this->adapter;
}
return emptyAdapter;
}
void ScrollableWindow::OnDimensionsChanged() {
Window::OnDimensionsChanged();

View File

@ -43,9 +43,16 @@
namespace cursespp {
class ScrollableWindow : public IScrollable, public IKeyHandler, public Window {
public:
ScrollableWindow(IWindow *parent = NULL);
ScrollableWindow(
std::shared_ptr<IScrollAdapter> adapter,
IWindow *parent = nullptr);
ScrollableWindow(IWindow *parent = nullptr);
virtual ~ScrollableWindow();
virtual void SetAdapter(std::shared_ptr<IScrollAdapter> adapter);
virtual void Show();
virtual void OnDimensionsChanged();
@ -69,13 +76,14 @@ namespace cursespp {
virtual const IScrollAdapter::ScrollPosition& GetScrollPosition();
protected:
virtual IScrollAdapter& GetScrollAdapter() = 0;
virtual IScrollAdapter& GetScrollAdapter();
virtual IScrollAdapter::ScrollPosition& GetMutableScrollPosition();
size_t GetPreviousPageEntryIndex();
bool IsLastItemVisible();
private:
std::shared_ptr<IScrollAdapter> adapter;
IScrollAdapter::ScrollPosition scrollPosition;
bool allowArrowKeyPropagation;
};

View File

@ -141,7 +141,6 @@
<ClCompile Include="app\window\CategoryListView.cpp" />
<ClCompile Include="app\window\EntryWithHeader.cpp" />
<ClCompile Include="app\window\LogWindow.cpp" />
<ClCompile Include="app\window\OutputWindow.cpp" />
<ClCompile Include="app\window\TrackListView.cpp" />
<ClCompile Include="app\window\TransportWindow.cpp" />
<ClCompile Include="cursespp\App.cpp" />
@ -191,7 +190,6 @@
<ClInclude Include="app\window\CategoryListView.h" />
<ClInclude Include="app\window\EntryWithHeader.h" />
<ClInclude Include="app\window\LogWindow.h" />
<ClInclude Include="app\window\OutputWindow.h" />
<ClInclude Include="app\window\TrackListView.h" />
<ClInclude Include="app\window\TransportWindow.h" />
<ClInclude Include="cursespp\App.h" />

View File

@ -33,9 +33,6 @@
<ClCompile Include="app\layout\LibraryLayout.cpp">
<Filter>app\layout</Filter>
</ClCompile>
<ClCompile Include="app\window\OutputWindow.cpp">
<Filter>app\window</Filter>
</ClCompile>
<ClCompile Include="app\window\TrackListView.cpp">
<Filter>app\window</Filter>
</ClCompile>
@ -192,9 +189,6 @@
<ClInclude Include="app\window\LogWindow.h">
<Filter>app\window</Filter>
</ClInclude>
<ClInclude Include="app\window\OutputWindow.h">
<Filter>app\window</Filter>
</ClInclude>
<ClInclude Include="app\window\TrackListView.h">
<Filter>app\window</Filter>
</ClInclude>