splitter_handle.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 #ifndef SPLITTER_HANDLE_H
30 #define SPLITTER_HANDLE_H
31 
32 #include <QWidget>
33 #include <utility>
34 
35 
36 class QTreeView;
37 
38 namespace rviz
39 {
44 class SplitterHandle : public QWidget
45 {
46  Q_OBJECT
47 public:
48  SplitterHandle(QTreeView* parent = nullptr);
49 
51  void setRatio(float ratio);
52 
54  float getRatio();
55 
57  void setDesiredWidth(int width);
58 
61  bool eventFilter(QObject* event_target, QEvent* event) override;
62 
63  void setColor(QColor color)
64  {
65  color_ = std::move(color);
66  update();
67  }
68  QColor getColor() const
69  {
70  return color_;
71  }
72 
73 protected:
74  void mousePressEvent(QMouseEvent* event) override;
75  void mouseMoveEvent(QMouseEvent* event) override;
76  void mouseDoubleClickEvent(QMouseEvent* event) override;
77  void paintEvent(QPaintEvent* event) override;
78 
79 private:
82  void updateGeometry();
83 
84  QTreeView* parent_;
86 
90  QColor color_;
91 };
92 
93 } // end namespace rviz
94 
95 #endif // SPLITTER_HANDLE_H
rviz::SplitterHandle::getColor
QColor getColor() const
Definition: splitter_handle.h:68
rviz::SplitterHandle::updateGeometry
void updateGeometry()
Update the parent's column widths and this splitter's geometry based on first_column_size_ratio_.
Definition: splitter_handle.cpp:60
rviz::SplitterHandle::setDesiredWidth
void setDesiredWidth(int width)
Set desired width of first column - subject to clamping.
Definition: splitter_handle.cpp:108
rviz::SplitterHandle::setRatio
void setRatio(float ratio)
Set the ratio of the parent's left column to the parent widget width.
Definition: splitter_handle.cpp:97
rviz::SplitterHandle::first_column_size_ratio_
float first_column_size_ratio_
Definition: splitter_handle.h:89
rviz::SplitterHandle::color_
QColor color_
Definition: splitter_handle.h:90
rviz::SplitterHandle::SplitterHandle
SplitterHandle(QTreeView *parent=nullptr)
Definition: splitter_handle.cpp:42
rviz::SplitterHandle::x_press_offset_
int x_press_offset_
Definition: splitter_handle.h:85
update
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
rviz::SplitterHandle::mouseDoubleClickEvent
void mouseDoubleClickEvent(QMouseEvent *event) override
Definition: splitter_handle.cpp:133
rviz
Definition: add_display_dialog.cpp:54
rviz::SplitterHandle
A tall skinny invisible widget providing left-right sliding column separator adjustment for a two-col...
Definition: splitter_handle.h:44
rviz::SplitterHandle::getRatio
float getRatio()
Get the ratio of the parent's left column to the parent widget width.
Definition: splitter_handle.cpp:103
rviz::SplitterHandle::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override
Definition: splitter_handle.cpp:123
rviz::SplitterHandle::paintEvent
void paintEvent(QPaintEvent *event) override
Definition: splitter_handle.cpp:149
rviz::SplitterHandle::parent_
QTreeView * parent_
Definition: splitter_handle.h:84
rviz::SplitterHandle::setColor
void setColor(QColor color)
Definition: splitter_handle.h:63
rviz::SplitterHandle::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition: splitter_handle.cpp:114
rviz::SplitterHandle::eventFilter
bool eventFilter(QObject *event_target, QEvent *event) override
Catch resize events sent to parent to update splitter's geometry. Always returns false.
Definition: splitter_handle.cpp:51


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Sat Jun 1 2024 02:31:53