From: Thomas Geymayer Date: Sun, 3 Aug 2014 14:39:26 +0000 (+0200) Subject: Move canvas::AlignmentFlag to separate file. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d1f5d92a7bab73d8fd0617d50bbfb7743e2f6565;p=simgear.git Move canvas::AlignmentFlag to separate file. Mapping in a separate file allows easier exposing of values and string representation to Nasal. --- diff --git a/simgear/canvas/layout/AlignFlag_values.hxx b/simgear/canvas/layout/AlignFlag_values.hxx new file mode 100644 index 00000000..b5184cc8 --- /dev/null +++ b/simgear/canvas/layout/AlignFlag_values.hxx @@ -0,0 +1,43 @@ +///@file +/// Enumeration of layout alignment flags. +// +// Copyright (C) 2014 Thomas Geymayer +// +// 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 ALIGN_ENUM_MAPPING +# error "Only include with ALIGN_ENUM_MAPPING defined!" +#endif + +ALIGN_ENUM_MAPPING(AlignFill, 0, Use all available space) + +ALIGN_ENUM_MAPPING(AlignLeft, 0x01, Align with left edge) +ALIGN_ENUM_MAPPING(AlignRight, 0x02, Align with right edge) +ALIGN_ENUM_MAPPING(AlignHCenter, 0x04, Center horizontally in available space) + +ALIGN_ENUM_MAPPING(AlignTop, 0x20, Align with top edge) +ALIGN_ENUM_MAPPING(AlignBottom, 0x40, Align with bottom edge) +ALIGN_ENUM_MAPPING(AlignVCenter, 0x80, Center vertically in available space) + +ALIGN_ENUM_MAPPING( AlignCenter, + AlignVCenter | AlignHCenter, + Center both vertically and horizontally ) + +ALIGN_ENUM_MAPPING( AlignHorizontal_Mask, + AlignLeft | AlignRight | AlignHCenter, + Mask of all horizontal alignment flags ) +ALIGN_ENUM_MAPPING( AlignVertical_Mask, + AlignTop | AlignBottom | AlignVCenter, + Mask of all vertical alignment flags ) diff --git a/simgear/canvas/layout/CMakeLists.txt b/simgear/canvas/layout/CMakeLists.txt index f15cc4a8..ff7c900b 100644 --- a/simgear/canvas/layout/CMakeLists.txt +++ b/simgear/canvas/layout/CMakeLists.txt @@ -1,6 +1,7 @@ include (SimGearComponent) set(HEADERS + AlignFlag_values.hxx BoxLayout.hxx Layout.hxx LayoutItem.hxx diff --git a/simgear/canvas/layout/LayoutItem.hxx b/simgear/canvas/layout/LayoutItem.hxx index 2807daa6..885bc564 100644 --- a/simgear/canvas/layout/LayoutItem.hxx +++ b/simgear/canvas/layout/LayoutItem.hxx @@ -89,25 +89,9 @@ namespace canvas */ enum AlignmentFlag { - AlignFill = 0, //!< Use all available space - - AlignLeft = 0x01, //!< Align with left edge - AlignRight = 0x02, //!< Align with right edge - AlignHCenter = 0x04, //!< Center horizontally in available space - - AlignTop = 0x20, //!< Align with top edge - AlignBottom = 0x40, //!< Align with bottom edge - AlignVCenter = 0x80, //!< Center vertically in available space - - AlignCenter = AlignVCenter //!< Center both vertically and horizontally - | AlignHCenter, - - AlignHorizontal_Mask = AlignLeft - | AlignRight - | AlignHCenter, - AlignVertical_Mask = AlignTop - | AlignBottom - | AlignVCenter +#define ALIGN_ENUM_MAPPING(key, val, comment) key = val, /*!< comment */ +# include "AlignFlag_values.hxx" +#undef ALIGN_ENUM_MAPPING }; /**