Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
scroll-utils.cpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
/* Authors:
3
* Thomas Holder
4
*
5
* Copyright (C) 2020 authors
6
*
7
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
8
*/
9
10
#include "
scroll-utils.h
"
11
#include <gtkmm/scrolledwindow.h>
12
#include "
ui/util.h
"
13
14
namespace
Inkscape::UI::Widget
{
15
19
Gtk::Widget *
get_scrollable_ancestor
(Gtk::Widget *widget)
20
{
21
g_return_val_if_fail(widget,
nullptr
);
22
23
return
for_each_parent
(*widget, [](Gtk::Widget &
parent
)
24
{
25
auto
const
scrollable =
dynamic_cast<
Gtk::ScrolledWindow *
>
(&
parent
);
26
return
scrollable ?
ForEachResult::_break
:
ForEachResult::_continue
;
27
});
28
}
29
33
Gtk::Widget
const
*
get_scrollable_ancestor
(Gtk::Widget
const
*
const
widget)
34
{
35
g_return_val_if_fail(widget,
nullptr
);
36
37
auto
const
mut_widget =
const_cast<
Gtk::Widget *
>
(widget);
38
auto
const
mut_ancestor =
get_scrollable_ancestor
(mut_widget);
39
return
const_cast<
Gtk::Widget
const
*
>
(mut_ancestor);
40
}
41
42
}
// namespace Inkscape::UI::Widget
43
44
/*
45
Local Variables:
46
mode:c++
47
c-file-style:"stroustrup"
48
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
49
indent-tabs-mode:nil
50
fill-column:99
51
End:
52
*/
53
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
parent
static char const *const parent
Definition
dir-util.cpp:70
Inkscape::UI::Widget
Custom widgets.
Definition
desktop.h:126
Inkscape::UI::Widget::get_scrollable_ancestor
Gtk::Widget * get_scrollable_ancestor(Gtk::Widget *widget)
Get the first ancestor which is scrollable.
Definition
scroll-utils.cpp:19
Inkscape::UI::for_each_parent
Gtk::Widget * for_each_parent(Gtk::Widget &widget, Func &&func)
Call Func with a reference to successive parents, until Func returns _break.
Definition
util.h:126
Inkscape::UI::ForEachResult::_break
@ _break
Inkscape::UI::ForEachResult::_continue
@ _continue
scroll-utils.h
util.h
src
ui
widget
scroll-utils.cpp
Generated on Sun Jul 13 2025 04:02:23 for Inkscape by
1.9.8