From d1f5d92a7bab73d8fd0617d50bbfb7743e2f6565 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Sun, 3 Aug 2014 16:39:26 +0200 Subject: [PATCH] Move canvas::AlignmentFlag to separate file. Mapping in a separate file allows easier exposing of values and string representation to Nasal. --- simgear/canvas/layout/AlignFlag_values.hxx | 43 ++++++++++++++++++++++ simgear/canvas/layout/CMakeLists.txt | 1 + simgear/canvas/layout/LayoutItem.hxx | 22 ++--------- 3 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 simgear/canvas/layout/AlignFlag_values.hxx 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 }; /** -- 2.39.5