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
|
/************************************************************************
*
* Copyright (C) 2016-2023 IRCAD France
* Copyright (C) 2016-2021 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/>.
*
***********************************************************************/
#include "ui/qt/builder/slideview.hpp"
#include "ui/qt/container/widget.hpp"
#include <ui/__/macros.hpp>
#include <ui/qt/widget/slide_bar.hpp>
#include <QWidget>
SIGHT_REGISTER_GUI(sight::ui::qt::builder::slideview, sight::ui::builder::slideview::REGISTRY_KEY)
namespace sight::ui::qt::builder
{
//-----------------------------------------------------------------------------
void slideview::create_container(ui::container::widget::sptr _parent)
{
m_parent = std::dynamic_pointer_cast<ui::qt::container::widget>(_parent);
SIGHT_ASSERT("The parent container is not a widget", m_parent);
QWidget* qt_parent = m_parent->get_qt_container();
ui::qt::widget::slide_bar::h_alignment h_align = ui::qt::widget::slide_bar::left;
ui::qt::widget::slide_bar::v_alignment v_align = ui::qt::widget::slide_bar::top;
ui::qt::widget::slide_bar::animatable_alignment anim_align = ui::qt::widget::slide_bar::top_animation;
switch(m_h_alignment)
{
case slideview::left:
h_align = ui::qt::widget::slide_bar::left;
break;
case slideview::right:
h_align = ui::qt::widget::slide_bar::right;
break;
}
switch(m_v_alignment)
{
case slideview::top:
v_align = ui::qt::widget::slide_bar::top;
break;
case slideview::bottom:
v_align = ui::qt::widget::slide_bar::bottom;
break;
}
switch(m_animatable_alignment)
{
case slideview::top_animation:
anim_align = ui::qt::widget::slide_bar::top_animation;
break;
case slideview::bottom_animation:
anim_align = ui::qt::widget::slide_bar::bottom_animation;
break;
case slideview::left_animation:
anim_align = ui::qt::widget::slide_bar::left_animation;
break;
case slideview::right_animation:
anim_align = ui::qt::widget::slide_bar::right_animation;
break;
}
auto* slide_bar =
new ui::qt::widget::slide_bar(
qt_parent,
h_align,
v_align,
m_width,
m_percent_width,
m_height,
m_percent_height,
m_h_offset,
m_percent_h_offset,
m_v_offset,
m_percent_v_offset,
m_opacity,
m_animatable,
anim_align
);
if(!m_style_sheet.empty())
{
slide_bar->setStyleSheet(QString::fromStdString(m_style_sheet));
}
ui::qt::container::widget::sptr qt_container = ui::qt::container::widget::make();
qt_container->set_qt_container(slide_bar);
m_container = qt_container;
}
//-----------------------------------------------------------------------------
void slideview::destroy_container()
{
SIGHT_ASSERT("The Container is not initialized", m_container);
m_container->destroy_container();
}
//-----------------------------------------------------------------------------
} // namespace sight::ui::qt::builder
|