From a8177a33d7d79bbb782b177089ef935b4dfe2f11 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 29 Mar 2016 21:50:18 -0400 Subject: [PATCH] Composite: Added stubbed class --- src/CMakeLists.txt | 3 +- src/Composite.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++ src/Composite.h | 46 +++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 src/Composite.cpp create mode 100644 src/Composite.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f3da275c..bbbbbc0d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,8 @@ include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src/libshared/src ${TIMEW_INCLUDE_DIRS}) -set (timew_SRCS Database.cpp Database.h +set (timew_SRCS Composite.cpp Composite.h + Database.cpp Database.h Datafile.cpp Datafile.h Exclusion.cpp Exclusion.h Extensions.cpp Extensions.h diff --git a/src/Composite.cpp b/src/Composite.cpp new file mode 100644 index 00000000..f5492351 --- /dev/null +++ b/src/Composite.cpp @@ -0,0 +1,69 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// http://www.opensource.org/licenses/mit-license.php +// +//////////////////////////////////////////////////////////////////////////////// + +#include +#include + +//////////////////////////////////////////////////////////////////////////////// +// Initially assume no text, but infinite virtual space. +// +// Ã…llow overlay placement of arbitrary text at any offset, real or virtual, and +// using a specific color. The color is blended with any underlying color. +// +// Collapse all the strings down to a single string, with the most efficient +// color directives inline. +// +// For example: +// Composite c; +// c.add ("first", 2, Color ("red")); +// c.add ("second", 5, Color ("underline")); +// +// Result: +// " firsecond" +// rrrrr +// uuuuuu +// +// The first part "fir" will be red. +// The second part "se" will be red and underlined. +// The third part "cond" will be underlined. +// +void Composite::add ( + const std::string& text, + std::string::size_type offset, + const Color& color) +{ + _layers.push_back (std::make_tuple (text, offset, color)); +} + +//////////////////////////////////////////////////////////////////////////////// +// overlay == true means there is no color blending. +// overlay == false means there is color blending. +std::string Composite::str (bool overlay) +{ + return ""; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Composite.h b/src/Composite.h new file mode 100644 index 00000000..620b170a --- /dev/null +++ b/src/Composite.h @@ -0,0 +1,46 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// http://www.opensource.org/licenses/mit-license.php +// +//////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDED_COMPOSITE +#define INCLUDED_COMPOSITE + +#include +#include +#include +#include + +class Composite +{ +public: + Composite () = default; + void add (const std::string&, std::string::size_type, const Color&); + std::string str (bool overlay = true); + +private: + std::vector > _layers; +}; + +#endif