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
|
/************************************************************************
*
* Copyright (C) 2009-2024 IRCAD France
* Copyright (C) 2012-2020 IHU Strasbourg
*
* 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/__/container/toolbar.hpp"
#include "ui/__/container/widget.hpp"
#include "ui/__/object.hpp"
namespace sight::ui::builder
{
/**
* @brief Defines the interface class for the toolbar builder.
*/
class SIGHT_UI_CLASS_API toolbar : public ui::object
{
public:
SIGHT_DECLARE_CLASS(toolbar, ui::object);
using registry_key_t = std::string;
SIGHT_UI_API const static registry_key_t REGISTRY_KEY;
enum alignment
{
top,
bottom,
right,
left
};
/// Constructor. Do nothing.
SIGHT_UI_API toolbar();
/// Destructor. Do nothing.
SIGHT_UI_API ~toolbar() override = default;
/**
* @brief Returns the builded tool bar.
*/
SIGHT_UI_API virtual ui::container::toolbar::sptr get_tool_bar();
/**
* @brief Initialize the tool bar.
*
* Example of configuration
* @code{.xml}
<toolbar align="top" backgroundColor="default" spacing="10">
<toolBitmapSize height= "50" width="50" />
</toolbar>
@endcode
- \b align : toolbar alignment (top, bottom, left, right).
- \b backgroundColor (optional) : (hexa) background color.
- \b spacing (optional) : (int) spacing between each button, in pixels.
* - \<toolBitmapSize height= "50" width="50"/\> : give the size of the icon.
*/
SIGHT_UI_API virtual void initialize(const ui::config_t& _configuration);
/**
* @brief Instantiate layout with parent toolbar.
* @pre layout must be initialized before.
* @pre parent toolbar must be instanced.
*/
SIGHT_UI_API virtual void create_tool_bar(ui::container::widget::sptr _parent) = 0;
/**
* @brief Destroy local layout with sub containers.
* @pre services using this sub containers must be stopped before.
*/
SIGHT_UI_API virtual void destroy_tool_bar() = 0;
protected:
/// tool_bar.
ui::container::toolbar::sptr m_tool_bar;
std::pair<int, int> m_tool_bitmap_size;
int m_spacing {0};
alignment m_alignment {top};
/// Background color. Use an empty string to use the default background color, else, set an hexadecimal value.
std::string m_background_color;
/// Defines a qss key to apply style
std::string m_qss_class;
};
} // namespace sight::ui::builder
|