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
14namespace Inkscape::UI::Widget {
15
19Gtk::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);
27 });
28}
29
33Gtk::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 :
static char const *const parent
Definition dir-util.cpp:70
Custom widgets.
Definition desktop.h:126
Gtk::Widget * get_scrollable_ancestor(Gtk::Widget *widget)
Get the first ancestor which is scrollable.
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