Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
CustomButtonWidget Class Reference

Custom button to be drawn inside drawing areas. More...

#include <src/gui/backend/gtk_widgets/custom_button.h>

Collaboration diagram for CustomButtonWidget:

Public Types

enum class  State {
  NORMAL , HOVERED , ACTIVE , TOGGLED ,
  SEMI_TOGGLED
}
enum class  Owner { TRACK , LANE , AT }

Public Member Functions

 CustomButtonWidget (const std::string &iicon_name, int isize)
 CustomButtonWidget (const CustomButtonWidget &)=delete
CustomButtonWidgetoperator= (const CustomButtonWidget &)=delete
 CustomButtonWidget (CustomButtonWidget &&)=default
CustomButtonWidgetoperator= (CustomButtonWidget &&)=default
void draw (GtkSnapshot *snapshot, double ix, double iy, State state)
void draw_with_text (GtkSnapshot *snapshot, double ix, double iy, double iwidth, State state)
void set_text (PangoLayout *ilayout, const std::string &itext, const std::string &font_descr)
 Sets the text and layout to draw the text width.

Data Fields

Color def_color = {}
 Default color.
Color hovered_color = {}
 Hovered color.
Color toggled_color = {}
 Toggled color.
Color held_color = {}
 Held color (used after clicking and before releasing).
std::string icon_name
 Name of the icon to show.
int size = 0
 Size in pixels (width and height will be set to this).
int width = 0
 if non-zero, the button has "size" height and this width.
double aspect = 1.0
 Aspect ratio for the rounded rectangle.
double corner_radius = 0.0
 Corner curvature radius for the rounded rectangle.
GdkTexture * icon_texture = nullptr
 The icon surface.
State last_state = State::NORMAL
 Used to update caches if state changed.
Owner owner_type = Owner::TRACK
 Owner type.
void * owner = nullptr
 Owner.
Color last_color = {}
 Used during transitions.
std::string text
 Text, if any, to show after the icon.
int text_height = 0
PangoLayout * layout = nullptr
 Cache layout for drawing the text.
double x = 0
 X/y relative to parent drawing area.
double y = 0
unsigned int button_id = 0
 The id of the button returned by a symap of its icon name, for better performance vs comparing strings.
int transition_frames = 0
 Frames left for a transition in color.

Detailed Description

Custom button to be drawn inside drawing areas.

Definition at line 29 of file custom_button.h.

Member Enumeration Documentation

◆ Owner

enum class CustomButtonWidget::Owner
strong

Definition at line 43 of file custom_button.h.

◆ State

enum class CustomButtonWidget::State
strong
Enumerator
SEMI_TOGGLED 

Only border is toggled.

Definition at line 32 of file custom_button.h.

Member Function Documentation

◆ draw_with_text()

void CustomButtonWidget::draw_with_text ( GtkSnapshot * snapshot,
double ix,
double iy,
double iwidth,
State state )
Parameters
widthMax width for the button to use.

◆ set_text()

void CustomButtonWidget::set_text ( PangoLayout * ilayout,
const std::string & itext,
const std::string & font_descr )

Sets the text and layout to draw the text width.

Parameters
font_descrFont description to set the pango layout font to.

Field Documentation

◆ aspect

double CustomButtonWidget::aspect = 1.0

Aspect ratio for the rounded rectangle.

Definition at line 125 of file custom_button.h.

◆ button_id

unsigned int CustomButtonWidget::button_id = 0

The id of the button returned by a symap of its icon name, for better performance vs comparing strings.

TODO

Definition at line 168 of file custom_button.h.

◆ corner_radius

double CustomButtonWidget::corner_radius = 0.0

Corner curvature radius for the rounded rectangle.

Definition at line 128 of file custom_button.h.

◆ def_color

Color CustomButtonWidget::def_color = {}

Default color.

Definition at line 103 of file custom_button.h.

◆ held_color

Color CustomButtonWidget::held_color = {}

Held color (used after clicking and before releasing).

Definition at line 113 of file custom_button.h.

◆ hovered_color

Color CustomButtonWidget::hovered_color = {}

Hovered color.

Definition at line 106 of file custom_button.h.

◆ icon_name

std::string CustomButtonWidget::icon_name

Name of the icon to show.

Definition at line 116 of file custom_button.h.

◆ icon_texture

GdkTexture* CustomButtonWidget::icon_texture = nullptr

The icon surface.

Definition at line 131 of file custom_button.h.

◆ last_color

Color CustomButtonWidget::last_color = {}

Used during transitions.

Definition at line 143 of file custom_button.h.

◆ last_state

State CustomButtonWidget::last_state = State::NORMAL

Used to update caches if state changed.

Definition at line 134 of file custom_button.h.

◆ layout

PangoLayout* CustomButtonWidget::layout = nullptr

Cache layout for drawing the text.

Definition at line 155 of file custom_button.h.

◆ owner

void* CustomButtonWidget::owner = nullptr

Owner.

Definition at line 140 of file custom_button.h.

◆ owner_type

Owner CustomButtonWidget::owner_type = Owner::TRACK

Owner type.

Definition at line 137 of file custom_button.h.

◆ size

int CustomButtonWidget::size = 0

Size in pixels (width and height will be set to this).

Definition at line 119 of file custom_button.h.

◆ text

std::string CustomButtonWidget::text

Text, if any, to show after the icon.

This will be ellipsized.

Definition at line 150 of file custom_button.h.

◆ text_height

int CustomButtonWidget::text_height = 0

Definition at line 152 of file custom_button.h.

◆ toggled_color

Color CustomButtonWidget::toggled_color = {}

Toggled color.

Definition at line 109 of file custom_button.h.

◆ transition_frames

int CustomButtonWidget::transition_frames = 0

Frames left for a transition in color.

Definition at line 171 of file custom_button.h.

◆ width

int CustomButtonWidget::width = 0

if non-zero, the button has "size" height and this width.

Definition at line 122 of file custom_button.h.

◆ x

double CustomButtonWidget::x = 0

X/y relative to parent drawing area.

Definition at line 158 of file custom_button.h.

◆ y

double CustomButtonWidget::y = 0

Definition at line 159 of file custom_button.h.


The documentation for this class was generated from the following file: