mirror of
https://github.com/clangen/musikcube.git
synced 2025-04-15 20:42:33 +00:00
cursespp and musikbox are compiling! not running though.
This commit is contained in:
parent
e33f9928fb
commit
d12eae819d
@ -48,10 +48,11 @@ set (musikbox_LINK_LIBS
|
||||
include_directories (
|
||||
"${musikbox_SOURCE_DIR}/src"
|
||||
"${musikbox_SOURCE_DIR}/src/core"
|
||||
"${musikbox_SOURCE_DIR}/src/musikbox"
|
||||
"${musikbox_SOURCE_DIR}/src/3rdparty/include"
|
||||
)
|
||||
|
||||
add_subdirectory(src/3rdparty)
|
||||
add_subdirectory(src/core)
|
||||
#add_subdirectory(src/contrib)
|
||||
#add_subdirectory(src/musikbox)
|
||||
add_subdirectory(src/musikbox)
|
||||
|
@ -1,20 +1,84 @@
|
||||
set (SQUARE_SRCS
|
||||
stdafx.cpp
|
||||
player.cpp
|
||||
DummyAudioEventHandler.cpp
|
||||
ConsoleUI.cpp
|
||||
set (BOX_SRCS
|
||||
./Main.cpp
|
||||
./stdafx.cpp
|
||||
./app/layout/LibraryLayout.cpp
|
||||
./app/layout/MainLayout.cpp
|
||||
./app/query/CategoryListViewQuery.cpp
|
||||
./app/query/SingleTrackQuery.cpp
|
||||
./app/query/TrackListViewQuery.cpp
|
||||
./app/service/PlaybackService.cpp
|
||||
./app/util/GlobalHotkeys.cpp
|
||||
./app/util/SystemInfo.cpp
|
||||
./app/util/Text.cpp
|
||||
./app/window/CategoryListView.cpp
|
||||
./app/window/CommandWindow.cpp
|
||||
./app/window/LogWindow.cpp
|
||||
./app/window/OutputWindow.cpp
|
||||
./app/window/ResourcesWindow.cpp
|
||||
./app/window/TrackListView.cpp
|
||||
./app/window/TransportWindow.cpp
|
||||
./cursespp/Colors.cpp
|
||||
./cursespp/LayoutBase.cpp
|
||||
./cursespp/LayoutStack.cpp
|
||||
./cursespp/ListWindow.cpp
|
||||
./cursespp/Message.cpp
|
||||
./cursespp/MessageQueue.cpp
|
||||
./cursespp/MultiLineEntry.cpp
|
||||
./cursespp/Screen.cpp
|
||||
./cursespp/ScrollableWindow.cpp
|
||||
./cursespp/ScrollAdapterBase.cpp
|
||||
./cursespp/SimpleScrollAdapter.cpp
|
||||
./cursespp/SingleLineEntry.cpp
|
||||
./cursespp/Window.cpp
|
||||
./cursespp/WindowLayout.cpp
|
||||
)
|
||||
|
||||
set (SQUARE_HEADERS
|
||||
config.h
|
||||
ConsoleUI.h
|
||||
DummyAudioEventHandler.h
|
||||
memtrace.h
|
||||
stdafx.h
|
||||
set (BOX_HEADERS
|
||||
./stdafx.h
|
||||
./app/layout/LibraryLayout.h
|
||||
./app/layout/MainLayout.h
|
||||
./app/query/CategoryListViewQuery.h
|
||||
./app/query/SingleTrackQuery.h
|
||||
./app/query/TrackListViewQuery.h
|
||||
./app/service/PlaybackService.h
|
||||
./app/util/GlobalHotkeys.h
|
||||
./app/util/SystemInfo.h
|
||||
./app/util/Text.h
|
||||
./app/window/CategoryListView.h
|
||||
./app/window/CommandWindow.h
|
||||
./app/window/LogWindow.h
|
||||
./app/window/OutputWindow.h
|
||||
./app/window/ResourcesWindow.h
|
||||
./app/window/TrackListView.h
|
||||
./app/window/TransportWindow.h
|
||||
./cursespp/Colors.h
|
||||
./cursespp/curses_config.h
|
||||
./cursespp/IDisplayable.h
|
||||
./cursespp/IInput.h
|
||||
./cursespp/IKeyHandler.h
|
||||
./cursespp/ILayout.h
|
||||
./cursespp/ILayoutStack.h
|
||||
./cursespp/IMessage.h
|
||||
./cursespp/IMessageTarget.h
|
||||
./cursespp/IOrderable.h
|
||||
./cursespp/IScrollable.h
|
||||
./cursespp/IScrollAdapter.h
|
||||
./cursespp/IWindow.h
|
||||
./cursespp/IWindowGroup.h
|
||||
./cursespp/LayoutBase.h
|
||||
./cursespp/LayoutStack.h
|
||||
./cursespp/ListWindow.h
|
||||
./cursespp/Message.h
|
||||
./cursespp/MessageQueue.h
|
||||
./cursespp/MultiLineEntry.h
|
||||
./cursespp/Screen.h
|
||||
./cursespp/ScrollableWindow.h
|
||||
./cursespp/ScrollAdapterBase.h
|
||||
./cursespp/SimpleScrollAdapter.h
|
||||
./cursespp/SingleLineEntry.h
|
||||
./cursespp/Window.h
|
||||
./cursespp/WindowLayout.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP ("Source Files" FILES ${SQUARE_SRCS})
|
||||
SOURCE_GROUP ("Header Files" FILES ${SQUARE_HEADERS})
|
||||
|
||||
add_executable(square ${SQUARE_SRCS} ${SQUARE_HEADERS})
|
||||
target_link_libraries(square ${musikCube_LINK_LIBS} musik)
|
||||
add_executable(musikbox ${BOX_SRCS} ${BOX_HEADERS})
|
||||
target_link_libraries(musikbox ${musikbox_LINK_LIBS} curses panel musikcore)
|
||||
|
@ -95,7 +95,7 @@ static void changeLayout(WindowState& current, ILayoutPtr newLayout) {
|
||||
|
||||
if (current.layout) {
|
||||
current.layout->Hide();
|
||||
current.layout = { 0 };
|
||||
current.layout.reset();
|
||||
}
|
||||
|
||||
if (newLayout) {
|
||||
@ -184,14 +184,17 @@ int main(int argc, char* argv[])
|
||||
|
||||
GlobalHotkeys globalHotkeys(playback, library);
|
||||
|
||||
ILayoutPtr libraryLayout(new LibraryLayout(playback, library));
|
||||
ILayoutPtr consoleLayout(new MainLayout(tp, library));
|
||||
ILayoutPtr libraryLayout((ILayout *) new LibraryLayout(playback, library));
|
||||
ILayoutPtr consoleLayout((ILayout *) new MainLayout(tp, library));
|
||||
|
||||
int64 ch;
|
||||
timeout(IDLE_TIMEOUT_MS);
|
||||
bool quit = false;
|
||||
|
||||
WindowState state = { 0 };
|
||||
WindowState state;
|
||||
state.input = NULL;
|
||||
state.keyHandler = NULL;
|
||||
|
||||
changeLayout(state, libraryLayout);
|
||||
|
||||
while (!quit) {
|
||||
@ -249,4 +252,3 @@ int main(int argc, char* argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@ namespace musik {
|
||||
|
||||
virtual void Layout();
|
||||
virtual void Show();
|
||||
virtual bool LibraryLayout::KeyPress(int64 ch);
|
||||
virtual cursespp::IWindowPtr GetFocus();
|
||||
virtual bool KeyPress(int64 ch);
|
||||
|
||||
private:
|
||||
void InitializeWindows();
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "MainLayout.h"
|
||||
#include <cursespp/Screen.h>
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "CategoryListViewQuery.h"
|
||||
|
||||
@ -17,7 +15,7 @@ using namespace musik::core::db;
|
||||
using namespace musik::core::library::constants;
|
||||
using namespace musik::box;
|
||||
|
||||
#define reset(x) x.reset(new std::vector<std::shared_ptr<Result>>);
|
||||
#define reset(x) x.reset(new std::vector<std::shared_ptr<Result> >);
|
||||
|
||||
static const std::string ALBUM_QUERY =
|
||||
"SELECT DISTINCT albums.id, albums.name "
|
||||
@ -41,9 +39,9 @@ static boost::mutex QUERY_MAP_MUTEX;
|
||||
static std::map<std::string, std::string> FIELD_TO_QUERY_MAP;
|
||||
|
||||
static void initFieldToQueryMap() {
|
||||
FIELD_TO_QUERY_MAP.emplace(Track::ALBUM_ID, ALBUM_QUERY);
|
||||
FIELD_TO_QUERY_MAP.emplace(Track::ARTIST_ID, ARTIST_QUERY);
|
||||
FIELD_TO_QUERY_MAP.emplace(Track::GENRE_ID, GENRE_QUERY);
|
||||
FIELD_TO_QUERY_MAP[Track::ALBUM_ID] = ALBUM_QUERY;
|
||||
FIELD_TO_QUERY_MAP[Track::ARTIST_ID] = ARTIST_QUERY;
|
||||
FIELD_TO_QUERY_MAP[Track::GENRE_ID] = GENRE_QUERY;
|
||||
}
|
||||
|
||||
CategoryListViewQuery::CategoryListViewQuery(const std::string& trackField) {
|
||||
|
@ -14,7 +14,7 @@ namespace musik {
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<std::vector<
|
||||
std::shared_ptr<Result>>> ResultList;
|
||||
std::shared_ptr<Result> > > ResultList;
|
||||
|
||||
CategoryListViewQuery(const std::string& trackField);
|
||||
virtual ~CategoryListViewQuery();
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "SingleTrackQuery.h"
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "TrackListViewQuery.h"
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace musik {
|
||||
class TrackListViewQuery : public musik::core::query::QueryBase {
|
||||
public:
|
||||
typedef std::shared_ptr<
|
||||
std::vector<musik::core::TrackPtr>> Result;
|
||||
std::vector<musik::core::TrackPtr> > Result;
|
||||
|
||||
TrackListViewQuery(
|
||||
musik::core::LibraryPtr library,
|
||||
|
@ -2,13 +2,14 @@
|
||||
|
||||
#include "SystemInfo.h"
|
||||
|
||||
using namespace musik::box;
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include "windows.h"
|
||||
#include "psapi.h"
|
||||
#include "pdh.h"
|
||||
|
||||
using namespace musik::box;
|
||||
|
||||
#ifdef WIN32
|
||||
class WindowsSystemInfo : public SystemInfo {
|
||||
public:
|
||||
WindowsSystemInfo();
|
||||
|
@ -16,12 +16,13 @@ namespace musik {
|
||||
size_t c = 0;
|
||||
while (c < len && it != str.end()) {
|
||||
try {
|
||||
utf8::next(it++, end);
|
||||
utf8::next(it, end);
|
||||
}
|
||||
catch (...) {
|
||||
it++; /* invalid encoding, just treat as a single char */
|
||||
/* invalid encoding, just treat as a single char */
|
||||
}
|
||||
|
||||
++it;
|
||||
++c;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <cursespp/Colors.h>
|
||||
|
||||
|
@ -20,7 +20,11 @@ using cursespp::ScrollAdapterBase;
|
||||
|
||||
namespace musik {
|
||||
namespace box {
|
||||
class CategoryListView : public ListWindow, public sigslot::has_slots<> {
|
||||
class CategoryListView :
|
||||
public ListWindow,
|
||||
public std::enable_shared_from_this<CategoryListView>,
|
||||
public sigslot::has_slots<>
|
||||
{
|
||||
public:
|
||||
CategoryListView(LibraryPtr library, const std::string& fieldName);
|
||||
virtual ~CategoryListView();
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <cursespp/Screen.h>
|
||||
@ -232,7 +230,7 @@ void CommandWindow::ListPlugins() const {
|
||||
using musik::core::IPlugin;
|
||||
using musik::core::PluginFactory;
|
||||
|
||||
typedef std::vector<std::shared_ptr<IPlugin>> PluginList;
|
||||
typedef std::vector<std::shared_ptr<IPlugin> > PluginList;
|
||||
typedef PluginFactory::NullDeleter<IPlugin> Deleter;
|
||||
|
||||
PluginList plugins = PluginFactory::Instance()
|
||||
|
@ -12,6 +12,7 @@ namespace musik {
|
||||
class CommandWindow :
|
||||
public cursespp::Window,
|
||||
public cursespp::IInput,
|
||||
public std::enable_shared_from_this<CommandWindow>,
|
||||
public sigslot::has_slots<>
|
||||
{
|
||||
public:
|
||||
@ -21,7 +22,7 @@ namespace musik {
|
||||
musik::core::LibraryPtr library,
|
||||
OutputWindow& output);
|
||||
|
||||
~CommandWindow();
|
||||
virtual ~CommandWindow();
|
||||
|
||||
virtual void WriteChar(int64 ch);
|
||||
virtual void Focus();
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "LogWindow.h"
|
||||
|
@ -11,10 +11,14 @@
|
||||
|
||||
namespace musik {
|
||||
namespace box {
|
||||
class LogWindow : public cursespp::ScrollableWindow, public sigslot::has_slots<> {
|
||||
class LogWindow :
|
||||
public cursespp::ScrollableWindow,
|
||||
public std::enable_shared_from_this<LogWindow>,
|
||||
public sigslot::has_slots<>
|
||||
{
|
||||
public:
|
||||
LogWindow(cursespp::IWindow *parent = NULL);
|
||||
~LogWindow();
|
||||
virtual ~LogWindow();
|
||||
|
||||
void Update();
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "OutputWindow.h"
|
||||
|
@ -7,10 +7,13 @@
|
||||
|
||||
namespace musik {
|
||||
namespace box {
|
||||
class OutputWindow : public cursespp::ScrollableWindow {
|
||||
class OutputWindow :
|
||||
public cursespp::ScrollableWindow,
|
||||
public std::enable_shared_from_this<OutputWindow>
|
||||
{
|
||||
public:
|
||||
OutputWindow(cursespp::IWindow *parent = NULL);
|
||||
~OutputWindow();
|
||||
virtual ~OutputWindow();
|
||||
|
||||
void WriteLine(const std::string& line, int64 attrs = -1);
|
||||
virtual cursespp::IScrollAdapter& GetScrollAdapter();
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "ResourcesWindow.h"
|
||||
|
@ -7,7 +7,10 @@
|
||||
|
||||
namespace musik {
|
||||
namespace box {
|
||||
class ResourcesWindow : public cursespp::Window {
|
||||
class ResourcesWindow :
|
||||
public cursespp::Window,
|
||||
public std::enable_shared_from_this<ResourcesWindow>
|
||||
{
|
||||
public:
|
||||
ResourcesWindow(cursespp::IWindow *parent = NULL);
|
||||
virtual ~ResourcesWindow();
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <cursespp/Colors.h>
|
||||
|
@ -13,13 +13,17 @@
|
||||
|
||||
namespace musik {
|
||||
namespace box {
|
||||
class TrackListView : public cursespp::ListWindow, public sigslot::has_slots<> {
|
||||
class TrackListView :
|
||||
public cursespp::ListWindow,
|
||||
public std::enable_shared_from_this<TrackListView>,
|
||||
public sigslot::has_slots<>
|
||||
{
|
||||
public:
|
||||
TrackListView(
|
||||
PlaybackService& playback,
|
||||
musik::core::LibraryPtr library);
|
||||
|
||||
~TrackListView();
|
||||
virtual ~TrackListView();
|
||||
|
||||
virtual void ProcessMessage(cursespp::IMessage &message);
|
||||
virtual bool KeyPress(int64 ch);
|
||||
@ -44,7 +48,7 @@ namespace musik {
|
||||
|
||||
private:
|
||||
std::shared_ptr<TrackListViewQuery> query;
|
||||
std::shared_ptr<std::vector<TrackPtr>> metadata;
|
||||
std::shared_ptr<std::vector<TrackPtr> > metadata;
|
||||
Adapter* adapter;
|
||||
PlaybackService& playback;
|
||||
musik::core::LibraryPtr library;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "TransportWindow.h"
|
||||
|
||||
@ -18,6 +16,8 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace musik::core;
|
||||
using namespace musik::core::audio;
|
||||
using namespace musik::core::library;
|
||||
@ -146,7 +146,7 @@ void TransportWindow::Update() {
|
||||
wprintw(c, "\n");
|
||||
|
||||
int volumePercent = (size_t) round(this->transport->Volume() * 100.0f) - 1;
|
||||
int thumbOffset = min(9, (volumePercent * 10) / 100);
|
||||
int thumbOffset = std::min(9, (volumePercent * 10) / 100);
|
||||
|
||||
std::string volume = "vol ";
|
||||
|
||||
@ -190,7 +190,7 @@ void TransportWindow::Update() {
|
||||
|
||||
if (secondsTotal) {
|
||||
size_t progress = (secondsCurrent * 100) / secondsTotal;
|
||||
thumbOffset = min(timerWidth - 1, (progress * timerWidth) / 100);
|
||||
thumbOffset = std::min(timerWidth - 1, (progress * timerWidth) / 100);
|
||||
}
|
||||
|
||||
std::string timerTrack = "";
|
||||
|
@ -10,7 +10,11 @@
|
||||
|
||||
namespace musik {
|
||||
namespace box {
|
||||
class TransportWindow : public cursespp::Window, public sigslot::has_slots<> {
|
||||
class TransportWindow :
|
||||
public cursespp::Window,
|
||||
public std::enable_shared_from_this<TransportWindow>,
|
||||
public sigslot::has_slots<>
|
||||
{
|
||||
public:
|
||||
TransportWindow(
|
||||
musik::core::LibraryPtr library,
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdafx.h>
|
||||
#include "Colors.h"
|
||||
|
||||
|
@ -3,9 +3,8 @@
|
||||
namespace cursespp {
|
||||
class IDisplayable {
|
||||
public:
|
||||
virtual ~IDisplayable() = 0 { }
|
||||
virtual ~IDisplayable() { }
|
||||
virtual void Show() = 0;
|
||||
virtual void Hide() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
namespace cursespp {
|
||||
class IInput {
|
||||
public:
|
||||
virtual ~IInput() = 0 { }
|
||||
virtual ~IInput() { }
|
||||
virtual void WriteChar(int64 ch) = 0;
|
||||
};
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
namespace cursespp {
|
||||
class IKeyHandler {
|
||||
public:
|
||||
virtual ~IKeyHandler() = 0 { }
|
||||
virtual ~IKeyHandler() { }
|
||||
virtual bool KeyPress(int64 ch) = 0;
|
||||
};
|
||||
}
|
@ -10,7 +10,7 @@ namespace cursespp {
|
||||
|
||||
class ILayout : public IWindowGroup, public IKeyHandler, public IOrderable, public IDisplayable {
|
||||
public:
|
||||
virtual ~ILayout() = 0 { }
|
||||
virtual ~ILayout() { }
|
||||
virtual IWindowPtr FocusNext() = 0;
|
||||
virtual IWindowPtr FocusPrev() = 0;
|
||||
virtual IWindowPtr GetFocus() = 0;
|
||||
|
@ -6,7 +6,7 @@
|
||||
namespace cursespp {
|
||||
class ILayoutStack {
|
||||
public:
|
||||
virtual ~ILayoutStack() = 0 { }
|
||||
virtual ~ILayoutStack() { }
|
||||
virtual bool Push(ILayoutPtr layout) = 0;
|
||||
virtual bool Pop(ILayoutPtr layout) = 0;
|
||||
virtual bool BringToTop(ILayoutPtr layout) = 0;
|
||||
|
@ -9,7 +9,7 @@ namespace cursespp {
|
||||
|
||||
class IMessage {
|
||||
public:
|
||||
virtual ~IMessage() = 0 { }
|
||||
virtual ~IMessage() { }
|
||||
virtual IMessageTarget* Target() = 0;
|
||||
virtual int Type() = 0;
|
||||
virtual int64 UserData1() = 0;
|
||||
|
@ -5,6 +5,7 @@
|
||||
namespace cursespp {
|
||||
class IMessageTarget {
|
||||
public:
|
||||
virtual ~IMessageTarget() { }
|
||||
virtual bool IsAcceptingMessages() = 0;
|
||||
virtual void ProcessMessage(IMessage &message) = 0;
|
||||
};
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace cursespp {
|
||||
class IOrderable {
|
||||
public:
|
||||
virtual ~IOrderable() = 0 { }
|
||||
virtual ~IOrderable() { }
|
||||
virtual void BringToTop() = 0;
|
||||
virtual void SendToBottom() = 0;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
namespace cursespp {
|
||||
class IScrollAdapter {
|
||||
public:
|
||||
virtual ~IScrollAdapter() = 0 { }
|
||||
virtual ~IScrollAdapter() { }
|
||||
|
||||
struct ScrollPosition {
|
||||
ScrollPosition() {
|
||||
@ -25,7 +25,7 @@ namespace cursespp {
|
||||
|
||||
class IEntry {
|
||||
public:
|
||||
virtual ~IEntry() = 0 { }
|
||||
virtual ~IEntry() { }
|
||||
virtual size_t GetLineCount() = 0;
|
||||
virtual std::string GetLine(size_t line) = 0;
|
||||
virtual std::string GetValue() = 0;
|
||||
@ -42,4 +42,3 @@ namespace cursespp {
|
||||
virtual void DrawPage(WINDOW* window, size_t index, ScrollPosition *result = NULL) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace cursespp {
|
||||
class IScrollable {
|
||||
public:
|
||||
virtual ~IScrollable() = 0 { }
|
||||
virtual ~IScrollable() { }
|
||||
virtual void ScrollToTop() = 0;
|
||||
virtual void ScrollToBottom() = 0;
|
||||
virtual void ScrollUp(int delta = 1) = 0;
|
||||
|
@ -10,7 +10,7 @@ namespace cursespp {
|
||||
|
||||
class IWindow : public IOrderable, public IDisplayable, public IMessageTarget {
|
||||
public:
|
||||
virtual ~IWindow() = 0 { }
|
||||
virtual ~IWindow() { }
|
||||
virtual void Repaint() = 0;
|
||||
virtual void SetParent(IWindow* parent) = 0;
|
||||
virtual void Show() = 0;
|
||||
|
@ -5,7 +5,7 @@
|
||||
namespace cursespp {
|
||||
class IWindowGroup {
|
||||
public:
|
||||
virtual ~IWindowGroup() = 0 { }
|
||||
virtual ~IWindowGroup() { }
|
||||
virtual bool AddWindow(IWindowPtr window) = 0;
|
||||
virtual bool RemoveWindow(IWindowPtr window) = 0;
|
||||
virtual size_t GetWindowCount() = 0;
|
||||
|
@ -7,7 +7,7 @@ using namespace cursespp;
|
||||
|
||||
template <typename T> static int find(std::vector<T>& haystack, T& needle) {
|
||||
int i = 0;
|
||||
std::vector<T>::iterator it = haystack.begin();
|
||||
typename std::vector<T>::iterator it = haystack.begin();
|
||||
for (; it != haystack.end(); it++, i++) {
|
||||
if ((*it) == needle) {
|
||||
return i;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdafx.h>
|
||||
#include "LayoutStack.h"
|
||||
|
||||
@ -40,19 +38,19 @@ static inline bool erase(std::deque<ILayoutPtr>& group, ILayoutPtr ptr) {
|
||||
}
|
||||
|
||||
bool LayoutStack::AddWindow(IWindowPtr window) {
|
||||
throw std::exception("AddWindow() not supported in LayoutStack. Use Push()");
|
||||
throw std::runtime_error("AddWindow() not supported in LayoutStack. Use Push()");
|
||||
}
|
||||
|
||||
bool LayoutStack::RemoveWindow(IWindowPtr window) {
|
||||
throw std::exception("RemoveWindow() not supported in LayoutStack. Use Push()");
|
||||
throw std::runtime_error("RemoveWindow() not supported in LayoutStack. Use Push()");
|
||||
}
|
||||
|
||||
size_t LayoutStack::GetWindowCount() {
|
||||
throw std::exception("GetWindowCount() not supported in LayoutStack.");
|
||||
throw std::runtime_error("GetWindowCount() not supported in LayoutStack.");
|
||||
}
|
||||
|
||||
IWindowPtr LayoutStack::GetWindowAt(size_t position) {
|
||||
throw std::exception("GetWindowAt() not supported in LayoutStack.");
|
||||
throw std::runtime_error("GetWindowAt() not supported in LayoutStack.");
|
||||
}
|
||||
|
||||
ILayoutStack* LayoutStack::GetLayoutStack() {
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <stdafx.h>
|
||||
#include <algorithm>
|
||||
#include "ListWindow.h"
|
||||
|
||||
using namespace cursespp;
|
||||
@ -24,7 +25,7 @@ void ListWindow::ScrollToTop() {
|
||||
|
||||
void ListWindow::ScrollToBottom() {
|
||||
IScrollAdapter& adapter = this->GetScrollAdapter();
|
||||
this->SetSelectedIndex(max(0, adapter.GetEntryCount() - 1));
|
||||
this->SetSelectedIndex(std::max(0UL, adapter.GetEntryCount() - 1));
|
||||
adapter.DrawPage(this->GetContent(), selectedIndex, &scrollPosition);
|
||||
this->Repaint();
|
||||
}
|
||||
@ -46,13 +47,13 @@ void ListWindow::ScrollUp(int delta) {
|
||||
|
||||
int minIndex = 0;
|
||||
int newIndex = this->selectedIndex - delta;
|
||||
newIndex = max(newIndex, minIndex);
|
||||
newIndex = std::max(newIndex, minIndex);
|
||||
|
||||
if (newIndex < (int) first + 1) {
|
||||
drawIndex = newIndex - 1;
|
||||
}
|
||||
|
||||
drawIndex = max(0, drawIndex);
|
||||
drawIndex = std::max(0, drawIndex);
|
||||
|
||||
this->SetSelectedIndex(newIndex);
|
||||
|
||||
@ -75,7 +76,7 @@ void ListWindow::ScrollDown(int delta) {
|
||||
|
||||
size_t maxIndex = adapter.GetEntryCount() - 1;
|
||||
size_t newIndex = this->selectedIndex + delta;
|
||||
newIndex = min(newIndex, maxIndex);
|
||||
newIndex = std::min(newIndex, maxIndex);
|
||||
|
||||
if (newIndex >= last - 1) {
|
||||
drawIndex = drawIndex + delta;
|
||||
@ -112,7 +113,7 @@ void ListWindow::PageDown() {
|
||||
ScrollPos spos = this->GetScrollPosition();
|
||||
|
||||
size_t lastVisible = spos.firstVisibleEntryIndex + spos.visibleEntryCount - 1;
|
||||
this->SetSelectedIndex(min(adapter.GetEntryCount() - 1, lastVisible + 1));
|
||||
this->SetSelectedIndex(std::min(adapter.GetEntryCount() - 1, lastVisible + 1));
|
||||
|
||||
adapter.DrawPage(this->GetContent(), lastVisible, &this->scrollPosition);
|
||||
this->Repaint();
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <stdafx.h>
|
||||
#include <algorithm>
|
||||
#include "MessageQueue.h"
|
||||
|
||||
using namespace boost::chrono;
|
||||
@ -81,7 +82,7 @@ void MessageQueue::Remove(IMessageTarget *target, int type) {
|
||||
void MessageQueue::Post(IMessagePtr message, int64 delayMs) {
|
||||
boost::recursive_mutex::scoped_lock lock(this->queueMutex);
|
||||
|
||||
delayMs = max(0, delayMs);
|
||||
delayMs = std::max(0LL, delayMs);
|
||||
|
||||
milliseconds now = duration_cast<milliseconds>(
|
||||
system_clock::now().time_since_epoch());
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include <stdafx.h>
|
||||
#include "MultiLineEntry.h"
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include "MultiLineEntry.h"
|
||||
|
||||
using namespace cursespp;
|
||||
|
||||
@ -12,7 +14,7 @@ MultiLineEntry::MultiLineEntry(const std::string& value, int64 attrs) {
|
||||
}
|
||||
|
||||
size_t MultiLineEntry::GetLineCount() {
|
||||
return max(1, this->lines.size());
|
||||
return std::max(1UL, this->lines.size());
|
||||
}
|
||||
|
||||
std::string MultiLineEntry::GetLine(size_t n) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdafx.h>
|
||||
#include "Screen.h"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdafx.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "ScrollableWindow.h"
|
||||
#include "Screen.h"
|
||||
#include "Colors.h"
|
||||
@ -122,7 +122,7 @@ size_t ScrollableWindow::GetPreviousPageEntryIndex() {
|
||||
remaining -= count;
|
||||
}
|
||||
|
||||
return max(0, i);
|
||||
return std::max(0, i);
|
||||
}
|
||||
|
||||
void ScrollableWindow::PageUp() {
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdafx.h>
|
||||
#include "Window.h"
|
||||
#include "IWindowGroup.h"
|
||||
|
@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdafx.h>
|
||||
#include "WindowLayout.h"
|
||||
#include "LayoutStack.h"
|
||||
@ -15,19 +13,19 @@ WindowLayout::~WindowLayout() {
|
||||
}
|
||||
|
||||
bool WindowLayout::AddWindow(IWindowPtr window) {
|
||||
throw std::exception("AddWindow() not supported in LayoutStack. Use Push()");
|
||||
throw std::runtime_error("AddWindow() not supported in LayoutStack. Use Push()");
|
||||
}
|
||||
|
||||
bool WindowLayout::RemoveWindow(IWindowPtr window) {
|
||||
throw std::exception("RemoveWindow() not supported in LayoutStack. Use Push()");
|
||||
throw std::runtime_error("RemoveWindow() not supported in LayoutStack. Use Push()");
|
||||
}
|
||||
|
||||
size_t WindowLayout::GetWindowCount() {
|
||||
throw std::exception("GetWindowCount() not supported in LayoutStack.");
|
||||
throw std::runtime_error("GetWindowCount() not supported in LayoutStack.");
|
||||
}
|
||||
|
||||
IWindowPtr WindowLayout::GetWindowAt(size_t position) {
|
||||
throw std::exception("GetWindowAt() not supported in LayoutStack.");
|
||||
throw std::runtime_error("GetWindowAt() not supported in LayoutStack.");
|
||||
}
|
||||
|
||||
void WindowLayout::Show() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user