aosd-text.h | aosd-text.h | |||
---|---|---|---|---|
/* aosd -- OSD with transparency, cairo, and pango. | /* aosd -- OSD with transparency, cairo, and pango. | |||
* | * | |||
* Copyright (C) 2006 Evan Martin <martine@danga.com> | * Copyright (C) 2007 Eugene Paskevich <eugene@raptor.kiev.ua> | |||
*/ | */ | |||
#ifndef __AOSD_TEXT_H__ | #ifndef __AOSD_TEXT_H__ | |||
#define __AOSD_TEXT_H__ | #define __AOSD_TEXT_H__ | |||
Aosd* aosd_new_text(const char* markup, int x, int y); | #include <aosd.h> | |||
#include "pango/pangocairo.h" | ||||
#ifdef __cplusplus | ||||
extern "C" | ||||
{ | ||||
#endif | ||||
// Tiny Pango API augmentation | ||||
// Way more convenient for aosd. | ||||
PangoLayout* pango_layout_new_aosd(void); | ||||
void pango_layout_unref_aosd(PangoLayout* lay); | ||||
void pango_layout_get_size_aosd(PangoLayout* lay, | ||||
unsigned* width, unsigned* height, int* lbearing); | ||||
// Converts all \n occurrences into U+2028 symbol | ||||
void pango_layout_set_text_aosd(PangoLayout* lay, char* text); | ||||
void pango_layout_set_attr_aosd(PangoLayout* lay, PangoAttribute* attr); | ||||
void pango_layout_set_font_aosd(PangoLayout* lay, char* font_desc); | ||||
typedef struct | ||||
{ | ||||
PangoLayout* lay; | ||||
int lbearing; | ||||
struct | ||||
{ | ||||
guint8 x_offset; | ||||
guint8 y_offset; | ||||
} geom; | ||||
struct | ||||
{ | ||||
char* color; | ||||
guint8 opacity; | ||||
} back; | ||||
struct | ||||
{ | ||||
char* color; | ||||
guint8 opacity; | ||||
gint8 x_offset; | ||||
gint8 y_offset; | ||||
} shadow; | ||||
struct | ||||
{ | ||||
char* color; | ||||
guint8 opacity; | ||||
} fore; | ||||
} TextRenderData; | ||||
void aosd_text_renderer(cairo_t* cr, void* TextRenderData_ptr); | ||||
void aosd_text_get_size(TextRenderData* trd, unsigned* width, unsigned* hei | ||||
ght); | ||||
int aosd_text_get_screen_wrap_width(Aosd* aosd, TextRenderData* trd); | ||||
#ifdef __cplusplus | ||||
} | ||||
#endif | ||||
#endif /* __AOSD_TEXT_H__ */ | #endif /* __AOSD_TEXT_H__ */ | |||
/* vim: set ts=2 sw=2 et : */ | /* vim: set ts=2 sw=2 et : */ | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 64 lines changed or added | |||
aosd.h | aosd.h | |||
---|---|---|---|---|
skipping to change at line 18 | skipping to change at line 18 | |||
* - added/changed some other stuff | * - added/changed some other stuff | |||
*/ | */ | |||
#ifndef __AOSD_H__ | #ifndef __AOSD_H__ | |||
#define __AOSD_H__ | #define __AOSD_H__ | |||
#include <X11/Xutil.h> | #include <X11/Xutil.h> | |||
#include <cairo/cairo.h> | #include <cairo/cairo.h> | |||
#include <limits.h> /* INT_MAX */ | #ifdef __cplusplus | |||
#include <sys/time.h> /* timeval */ | extern "C" | |||
{ | ||||
#endif | ||||
/* global object type */ | /* global object type */ | |||
typedef struct _Aosd Aosd; | typedef struct _Aosd Aosd; | |||
#define AOSD_COORD_CENTER INT_MAX | // relative coordinates for positioning | |||
typedef enum { | ||||
COORDINATE_MINIMUM = 0, | ||||
COORDINATE_CENTER, | ||||
COORDINATE_MAXIMUM | ||||
} AosdCoordinate; | ||||
/* minimal struct to handle mouse events */ | /* minimal struct to handle mouse events */ | |||
typedef struct | typedef struct | |||
{ | { | |||
// relative coordinates | // relative coordinates | |||
int x, y; | int x, y; | |||
// global coordinates | // global coordinates | |||
int x_root, y_root; | int x_root, y_root; | |||
// whether we should send the event further | ||||
int send_event; | int send_event; | |||
// button being pressed | // button being pressed | |||
unsigned int button; | unsigned int button; | |||
unsigned long time; | unsigned long time; | |||
} | } | |||
AosdMouseEvent; | AosdMouseEvent; | |||
/* various callbacks */ | /* various callbacks */ | |||
typedef void (*AosdRenderer)(Aosd* aosd, cairo_t* cr, void* user_data); | typedef void (*AosdRenderer)(cairo_t* cr, void* user_data); | |||
typedef void (*AosdMouseEventCb)(Aosd* aosd, AosdMouseEvent* event, | typedef void (*AosdMouseEventCb)(AosdMouseEvent* event, void* user_data); | |||
void* user_data); | ||||
typedef enum | typedef enum | |||
{ | { | |||
TRANSPARENCY_NONE = 0, | TRANSPARENCY_NONE = 0, | |||
TRANSPARENCY_FAKE, | TRANSPARENCY_FAKE, | |||
TRANSPARENCY_COMPOSITE | TRANSPARENCY_COMPOSITE | |||
} AosdTransparency; | } AosdTransparency; | |||
/* object (de)allocators */ | /* object (de)allocators */ | |||
Aosd* aosd_new(void); | Aosd* aosd_new(void); | |||
void aosd_destroy(Aosd* aosd); | void aosd_destroy(Aosd* aosd); | |||
/* object inspectors */ | /* object inspectors */ | |||
void aosd_get_name(Aosd* aosd, XClassHint* result); | void aosd_get_name(Aosd* aosd, XClassHint* result); | |||
void aosd_get_names(Aosd* aosd, char** res_name, char** res_class); | ||||
AosdTransparency aosd_get_transparency(Aosd* aosd); | AosdTransparency aosd_get_transparency(Aosd* aosd); | |||
void aosd_get_geometry(Aosd* aosd, int* x, int* y, int* width, int* height) ; | void aosd_get_geometry(Aosd* aosd, int* x, int* y, int* width, int* height) ; | |||
void aosd_get_screen_size(Aosd* aosd, int* width, int* height); | ||||
Bool aosd_get_is_shown(Aosd* aosd); | ||||
/* object configurators */ | /* object configurators */ | |||
void aosd_set_name(Aosd* aosd, XClassHint* name); | void aosd_set_name(Aosd* aosd, XClassHint* name); | |||
void aosd_set_names(Aosd* aosd, char* res_name, char* res_class); | ||||
void aosd_set_transparency(Aosd* aosd, AosdTransparency mode); | void aosd_set_transparency(Aosd* aosd, AosdTransparency mode); | |||
void aosd_set_geometry(Aosd* aosd, int x, int y, int width, int height); | void aosd_set_geometry(Aosd* aosd, int x, int y, int width, int height); | |||
void aosd_set_renderer(Aosd* aosd, AosdRenderer renderer, void* user_data, | void aosd_set_position(Aosd* aosd, unsigned pos, int width, int height); | |||
void (*user_data_d)(void*)); | void aosd_set_position_offset(Aosd* aosd, int x_offset, int y_offset); | |||
void aosd_set_position_with_offset(Aosd* aosd, | ||||
AosdCoordinate abscissa, AosdCoordinate ordinate, int width, int height | ||||
, | ||||
int x_offset, int y_offset); | ||||
void aosd_set_renderer(Aosd* aosd, AosdRenderer renderer, void* user_data); | ||||
void aosd_set_mouse_event_cb(Aosd* aosd, AosdMouseEventCb cb, void* user_da ta); | void aosd_set_mouse_event_cb(Aosd* aosd, AosdMouseEventCb cb, void* user_da ta); | |||
void aosd_set_hide_upon_mouse_event(Aosd* aosd, Bool enable); | ||||
/* manual object manipulators */ | /* object manipulators */ | |||
void aosd_render(Aosd* aosd); | void aosd_render(Aosd* aosd); | |||
void aosd_show(Aosd* aosd); | void aosd_show(Aosd* aosd); | |||
void aosd_hide(Aosd* aosd); | void aosd_hide(Aosd* aosd); | |||
/* automatic object manipulators */ | /* X main loop processing */ | |||
void aosd_main_iterations(Aosd* aosd); | void aosd_loop_once(Aosd* aosd); | |||
void aosd_main_until(Aosd* aosd, struct timeval* until); | void aosd_loop_for(Aosd* aosd, unsigned loop_ms); | |||
void aosd_flash(Aosd* aosd, int fade_ms, int total_display_ms); | ||||
/* automatic object manipulator */ | ||||
void aosd_flash(Aosd* aosd, unsigned fade_in_ms, | ||||
unsigned full_ms, unsigned fade_out_ms); | ||||
#ifdef __cplusplus | ||||
} | ||||
#endif | ||||
#endif /* __AOSD_H__ */ | #endif /* __AOSD_H__ */ | |||
/* vim: set ts=2 sw=2 et : */ | /* vim: set ts=2 sw=2 et : */ | |||
End of changes. 11 change blocks. | ||||
14 lines changed or deleted | 36 lines changed or added | |||