Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
util.cpp File Reference

Go to the source code of this file.

Namespaces

namespace  Inkscape
 Helper class to stream background task notifications as a series of messages.
 
namespace  Inkscape::UI
 User interface code.
 

Functions

Glib::ustring ink_ellipsize_text (Glib::ustring const &src, std::size_t maxlen)
 
void reveal_widget (Gtk::Widget *widget, bool show)
 Show widget, if the widget has a Gtk::Reveal parent, reveal instead.
 
bool is_widget_effectively_visible (Gtk::Widget const *widget)
 
void Inkscape::UI::set_icon_sizes (Gtk::Widget *parent, int pixel_size)
 Recursively set all the icon sizes inside this parent widget.
 
void Inkscape::UI::set_icon_sizes (GtkWidget *parent, int pixel_size)
 
void Inkscape::UI::gui_warning (const std::string &msg, Gtk::Window *parent_window)
 
void Inkscape::UI::system_open (const Glib::ustring &path)
 Opens the given path with platform-specific tools.
 
std::vector< Gtk::Widget * > Inkscape::UI::get_children (Gtk::Widget &widget)
 Get a vector of the widgetʼs children, from get_first_child() through each get_next_sibling().
 
Gtk::Widget & Inkscape::UI::get_nth_child (Gtk::Widget &widget, std::size_t index)
 Get the widgetʼs child at the given position. Throws std::out_of_range if the index is invalid.
 
Gtk::Widget * Inkscape::UI::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.
 
Gtk::Widget * Inkscape::UI::find_focusable_widget (Gtk::Widget &parent)
 This function traverses a tree of widgets searching for first focusable widget.
 
bool Inkscape::UI::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.
 
bool Inkscape::UI::contains_focus (Gtk::Widget &widget)
 Returns if widget or one of its descendants has focus.
 
int Inkscape::UI::get_font_size (Gtk::Widget &widget)
 Get the relative font size as determined by a widgetʼs style/Pango contexts.
 
void Inkscape::UI::ellipsize (Gtk::Label &label, int const max_width_chars, Pango::EllipsizeMode const mode)
 
unsigned int get_color_value (const Glib::ustring color)
 Color is store as a string in the form #RRGGBBAA, '0' means "unset".
 
Gdk::RGBA mix_colors (const Gdk::RGBA &a, const Gdk::RGBA &b, float ratio)
 
double get_luminance (Gdk::RGBA const &rgba)
 Calculate luminance of an RGBA color from its RGB in range 0 to 1 inclusive.
 
Gdk::RGBA get_color_with_class (Gtk::Widget &widget, Glib::ustring const &css_class)
 
guint32 to_guint32 (Gdk::RGBA const &rgba)
 
Gdk::RGBA color_to_rgba (Inkscape::Colors::Color const &color)
 
Gdk::RGBA to_rgba (guint32 const u32)
 
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, without needing the entire CMS framework, which would be excessive for widget painting.
 
Gdk::RGBA css_color_to_gdk (const char *value)
 
Cairo::RectangleInt geom_to_cairo (const Geom::IntRect &rect)
 
Geom::IntRect cairo_to_geom (const Cairo::RectangleInt &rect)
 
Cairo::Matrix geom_to_cairo (const Geom::Affine &affine)
 
Geom::IntPoint dimensions (const Cairo::RefPtr< Cairo::ImageSurface > &surface)
 
Geom::IntPoint dimensions (const Gdk::Rectangle &allocation)
 
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 p1, int steps)
 
Gdk::RGBA change_alpha (const Gdk::RGBA &color, double new_alpha)
 
uint32_t conv_gdk_color_to_rgba (const Gdk::RGBA &color, double replace_alpha)
 
void set_dark_titlebar (Glib::RefPtr< Gdk::Surface > const &surface, bool is_dark)
 
static int fmt_number (const _GMatchInfo *match, _GString *ret, void *prec)
 
Glib::ustring round_numbers (const Glib::ustring &text, int precision)
 
void truncate_digits (const Glib::RefPtr< Gtk::TextBuffer > &buffer, int precision)
 
Glib::RefPtr< Gdk::Texture > to_texture (Cairo::RefPtr< Cairo::Surface > const &surface)
 Convert an image surface in ARGB32 format to a texture.
 
void restrict_minsize_to_square (Gtk::Widget &widget, int min_size_px)
 
char const * get_text (Gtk::Editable const &editable)
 Get the text from a GtkEditable without the temporary copy imposed by gtkmm.
 

Function Documentation

◆ cairo_to_geom()

◆ change_alpha()

◆ color_to_rgba()

Gdk::RGBA color_to_rgba ( Inkscape::Colors::Color const &  color)

Definition at line 320 of file util.cpp.

References to_rgba(), and Inkscape::Colors::Color::toRGBA().

Referenced by Inkscape::Extension::ParamColor::get_widget().

◆ conv_gdk_color_to_rgba()

uint32_t conv_gdk_color_to_rgba ( const Gdk::RGBA &  color,
double  replace_alpha 
)

◆ create_cubic_gradient()

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  p1,
int  steps 
)

Definition at line 378 of file util.cpp.

References Geom::bernstein_value_at(), mix_colors(), offset, and result.

Referenced by Inkscape::UI::Widget::Ruler::draw_ruler().

◆ css_color_to_gdk()

Gdk::RGBA css_color_to_gdk ( const char *  value)

Definition at line 343 of file util.cpp.

References Inkscape::Colors::hex_to_rgba(), and to_rgba().

◆ dimensions() [1/2]

◆ dimensions() [2/2]

Geom::IntPoint dimensions ( const Gdk::Rectangle &  allocation)

Definition at line 373 of file util.cpp.

◆ fmt_number()

static int fmt_number ( const _GMatchInfo *  match,
_GString *  ret,
void *  prec 
)
static

Definition at line 451 of file util.cpp.

References end, fmt, and Inkscape::Util::format_number().

Referenced by round_numbers().

◆ gdk_to_css_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, without needing the entire CMS framework, which would be excessive for widget painting.

Definition at line 340 of file util.cpp.

References Inkscape::Colors::rgba_to_hex(), and to_guint32().

Referenced by Inkscape::UI::Dialog::StartScreen::canvas_changed(), and Inkscape::UI::Widget::GradientWithStops::draw_func().

◆ geom_to_cairo() [1/2]

Cairo::Matrix geom_to_cairo ( const Geom::Affine affine)

Definition at line 363 of file util.cpp.

◆ geom_to_cairo() [2/2]

◆ get_color_value()

unsigned int get_color_value ( const Glib::ustring  color)

Color is store as a string in the form #RRGGBBAA, '0' means "unset".

Parameters
color- The string color from glade.

Definition at line 275 of file util.cpp.

References SP_RGBA32_F_COMPOSE().

Referenced by Inkscape::UI::Dialog::StartScreen::theme_changed().

◆ get_color_with_class()

◆ get_luminance()

double get_luminance ( const Gdk::RGBA &  color)

Calculate luminance of an RGBA color from its RGB in range 0 to 1 inclusive.

This uses the perceived brightness formula given at: https://www.w3.org/TR/AERT/#color-contrast

Definition at line 295 of file util.cpp.

◆ get_text()

char const * get_text ( Gtk::Editable const &  editable)

Get the text from a GtkEditable without the temporary copy imposed by gtkmm.

Definition at line 549 of file util.cpp.

Referenced by Inkscape::UI::Widget::InkSpinButton::commit_entry().

◆ ink_ellipsize_text()

Glib::ustring ink_ellipsize_text ( Glib::ustring const &  src,
std::size_t  maxlen 
)

Definition at line 67 of file util.cpp.

◆ is_widget_effectively_visible()

bool is_widget_effectively_visible ( Gtk::Widget const *  widget)

Definition at line 97 of file util.cpp.

◆ mix_colors()

Gdk::RGBA mix_colors ( const Gdk::RGBA &  a,
const Gdk::RGBA &  b,
float  ratio 
)

◆ restrict_minsize_to_square()

void restrict_minsize_to_square ( Gtk::Widget &  widget,
int  min_size_px 
)

Definition at line 537 of file util.cpp.

References css, and name.

Referenced by Inkscape::UI::Widget::ColorPicker::_construct().

◆ reveal_widget()

void reveal_widget ( Gtk::Widget *  widget,
bool  show 
)

Show widget, if the widget has a Gtk::Reveal parent, reveal instead.

Parameters
widget- The child widget to show.

Definition at line 83 of file util.cpp.

◆ round_numbers()

Glib::ustring round_numbers ( const Glib::ustring &  text,
int  precision 
)

Definition at line 473 of file util.cpp.

References fmt_number().

Referenced by truncate_digits().

◆ set_dark_titlebar()

void set_dark_titlebar ( Glib::RefPtr< Gdk::Surface > const &  surface,
bool  is_dark 
)

Definition at line 433 of file util.cpp.

References surface.

Referenced by Inkscape::UI::ThemeContext::themechangecallback().

◆ to_guint32()

◆ to_rgba()

Gdk::RGBA to_rgba ( guint32 const  u32)

◆ to_texture()

◆ truncate_digits()

void truncate_digits ( const Glib::RefPtr< Gtk::TextBuffer > &  buffer,
int  precision 
)

Definition at line 481 of file util.cpp.

References end, round_numbers(), and start.

Referenced by Inkscape::UI::Dialog::AttrDialog::truncateDigits().