Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
toy-framework-2.cpp File Reference

Go to the source code of this file.

Functions

double uniform ()
 
void cairo_set_source_rgba (cairo_t *cr, colour c)
 
void draw_text (cairo_t *cr, Geom::Point loc, const char *txt, bool bottom, const char *fontdesc)
 
void draw_text (cairo_t *cr, Geom::Point loc, const std::string &txt, bool bottom, const std::string &fontdesc)
 
void draw_number (cairo_t *cr, Geom::Point pos, int num, std::string name, bool bottom)
 
void draw_number (cairo_t *cr, Geom::Point pos, unsigned num, std::string name, bool bottom)
 
void draw_number (cairo_t *cr, Geom::Point pos, double num, std::string name, bool bottom)
 
void redraw ()
 
void show_about_dialog (GSimpleAction *, GVariant *, gpointer)
 
void quit (GSimpleAction *, GVariant *, gpointer)
 
Geom::Point read_point (FILE *f)
 
void get_clipboard_text (std::function< void(char const *)> &&on_completion)
 
Geom::Interval read_interval (FILE *f)
 
void open_handles_cb (GObject *source_object, GAsyncResult *res, gpointer data)
 
void open_handles (GSimpleAction *, GVariant *, gpointer)
 
void save_handles_cb (GObject *source_object, GAsyncResult *res, gpointer data)
 
void save_handles (GSimpleAction *, GVariant *, gpointer)
 
void write_image (char const *filename)
 
void save_cairo_cb (GObject *source_object, GAsyncResult *res, gpointer data)
 
void save_cairo (GSimpleAction *, GVariant *, gpointer)
 
static void toggle_action (GSimpleAction *action, GVariant *, gpointer)
 
static void set_show_timings (GSimpleAction *action, GVariant *variant, gpointer)
 
static void draw_callback (GtkDrawingArea *drawing_area, cairo_t *cr, int width, int height, gpointer user_data)
 
static void mouse_motion_event (GtkEventControllerMotion *self, double x, double y, gpointer user_data)
 
static void mouse_press_event (GtkGestureClick *self, int n_press, double x, double y, gpointer user_data)
 
static gboolean scroll_event (GtkEventControllerScroll *self, double dx, double dy, gpointer user_data)
 
static void mouse_release_event (GtkGestureClick *self, int n_press, double x, double y, gpointer user_data)
 
static gboolean key_press_event (GtkEventControllerKey *self, unsigned keyval, unsigned keycode, GdkModifierType state, gpointer user_data)
 
static void activate (GApplication *app, gpointer)
 
static void startup (GApplication *app, gpointer)
 
void init (int argc, char **argv, Toy *t, int width, int height)
 
void toggle_events (std::vector< Toggle > &ts, Geom::Point const &pos, unsigned button)
 
void draw_toggles (cairo_t *cr, std::vector< Toggle > &ts)
 

Variables

GtkApplicationWindow * the_window = nullptr
 
static GtkWidget * the_canvas = nullptr
 
Toythe_toy = nullptr
 
int the_requested_height = 0
 
int the_requested_width = 0
 
gchar ** the_emulated_argv = nullptr
 
gchar * arg_spool_filename = nullptr
 
gchar * arg_handles_filename = nullptr
 
gchar * arg_screenshot_filename = nullptr
 
gchar ** arg_extra_files = nullptr
 
const char * the_builder_xml
 
static GActionEntry the_actions []
 
static GOptionEntry const the_options []
 

Function Documentation

◆ activate()

◆ cairo_set_source_rgba()

◆ draw_callback()

static void draw_callback ( GtkDrawingArea *  drawing_area,
cairo_t cr,
int  width,
int  height,
gpointer  user_data 
)
static

◆ draw_number() [1/3]

void draw_number ( cairo_t cr,
Geom::Point  pos,
double  num,
std::string  name,
bool  bottom 
)

Definition at line 155 of file toy-framework-2.cpp.

References draw_text(), name, and num.

◆ draw_number() [2/3]

void draw_number ( cairo_t cr,
Geom::Point  pos,
int  num,
std::string  name,
bool  bottom 
)

Definition at line 139 of file toy-framework-2.cpp.

References draw_text(), name, and num.

Referenced by PointSetHandle::draw().

◆ draw_number() [3/3]

void draw_number ( cairo_t cr,
Geom::Point  pos,
unsigned  num,
std::string  name,
bool  bottom 
)

Definition at line 147 of file toy-framework-2.cpp.

References draw_text(), name, and num.

◆ draw_text() [1/2]

void draw_text ( cairo_t cr,
Geom::Point  loc,
const char *  txt,
bool  bottom,
const char *  fontdesc 
)

◆ draw_text() [2/2]

void draw_text ( cairo_t cr,
Geom::Point  loc,
const std::string &  txt,
bool  bottom,
const std::string &  fontdesc 
)

Definition at line 135 of file toy-framework-2.cpp.

References draw_text().

◆ draw_toggles()

void draw_toggles ( cairo_t cr,
std::vector< Toggle > &  ts 
)

Definition at line 739 of file toy-framework-2.cpp.

◆ get_clipboard_text()

void get_clipboard_text ( std::function< void(char const *)> &&  on_completion)

Definition at line 303 of file toy-framework-2.cpp.

References data, and the_canvas.

◆ init()

◆ key_press_event()

static gboolean key_press_event ( GtkEventControllerKey *  self,
unsigned  keyval,
unsigned  keycode,
GdkModifierType  state,
gpointer  user_data 
)
static

Definition at line 523 of file toy-framework-2.cpp.

References Toy::key_hit(), and the_toy.

Referenced by activate().

◆ mouse_motion_event()

static void mouse_motion_event ( GtkEventControllerMotion *  self,
double  x,
double  y,
gpointer  user_data 
)
static

Definition at line 487 of file toy-framework-2.cpp.

References Toy::mouse_moved(), and the_toy.

Referenced by activate().

◆ mouse_press_event()

static void mouse_press_event ( GtkGestureClick *  self,
int  n_press,
double  x,
double  y,
gpointer  user_data 
)
static

Definition at line 495 of file toy-framework-2.cpp.

References Toy::mouse_pressed(), and the_toy.

Referenced by activate().

◆ mouse_release_event()

static void mouse_release_event ( GtkGestureClick *  self,
int  n_press,
double  x,
double  y,
gpointer  user_data 
)
static

Definition at line 514 of file toy-framework-2.cpp.

References Toy::mouse_released(), and the_toy.

Referenced by activate().

◆ open_handles()

void open_handles ( GSimpleAction *  ,
GVariant *  ,
gpointer   
)

Definition at line 346 of file toy-framework-2.cpp.

References open_handles_cb(), the_toy, and the_window.

◆ open_handles_cb()

void open_handles_cb ( GObject source_object,
GAsyncResult *  res,
gpointer  data 
)

Definition at line 327 of file toy-framework-2.cpp.

References Toy::load(), redraw(), and the_toy.

Referenced by open_handles().

◆ quit()

void quit ( GSimpleAction *  ,
GVariant *  ,
gpointer   
)

Definition at line 292 of file toy-framework-2.cpp.

◆ read_interval()

Geom::Interval read_interval ( FILE *  f)

Definition at line 318 of file toy-framework-2.cpp.

References Geom::GenericInterval< C >::setEnds().

Referenced by RectHandle::load().

◆ read_point()

Geom::Point read_point ( FILE *  f)

Definition at line 296 of file toy-framework-2.cpp.

Referenced by PointHandle::load(), and PointSetHandle::load().

◆ redraw()

void redraw ( )

◆ save_cairo()

void save_cairo ( GSimpleAction *  ,
GVariant *  ,
gpointer   
)

Definition at line 442 of file toy-framework-2.cpp.

References save_cairo_cb(), and the_window.

◆ save_cairo_cb()

void save_cairo_cb ( GObject source_object,
GAsyncResult *  res,
gpointer  data 
)

Definition at line 428 of file toy-framework-2.cpp.

References write_image().

Referenced by save_cairo().

◆ save_handles()

void save_handles ( GSimpleAction *  ,
GVariant *  ,
gpointer   
)

Definition at line 371 of file toy-framework-2.cpp.

References save_handles_cb(), the_toy, and the_window.

◆ save_handles_cb()

void save_handles_cb ( GObject source_object,
GAsyncResult *  res,
gpointer  data 
)

Definition at line 354 of file toy-framework-2.cpp.

References Toy::save(), and the_toy.

Referenced by save_handles().

◆ scroll_event()

static gboolean scroll_event ( GtkEventControllerScroll *  self,
double  dx,
double  dy,
gpointer  user_data 
)
static

◆ set_show_timings()

static void set_show_timings ( GSimpleAction *  action,
GVariant *  variant,
gpointer   
)
static

Definition at line 455 of file toy-framework-2.cpp.

References Toy::show_timings, and the_toy.

◆ show_about_dialog()

void show_about_dialog ( GSimpleAction *  ,
GVariant *  ,
gpointer   
)

Definition at line 278 of file toy-framework-2.cpp.

References buf.

◆ startup()

static void startup ( GApplication *  app,
gpointer   
)
static

Definition at line 627 of file toy-framework-2.cpp.

References builder, and the_builder_xml.

Referenced by init().

◆ toggle_action()

static void toggle_action ( GSimpleAction *  action,
GVariant *  ,
gpointer   
)
static

Definition at line 449 of file toy-framework-2.cpp.

◆ toggle_events()

void toggle_events ( std::vector< Toggle > &  ts,
Geom::Point const &  pos,
unsigned  button 
)

Definition at line 732 of file toy-framework-2.cpp.

◆ uniform()

double uniform ( )

Definition at line 30 of file toy-framework-2.cpp.

◆ write_image()

void write_image ( char const *  filename)

Definition at line 379 of file toy-framework-2.cpp.

References Toy::draw(), height, the_canvas, the_toy, and width.

Referenced by activate(), and save_cairo_cb().

Variable Documentation

◆ arg_extra_files

gchar** arg_extra_files = nullptr

Definition at line 26 of file toy-framework-2.cpp.

Referenced by activate().

◆ arg_handles_filename

gchar* arg_handles_filename = nullptr

Definition at line 24 of file toy-framework-2.cpp.

Referenced by activate().

◆ arg_screenshot_filename

gchar* arg_screenshot_filename = nullptr

Definition at line 25 of file toy-framework-2.cpp.

Referenced by activate().

◆ arg_spool_filename

gchar* arg_spool_filename = nullptr

Definition at line 23 of file toy-framework-2.cpp.

Referenced by activate().

◆ the_actions

GActionEntry the_actions[]
static
Initial value:
=
{
{"open-handles", open_handles, nullptr, nullptr, nullptr},
{"save-handles", save_handles, nullptr, nullptr, nullptr},
{"save-image", save_cairo, nullptr, nullptr, nullptr},
{"show-timings", toggle_action, nullptr, "false", set_show_timings},
{"quit", quit, nullptr, nullptr, nullptr},
{"about", show_about_dialog, nullptr, nullptr, nullptr},
}
void open_handles(GSimpleAction *, GVariant *, gpointer)
void quit(GSimpleAction *, GVariant *, gpointer)
void show_about_dialog(GSimpleAction *, GVariant *, gpointer)
void save_cairo(GSimpleAction *, GVariant *, gpointer)
static void set_show_timings(GSimpleAction *action, GVariant *variant, gpointer)
void save_handles(GSimpleAction *, GVariant *, gpointer)
static void toggle_action(GSimpleAction *action, GVariant *, gpointer)

Definition at line 575 of file toy-framework-2.cpp.

Referenced by init().

◆ the_builder_xml

const char* the_builder_xml

Definition at line 531 of file toy-framework-2.cpp.

Referenced by startup().

◆ the_canvas

GtkWidget* the_canvas = nullptr
static

Definition at line 17 of file toy-framework-2.cpp.

Referenced by activate(), get_clipboard_text(), redraw(), and write_image().

◆ the_emulated_argv

gchar** the_emulated_argv = nullptr

Definition at line 21 of file toy-framework-2.cpp.

◆ the_options

GOptionEntry const the_options[]
static
Initial value:
= {
{"handles", 'h', G_OPTION_FLAG_NONE, G_OPTION_ARG_FILENAME, &arg_handles_filename,
"Load handle positions from given file", "FILE"},
{"spool", 'm', G_OPTION_FLAG_NONE, G_OPTION_ARG_FILENAME, &arg_spool_filename,
"Record all interaction to the given file", "FILE"},
{"screenshot", 's', G_OPTION_FLAG_NONE, G_OPTION_ARG_FILENAME, &arg_screenshot_filename,
"Take screenshot and exit", nullptr},
{G_OPTION_REMAINING, 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_FILENAME_ARRAY, &arg_extra_files,
"Additional data files", "FILES..."},
{nullptr, 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, nullptr, nullptr, nullptr},
}
gchar * arg_spool_filename
gchar * arg_screenshot_filename
gchar * arg_handles_filename
gchar ** arg_extra_files

Definition at line 585 of file toy-framework-2.cpp.

Referenced by init().

◆ the_requested_height

int the_requested_height = 0

Definition at line 19 of file toy-framework-2.cpp.

Referenced by activate(), and init().

◆ the_requested_width

int the_requested_width = 0

Definition at line 20 of file toy-framework-2.cpp.

Referenced by activate(), and init().

◆ the_toy

◆ the_window

GtkApplicationWindow* the_window = nullptr

Definition at line 16 of file toy-framework-2.cpp.

Referenced by activate(), open_handles(), save_cairo(), and save_handles().