Composite: Added stubbed class

This commit is contained in:
Paul Beckingham 2016-03-29 21:50:18 -04:00
parent 640b4abeef
commit a8177a33d7
3 changed files with 117 additions and 1 deletions

View file

@ -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

69
src/Composite.cpp Normal file
View file

@ -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 <cmake.h>
#include <Composite.h>
////////////////////////////////////////////////////////////////////////////////
// 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 "";
}
////////////////////////////////////////////////////////////////////////////////

46
src/Composite.h Normal file
View file

@ -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 <Color.h>
#include <vector>
#include <string>
#include <tuple>
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 <std::tuple <std::string, std::string::size_type, Color>> _layers;
};
#endif