mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 06:46:00 +01:00
Draw marked area
This commit draws an rectangle in the marked area.
This commit is contained in:
parent
7007394634
commit
6e0616d35b
2 changed files with 33 additions and 0 deletions
|
@ -41,6 +41,7 @@ static const char recolor_darkcolor[] = "#353535";
|
||||||
static const char recolor_lightcolor[] = "#DBDBDB";
|
static const char recolor_lightcolor[] = "#DBDBDB";
|
||||||
|
|
||||||
static const char search_highlight[] = "#9FBC00";
|
static const char search_highlight[] = "#9FBC00";
|
||||||
|
static const char select_text[] = "#000000";
|
||||||
|
|
||||||
/* statusbar */
|
/* statusbar */
|
||||||
static const char DEFAULT_TEXT[] = "[No Name]";
|
static const char DEFAULT_TEXT[] = "[No Name]";
|
||||||
|
|
32
zathura.c
32
zathura.c
|
@ -185,6 +185,7 @@ struct
|
||||||
GdkColor recolor_darkcolor;
|
GdkColor recolor_darkcolor;
|
||||||
GdkColor recolor_lightcolor;
|
GdkColor recolor_lightcolor;
|
||||||
GdkColor search_highlight;
|
GdkColor search_highlight;
|
||||||
|
GdkColor select_text;
|
||||||
PangoFontDescription *font;
|
PangoFontDescription *font;
|
||||||
} Style;
|
} Style;
|
||||||
|
|
||||||
|
@ -203,6 +204,12 @@ struct
|
||||||
int adjust_mode;
|
int adjust_mode;
|
||||||
} Global;
|
} Global;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
gdouble x;
|
||||||
|
gdouble y;
|
||||||
|
} SelectPoint;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
char* filename;
|
char* filename;
|
||||||
|
@ -250,6 +257,7 @@ struct
|
||||||
GStaticMutex pdflib_lock;
|
GStaticMutex pdflib_lock;
|
||||||
GStaticMutex pdf_obj_lock;
|
GStaticMutex pdf_obj_lock;
|
||||||
GStaticMutex search_lock;
|
GStaticMutex search_lock;
|
||||||
|
GStaticMutex select_lock;
|
||||||
} Lock;
|
} Lock;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
@ -408,6 +416,7 @@ init_zathura()
|
||||||
g_static_mutex_init(&(Zathura.Lock.pdflib_lock));
|
g_static_mutex_init(&(Zathura.Lock.pdflib_lock));
|
||||||
g_static_mutex_init(&(Zathura.Lock.search_lock));
|
g_static_mutex_init(&(Zathura.Lock.search_lock));
|
||||||
g_static_mutex_init(&(Zathura.Lock.pdf_obj_lock));
|
g_static_mutex_init(&(Zathura.Lock.pdf_obj_lock));
|
||||||
|
g_static_mutex_init(&(Zathura.Lock.select_lock));
|
||||||
|
|
||||||
/* look */
|
/* look */
|
||||||
gdk_color_parse(default_fgcolor, &(Zathura.Style.default_fg));
|
gdk_color_parse(default_fgcolor, &(Zathura.Style.default_fg));
|
||||||
|
@ -429,6 +438,7 @@ init_zathura()
|
||||||
gdk_color_parse(recolor_darkcolor, &(Zathura.Style.recolor_darkcolor));
|
gdk_color_parse(recolor_darkcolor, &(Zathura.Style.recolor_darkcolor));
|
||||||
gdk_color_parse(recolor_lightcolor, &(Zathura.Style.recolor_lightcolor));
|
gdk_color_parse(recolor_lightcolor, &(Zathura.Style.recolor_lightcolor));
|
||||||
gdk_color_parse(search_highlight, &(Zathura.Style.search_highlight));
|
gdk_color_parse(search_highlight, &(Zathura.Style.search_highlight));
|
||||||
|
gdk_color_parse(select_text, &(Zathura.Style.select_text));
|
||||||
Zathura.Style.font = pango_font_description_from_string(font);
|
Zathura.Style.font = pango_font_description_from_string(font);
|
||||||
|
|
||||||
/* other */
|
/* other */
|
||||||
|
@ -3334,12 +3344,34 @@ cb_view_button_pressed(GtkWidget* widget, GdkEventButton* event, gpointer data)
|
||||||
if(!Zathura.PDF.document)
|
if(!Zathura.PDF.document)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
/* clean page */
|
||||||
|
draw(Zathura.PDF.page_number);
|
||||||
|
g_static_mutex_lock(&(Zathura.Lock.select_lock));
|
||||||
|
Zathura.SelectPoint.x = event->x;
|
||||||
|
Zathura.SelectPoint.y = event->y;
|
||||||
|
g_static_mutex_unlock(&(Zathura.Lock.select_lock));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cb_view_button_release(GtkWidget* widget, GdkEventButton* event, gpointer data)
|
cb_view_button_release(GtkWidget* widget, GdkEventButton* event, gpointer data)
|
||||||
{
|
{
|
||||||
|
if(!Zathura.PDF.document)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
g_static_mutex_lock(&(Zathura.Lock.select_lock));
|
||||||
|
cairo_t *cairo = cairo_create(Zathura.PDF.surface);
|
||||||
|
cairo_set_source_rgba(cairo, Zathura.Style.select_text.red, Zathura.Style.select_text.green,
|
||||||
|
Zathura.Style.select_text.blue, TRANSPARENCY);
|
||||||
|
|
||||||
|
cairo_rectangle(cairo, event->x, event->y, (Zathura.SelectPoint.x - event->x),
|
||||||
|
(Zathura.SelectPoint.y - event->y));
|
||||||
|
cairo_fill(cairo);
|
||||||
|
g_static_mutex_unlock(&(Zathura.Lock.select_lock));
|
||||||
|
gtk_widget_queue_draw(Zathura.UI.drawing_area);
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue