Removed old, unused LayoutStack stuff.

This commit is contained in:
Casey Langen 2016-09-02 10:00:57 -07:00
parent b320cc837d
commit 77f3293dd7
11 changed files with 7 additions and 413 deletions

View File

@ -32,7 +32,6 @@ set (BOX_SRCS
./cursespp/Colors.cpp
./cursespp/DialogOverlay.cpp
./cursespp/LayoutBase.cpp
./cursespp/LayoutStack.cpp
./cursespp/ListWindow.cpp
./cursespp/Message.cpp
./cursespp/MessageQueue.cpp

View File

@ -35,7 +35,6 @@
#pragma once
#include <cursespp/LayoutBase.h>
#include <cursespp/LayoutStack.h>
#include <cursespp/ShortcutsWindow.h>
#include <app/layout/BrowseLayout.h>

View File

@ -40,8 +40,6 @@
#include <memory>
namespace cursespp {
class ILayoutStack;
class ILayout : public IWindowGroup, public IKeyHandler, public IOrderable, public IDisplayable {
public:
virtual ~ILayout() { }
@ -49,8 +47,6 @@ namespace cursespp {
virtual IWindowPtr FocusPrev() = 0;
virtual IWindowPtr GetFocus() = 0;
virtual bool SetFocus(IWindowPtr window) = 0;
virtual ILayoutStack* GetLayoutStack() = 0;
virtual void SetLayoutStack(ILayoutStack* stack) = 0;
virtual void Layout() = 0;
};

View File

@ -1,50 +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 <stdafx.h>
#include "ILayout.h"
namespace cursespp {
class ILayoutStack {
public:
virtual ~ILayoutStack() { }
virtual bool Push(ILayoutPtr layout) = 0;
virtual bool Pop(ILayoutPtr layout) = 0;
virtual bool BringToTop(ILayoutPtr layout) = 0;
virtual bool SendToBottom(ILayoutPtr layout) = 0;
virtual ILayoutPtr Top() = 0;
};
}

View File

@ -34,7 +34,6 @@
#include <stdafx.h>
#include "LayoutBase.h"
#include "LayoutStack.h"
#include "Colors.h"
using namespace cursespp;
@ -79,7 +78,6 @@ static inline IWindowPtr adjustFocus(IWindowPtr oldFocus, IWindowPtr newFocus) {
LayoutBase::LayoutBase(IWindow* parent)
: Window(parent) {
this->focused = -1;
this->layoutStack = 0;
this->SetFrameVisible(false);
}
@ -280,12 +278,4 @@ bool LayoutBase::KeyPress(const std::string& key) {
}
return false;
}
ILayoutStack* LayoutBase::GetLayoutStack() {
return this->layoutStack;
}
void LayoutBase::SetLayoutStack(ILayoutStack* stack) {
this->layoutStack = stack;
}
}

View File

@ -35,7 +35,6 @@
#pragma once
#include "ILayout.h"
#include "ILayoutStack.h"
#include "Window.h"
#include <vector>
@ -66,8 +65,6 @@ namespace cursespp {
virtual IWindowPtr FocusPrev();
virtual IWindowPtr GetFocus();
virtual bool SetFocus(IWindowPtr window);
virtual ILayoutStack* GetLayoutStack();
virtual void SetLayoutStack(ILayoutStack* stack);
virtual void Layout() = 0;
@ -86,7 +83,6 @@ namespace cursespp {
void SortFocusables();
void IndexFocusables();
ILayoutStack* layoutStack;
std::vector<IWindowPtr> children;
std::vector<IWindowPtr> focusable;
int focused;

View File

@ -1,231 +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 "LayoutStack.h"
using namespace cursespp;
LayoutStack::LayoutStack() {
this->visible = false;
this->stack = 0;
}
LayoutStack::~LayoutStack() {
}
static inline bool contains(const std::deque<ILayoutPtr>& group, ILayoutPtr ptr) {
for (size_t i = 0; i < group.size(); i++) {
if (group.at(i) == ptr) {
return true;
}
}
return false;
}
static inline bool erase(std::deque<ILayoutPtr>& group, ILayoutPtr ptr) {
std::deque<ILayoutPtr>::iterator it = group.begin();
while (it != group.end()) {
if (*it == ptr) {
group.erase(it);
return true;
}
else {
++it;
}
}
return false;
}
bool LayoutStack::AddWindow(IWindowPtr window) {
throw std::runtime_error("AddWindow() not supported in LayoutStack. Use Push()");
}
bool LayoutStack::RemoveWindow(IWindowPtr window) {
throw std::runtime_error("RemoveWindow() not supported in LayoutStack. Use Push()");
}
size_t LayoutStack::GetWindowCount() {
throw std::runtime_error("GetWindowCount() not supported in LayoutStack.");
}
IWindowPtr LayoutStack::GetWindowAt(size_t position) {
throw std::runtime_error("GetWindowAt() not supported in LayoutStack.");
}
ILayoutStack* LayoutStack::GetLayoutStack() {
return this->stack;
}
void LayoutStack::SetLayoutStack(ILayoutStack* stack) {
this->stack = stack;
}
void LayoutStack::Show() {
if (!this->visible) {
std::deque<ILayoutPtr>::iterator it = this->layouts.begin();
while (it != this->layouts.end()) {
(*it)->Show();
++it;
}
this->visible = true;
}
this->BringToTop();
}
void LayoutStack::Hide() {
if (this->visible) {
std::deque<ILayoutPtr>::iterator it = this->layouts.begin();
while (it != this->layouts.end()) {
(*it)->Hide();
++it;
}
this->visible = false;
}
}
bool LayoutStack::KeyPress(const std::string& key) {
if (!this->layouts.size()) {
return false;
}
return this->layouts.front()->KeyPress(key);
}
IWindowPtr LayoutStack::FocusNext() {
if (!this->layouts.size()) {
return IWindowPtr();
}
return this->layouts.front()->FocusNext();
}
ILayoutPtr LayoutStack::Top() {
if (this->layouts.size()) {
return this->layouts.front();
}
return ILayoutPtr();
}
IWindowPtr LayoutStack::FocusPrev() {
if (!this->layouts.size()) {
return IWindowPtr();
}
return this->layouts.front()->FocusPrev();
}
IWindowPtr LayoutStack::GetFocus() {
if (!this->layouts.size()) {
return IWindowPtr();
}
return this->layouts.front()->GetFocus();
}
bool LayoutStack::Push(ILayoutPtr layout) {
ILayoutStack* oldStack = layout->GetLayoutStack();
if (oldStack && oldStack != this) {
oldStack->Pop(layout);
}
layout->SetLayoutStack(this);
if (!contains(this->layouts, layout)) {
this->layouts.push_front(layout);
}
this->BringToTop();
return true;
}
bool LayoutStack::Pop(ILayoutPtr layout) {
bool erased = erase(this->layouts, layout);
if (erased) {
layout->Hide();
this->BringToTop();
return true;
}
return false;
}
void LayoutStack::BringToTop() {
std::deque<ILayoutPtr>::reverse_iterator it = this->layouts.rbegin();
while (it != this->layouts.rend()) {
(*it)->BringToTop();
++it;
}
}
void LayoutStack::SendToBottom() {
std::deque<ILayoutPtr>::reverse_iterator it = this->layouts.rbegin();
while (it != this->layouts.rend()) {
(*it)->SendToBottom();
++it;
}
}
bool LayoutStack::BringToTop(ILayoutPtr layout) {
if (this->layouts.front() != layout) {
if (!erase(this->layouts, layout)) {
return false;
}
}
this->layouts.push_front(layout);
this->BringToTop();
return true;
}
bool LayoutStack::SendToBottom(ILayoutPtr layout) {
if (this->layouts.back() != layout) {
if (!erase(this->layouts, layout)) {
return false;
}
}
this->layouts.push_back(layout);
this->SendToBottom();
return true;
}

View File

@ -1,86 +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 "ILayout.h"
#include "ILayoutStack.h"
#include "LayoutBase.h"
#include <memory>
namespace cursespp {
class LayoutStack : public LayoutBase, public ILayoutStack {
public:
LayoutStack();
virtual ~LayoutStack();
/* ILayout */
virtual IWindowPtr FocusNext();
virtual IWindowPtr FocusPrev();
virtual IWindowPtr GetFocus();
virtual ILayoutStack* GetLayoutStack();
virtual void SetLayoutStack(ILayoutStack* stack);
virtual void Layout() { }
/* IOrderable */
virtual void BringToTop();
virtual void SendToBottom();
/* IDisplayable */
virtual void Show();
virtual void Hide();
/* IKeyHandler */
virtual bool KeyPress(const std::string& key);
/* IWindowGroup */
virtual bool AddWindow(IWindowPtr window);
virtual bool RemoveWindow(IWindowPtr window);
virtual size_t GetWindowCount();
virtual IWindowPtr GetWindowAt(size_t position);
/* ILayoutStack */
virtual bool Push(ILayoutPtr layout);
virtual bool Pop(ILayoutPtr layout);
virtual bool BringToTop(ILayoutPtr layout);
virtual bool SendToBottom(ILayoutPtr layout);
virtual ILayoutPtr Top();
private:
std::deque<ILayoutPtr> layouts;
ILayoutStack* stack;
bool visible;
};
}

View File

@ -34,32 +34,30 @@
#include <stdafx.h>
#include "WindowLayout.h"
#include "LayoutStack.h"
using namespace cursespp;
WindowLayout::WindowLayout(IWindowPtr window) {
this->window = window;
this->stack = 0;
}
WindowLayout::~WindowLayout() {
}
bool WindowLayout::AddWindow(IWindowPtr window) {
throw std::runtime_error("AddWindow() not supported in LayoutStack. Use Push()");
throw std::runtime_error("AddWindow() not supported in WindowLayout. Use Push()");
}
bool WindowLayout::RemoveWindow(IWindowPtr window) {
throw std::runtime_error("RemoveWindow() not supported in LayoutStack. Use Push()");
throw std::runtime_error("RemoveWindow() not supported in WindowLayout. Use Push()");
}
size_t WindowLayout::GetWindowCount() {
throw std::runtime_error("GetWindowCount() not supported in LayoutStack.");
throw std::runtime_error("GetWindowCount() not supported in WindowLayout.");
}
IWindowPtr WindowLayout::GetWindowAt(size_t position) {
throw std::runtime_error("GetWindowAt() not supported in LayoutStack.");
throw std::runtime_error("GetWindowAt() not supported in WindowLayout.");
}
void WindowLayout::Show() {
@ -71,9 +69,6 @@ void WindowLayout::Hide() {
}
bool WindowLayout::KeyPress(int64 ch) {
if (ch == 27 && this->GetLayoutStack()) {
this->GetLayoutStack()->Pop(shared_from_this());
}
return false;
}
@ -95,12 +90,4 @@ void WindowLayout::BringToTop() {
void WindowLayout::SendToBottom() {
this->window->SendToBottom();
}
ILayoutStack* WindowLayout::GetLayoutStack() {
return this->stack;
}
void WindowLayout::SetLayoutStack(ILayoutStack* stack) {
this->stack = stack;
}
}

View File

@ -46,8 +46,6 @@ namespace cursespp {
virtual IWindowPtr FocusNext();
virtual IWindowPtr FocusPrev();
virtual IWindowPtr GetFocus();
virtual ILayoutStack* GetLayoutStack();
virtual void SetLayoutStack(ILayoutStack* stack);
virtual void Layout() { }
/* IOrderable */
@ -68,7 +66,6 @@ namespace cursespp {
virtual IWindowPtr GetWindowAt(size_t position);
private:
ILayoutStack* stack;
IWindowPtr window;
};
}

View File

@ -146,7 +146,6 @@
<ClCompile Include="cursespp\Colors.cpp" />
<ClCompile Include="cursespp\DialogOverlay.cpp" />
<ClCompile Include="cursespp\LayoutBase.cpp" />
<ClCompile Include="cursespp\LayoutStack.cpp" />
<ClCompile Include="cursespp\ListWindow.cpp" />
<ClCompile Include="cursespp\MultiLineEntry.cpp" />
<ClCompile Include="cursespp\Overlays.cpp" />
@ -207,11 +206,9 @@
<ClInclude Include="cursespp\IInput.h" />
<ClInclude Include="cursespp\IKeyHandler.h" />
<ClInclude Include="cursespp\ILayout.h" />
<ClInclude Include="cursespp\ILayoutStack.h" />
<ClInclude Include="cursespp\IMessageTarget.h" />
<ClInclude Include="cursespp\IOrderable.h" />
<ClInclude Include="cursespp\IOverlay.h" />
<ClInclude Include="cursespp\LayoutStack.h" />
<ClInclude Include="cursespp\IScrollable.h" />
<ClInclude Include="cursespp\IScrollAdapter.h" />
<ClInclude Include="cursespp\IWindow.h" />
@ -250,4 +247,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>