/usr/include/simgear/canvas/layout/Layout.hxx is in libsimgear-dev 3.4.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | /// @file
//
// Copyright (C) 2014 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef SG_CANVAS_LAYOUT_HXX_
#define SG_CANVAS_LAYOUT_HXX_
#include "LayoutItem.hxx"
#include <vector>
namespace simgear
{
namespace canvas
{
/**
* Base class for all Canvas layouts.
*/
class Layout:
public LayoutItem
{
public:
virtual void addItem(const LayoutItemRef& item) = 0;
virtual void setSpacing(int spacing) = 0;
virtual int spacing() const = 0;
/**
* Get the number of items.
*/
virtual size_t count() const = 0;
/**
* Get the item at position @a index.
*
* If there is no such item the function must do nothing and return an
* empty reference.
*/
virtual LayoutItemRef itemAt(size_t index) = 0;
/**
* Remove and get the item at position @a index.
*
* If there is no such item the function must do nothing and return an
* empty reference.
*/
virtual LayoutItemRef takeAt(size_t index) = 0;
/**
* Remove the given @a item from the layout.
*/
void removeItem(const LayoutItemRef& item);
/**
* Remove all items.
*/
virtual void clear();
/**
* Get the actual geometry of this layout given the rectangle \a geom
* taking into account the alignment flags and size hints. For layouts,
* if no alignment (different to AlignFill) is set, the whole area is
* used. Excess space is distributed by the layouting algorithm and
* handled by the individual children.
*
* @param geom Area available to this layout.
* @return The resulting geometry for this layout.
*/
virtual SGRecti alignmentRect(const SGRecti& geom) const;
protected:
enum LayoutFlags
{
LAST_FLAG = LayoutItem::LAST_FLAG
};
struct ItemData
{
LayoutItemRef layout_item;
int size_hint,
min_size,
max_size,
padding_orig, //!< original padding as specified by the user
padding, //!< padding before element (layouted)
size, //!< layouted size
stretch; //!< stretch factor
bool visible : 1,
has_align: 1, //!< Has alignment factor set (!= AlignFill)
has_hfw : 1, //!< height for width
done : 1; //!< layouting done
/** Clear values (reset to default/empty state) */
void reset();
int hfw(int w) const;
int mhfw(int w) const;
};
Layout();
virtual void contentsRectChanged(const SGRecti& rect);
/**
* Override to implement the actual layouting
*/
virtual void doLayout(const SGRecti& geom) = 0;
/**
* Distribute the available @a space to all @a items
*/
void distribute(std::vector<ItemData>& items, const ItemData& space);
private:
int _num_not_done, //!< number of children not layouted yet
_sum_stretch, //!< sum of stretch factors of all not yet layouted
// children
_space_stretch,//!< space currently assigned to all not yet layouted
// stretchable children
_space_left; //!< remaining space not used by any child yet
};
typedef SGSharedPtr<Layout> LayoutRef;
} // namespace canvas
} // namespace simgear
#endif /* SG_CANVAS_LAYOUT_HXX_ */
|