16#include <gtkmm/notebook.h>
59void gui_warning(
const std::string &
msg, Gtk::Window * parent_window =
nullptr);
71std::vector<Gtk::Widget *>
get_children(Gtk::Widget &widget);
78 widget.remove(*
child);
89template <
typename Func>
91 bool const plus_self =
false,
bool const recurse =
false,
94 static_assert(std::is_invocable_r_v<ForEachResult, Func, Gtk::Widget &>);
97 auto ret = func(widget);
104 if (!recurse && level > 0)
return nullptr;
108 if (descendant)
return descendant;
118template <
typename Func>
121 return for_each_child(widget, std::forward<Func>(func),
true,
true);
125template <
typename Func>
128 static_assert(std::is_invocable_r_v<ForEachResult, Func, Gtk::Widget &>);
138template <
typename Func>
140 static_assert(std::is_invocable_r_v<ForEachResult, Func, Gtk::Widget&>);
142 const int page_number = notebook.get_n_pages();
143 for (
int page_index = 0; page_index < page_number; ++page_index) {
144 auto page = notebook.get_nth_page(page_index);
155[[nodiscard]]
bool is_descendant_of(Gtk::Widget
const &descendant, Gtk::Widget
const &ancestor);
169Gdk::RGBA
mix_colors(
const Gdk::RGBA& a,
const Gdk::RGBA& b,
float ratio);
172Gdk::RGBA
change_alpha(
const Gdk::RGBA& color,
double new_alpha);
182 Glib::ustring
const &css_class);
206 return Gdk::Graphene::Point(point.
x(), point.
y());
209 return Gdk::Graphene::Point(point.
x(), point.
y());
214 const Gdk::RGBA& from,
229Glib::ustring
round_numbers(
const Glib::ustring& text,
int precision);
232void truncate_digits(
const Glib::RefPtr<Gtk::TextBuffer>& buffer,
int precision);
238Glib::RefPtr<Gdk::Texture>
to_texture(Cairo::RefPtr<Cairo::Surface>
const &
surface);
245char const *
get_text(Gtk::Editable
const &editable);
Cairo::RefPtr< Cairo::ImageSurface > surface
3x3 matrix representing an affine transformation.
Axis aligned, non-empty, generic rectangle.
C top() const
Return top coordinate of the rectangle (+Y is downwards).
C left() const
Return leftmost coordinate of the rectangle (+X is to the right).
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
Two-dimensional point with integer coordinates.
constexpr IntCoord x() const noexcept
constexpr IntCoord y() const noexcept
Two-dimensional point that doubles as a vector.
constexpr Coord y() const noexcept
constexpr Coord x() const noexcept
static char const *const parent
Control handle rendering/caching.
A set of useful color modifying functions which do not fit as generic methods on the color class itse...
Gtk::Widget * for_each_parent(Gtk::Widget &widget, Func &&func)
Call Func with a reference to successive parents, until Func returns _break.
void remove_all_children(Widget &widget)
For each child in get_children(widget), call widget.remove(*child). May not cause delete child!
void set_icon_sizes(Gtk::Widget *parent, int pixel_size)
Recursively set all the icon sizes inside this parent widget.
void gui_warning(const std::string &msg, Gtk::Window *parent_window)
Gtk::Widget & get_nth_child(Gtk::Widget &widget, std::size_t const index)
Get the widgetʼs child at the given position. Throws std::out_of_range if the index is invalid.
Gtk::Widget * for_each_descendant(Gtk::Widget &widget, Func &&func)
Like for_each_child() but also tests the initial widget & recurses through childrenʼs children.
Gtk::Widget * find_widget_by_name(Gtk::Widget &parent, Glib::ustring const &name, bool visible_only)
Returns a named descendent of parent, which has the given name, or nullptr if there's none.
bool is_descendant_of(Gtk::Widget const &descendant, Gtk::Widget const &ancestor)
Returns if widget is a descendant of given ancestor, i.e.: itself, a child, or a childʼs child.
int get_font_size(Gtk::Widget &widget)
Get the relative font size as determined by a widgetʼs style/Pango contexts.
ForEachResult
Whether for_each_*() will continue or stop after calling Func per child.
std::vector< Gtk::Widget * > get_children(Gtk::Widget &widget)
Get a vector of the widgetʼs children, from get_first_child() through each get_next_sibling().
void ellipsize(Gtk::Label &label, int const max_width_chars, Pango::EllipsizeMode const mode)
Gtk::Widget * for_each_child(Gtk::Widget &widget, Func &&func, bool const plus_self=false, bool const recurse=false, int const level=0)
Call Func with a reference to each child of parent, until it returns _break.
Gtk::Widget * for_each_page(Gtk::Notebook ¬ebook, Func &&func)
Similar to for_each_child, but only iterates over pages in a notebook.
void system_open(const Glib::ustring &path)
Opens the given path with platform-specific tools.
bool contains_focus(Gtk::Widget &widget)
Returns if widget or one of its descendants has focus.
Gtk::Widget * find_focusable_widget(Gtk::Widget &parent)
This function traverses a tree of widgets searching for first focusable widget.
Glib::ustring ink_ellipsize_text(Glib::ustring const &src, std::size_t maxlen)
Glib::ustring round_numbers(const Glib::ustring &text, int precision)
unsigned int get_color_value(const Glib::ustring color)
Color is store as a string in the form #RRGGBBAA, '0' means "unset".
double get_luminance(const Gdk::RGBA &color)
Calculate luminance of an RGBA color from its RGB in range 0 to 1 inclusive.
Glib::RefPtr< Gdk::Texture > to_texture(Cairo::RefPtr< Cairo::Surface > const &surface)
Convert an image surface in ARGB32 format to a texture.
Gdk::RGBA to_rgba(guint32 const u32)
Cairo::RectangleInt geom_to_cairo(const Geom::IntRect &rect)
uint32_t conv_gdk_color_to_rgba(const Gdk::RGBA &color, double replace_alpha=-1)
Gdk::Graphene::Rect geom_to_gtk(Geom::GenericRect< T > const &rect)
guint32 to_guint32(Gdk::RGBA const &rgba)
Gdk::RGBA css_color_to_gdk(const char *value)
void restrict_minsize_to_square(Gtk::Widget &widget, int min_size_px)
bool is_widget_effectively_visible(Gtk::Widget const *widget)
std::vector< GskColorStop > create_cubic_gradient(const Gdk::RGBA &from, const Gdk::RGBA &to, Geom::Point ctrl1, Geom::Point ctrl2, Geom::Point p0=Geom::Point(0, 0), Geom::Point p1=Geom::Point(1, 1), int steps=8)
Gdk::RGBA get_color_with_class(Gtk::Widget &widget, Glib::ustring const &css_class)
char const * get_text(Gtk::Editable const &editable)
Get the text from a GtkEditable without the temporary copy imposed by gtkmm.
Gdk::RGBA change_alpha(const Gdk::RGBA &color, double new_alpha)
Gdk::RGBA mix_colors(const Gdk::RGBA &a, const Gdk::RGBA &b, float ratio)
Geom::IntRect cairo_to_geom(const Cairo::RectangleInt &rect)
void reveal_widget(Gtk::Widget *widget, bool show)
Show widget, if the widget has a Gtk::Reveal parent, reveal instead.
void truncate_digits(const Glib::RefPtr< Gtk::TextBuffer > &buffer, int precision)
void set_dark_titlebar(Glib::RefPtr< Gdk::Surface > const &surface, bool is_dark)
Gdk::RGBA color_to_rgba(Inkscape::Colors::Color const &color)
Glib::ustring gdk_to_css_color(const Gdk::RGBA &color)
These GUI related color conversions allow us to convert from SVG xml attributes to Gdk colors,...
Geom::IntPoint dimensions(const Cairo::RefPtr< Cairo::ImageSurface > &surface)