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
|
/************************************************************************
*
* Copyright (C) 2023-2025 IRCAD France
*
* This file is part of Sight.
*
* Sight is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Sight 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Sight. If not, see <https://www.gnu.org/licenses/>.
*
***********************************************************************/
#pragma once
#include <sight/ui/__/config.hpp>
#include "ui/__/layout/view.hpp"
namespace sight::ui::layout
{
/**
* @brief Defines the base for line layout manager.
*/
class SIGHT_UI_CLASS_API overlay : public view
{
public:
SIGHT_DECLARE_CLASS(overlay, ui::layout::view);
struct view
{
struct coord
{
bool relative = false;
bool negative = false;
int value = 0;
};
coord x;
coord y;
coord width;
coord height;
int min_width {0};
int min_height {0};
bool visible {true};
float opacity {0.0};
};
/**
* @brief Initialize Overlay layout manager before the creation of layout.
*
* Example of configuration with overlay layout.
* @code{.xml}
<service uid="mainView" type="sight::module::ui::view">
<gui>
<layout type="sight::ui::layout::overlay">
<view />
<view x="0" y="0" minWidth="55" minHeight="100" />
<view x="-1" y="0" width="50" height="55" visible="false" />
<view x="0" y="-1" height="35" width="100%" visible="false" />
<view x="-50%" y="0" width="400" height="300" />
</layout>
</gui>
<registry>
<parent wid="${WID_PARENT}" />
<view sid="scenesView" />
<view sid="topToolbarSliderView" />
<view sid="rightToolbarSliderView" />
<view sid="videoSliderView" />
<view sid="advancedQueryEditorSliderView" />
</registry>
</service>
@endcode
* - \<layout type="ui::layout::overlay" \> : define a overlay layout.
* - \<view /\> : define a new view. The first view is the background widget and the other ones are the overlays.
The overlay views can have the following attributes:
* - \b x : The horizontal offset of the widget. If positive, from left; if negative, from right
* - \b y : The vertical offset of the widget. If positive, from top; if negative, from bottom
* - \b width : The fixed weight of the widget
* - \b height : The fixed height of the widget
* - \b minWidth : The minimum width of the widget
* - \b minHeight : The minimum height of the widget
* - \b visible : Whether the widget should be shown on application start (default: true)
*/
SIGHT_UI_API void initialize(const ui::config_t& _configuration) override;
static inline std::string s_registry_key = "sight::ui::layout::overlay";
protected:
//------------------------------------------------------------------------------
const std::vector<view>& views() const
{
return m_views;
}
private:
/// Save layout configuration definition
std::vector<view> m_views;
};
} // namespace sight::ui::layout
|