mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 11:46:01 +01:00
fix the coordinate system
This commit is contained in:
parent
52775364f7
commit
6045e46069
3 changed files with 16 additions and 14 deletions
|
@ -77,7 +77,9 @@ zathura_image_buffer_t* zathura_image_buffer_create(unsigned int width, unsigned
|
|||
void zathura_image_buffer_free(zathura_image_buffer_t*);
|
||||
|
||||
/**
|
||||
* Rectangle structure
|
||||
* Rectangle structure.
|
||||
* The coordinate system has its origin in the left upper corner. The x axes
|
||||
* goes to the right, the y access goes down.
|
||||
*/
|
||||
typedef struct zathura_rectangle_s
|
||||
{
|
||||
|
|
|
@ -292,7 +292,7 @@ zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event)
|
|||
/* draw text */
|
||||
cairo_set_source_rgba(cairo, 0, 0, 0, 1);
|
||||
cairo_set_font_size(cairo, 10);
|
||||
cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y1 - 1);
|
||||
cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y2 - 1);
|
||||
char* link_number = g_strdup_printf("%i", priv->link_offset + ++link_counter);
|
||||
cairo_show_text(cairo, link_number);
|
||||
g_free(link_number);
|
||||
|
@ -384,9 +384,9 @@ redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle)
|
|||
/* cause the rect to be drawn */
|
||||
GdkRectangle grect;
|
||||
grect.x = rectangle->x1;
|
||||
grect.y = rectangle->y2;
|
||||
grect.y = rectangle->y1;
|
||||
grect.width = rectangle->x2 - rectangle->x1;
|
||||
grect.height = rectangle->y1 - rectangle->y2;
|
||||
grect.height = rectangle->y2 - rectangle->y1;
|
||||
gdk_window_invalidate_rect(GTK_WIDGET(widget)->window, &grect, TRUE);
|
||||
}
|
||||
|
||||
|
|
20
utils.c
20
utils.c
|
@ -200,28 +200,28 @@ recalc_rectangle(zathura_page_t* page, zathura_rectangle_t rectangle)
|
|||
|
||||
switch (page->document->rotate) {
|
||||
case 90:
|
||||
tmp.x1 = rectangle.y2 * page->document->scale;
|
||||
tmp.x2 = rectangle.y1 * page->document->scale;
|
||||
tmp.x1 = (page->height - rectangle.y2) * page->document->scale;
|
||||
tmp.x2 = (page->height - rectangle.y1) * page->document->scale;
|
||||
tmp.y1 = rectangle.x1 * page->document->scale;
|
||||
tmp.y2 = rectangle.x2 * page->document->scale;
|
||||
break;
|
||||
case 180:
|
||||
tmp.x1 = (page->width - rectangle.x2) * page->document->scale;
|
||||
tmp.x2 = (page->width - rectangle.x1) * page->document->scale;
|
||||
tmp.y1 = rectangle.y2 * page->document->scale;
|
||||
tmp.y2 = rectangle.y1 * page->document->scale;
|
||||
tmp.y1 = (page->height - rectangle.y2) * page->document->scale;
|
||||
tmp.y2 = (page->height - rectangle.y1) * page->document->scale;
|
||||
break;
|
||||
case 270:
|
||||
tmp.x1 = (page->height - rectangle.y1) * page->document->scale;
|
||||
tmp.x2 = (page->height - rectangle.y2) * page->document->scale;
|
||||
tmp.y1 = (page->width - rectangle.x2) * page->document->scale;
|
||||
tmp.y2 = (page->width - rectangle.x1) * page->document->scale;
|
||||
tmp.x1 = rectangle.y1 * page->document->scale;
|
||||
tmp.x2 = rectangle.y2 * page->document->scale;
|
||||
tmp.y1 = (page->width - rectangle.x2) * page->document->scale;
|
||||
tmp.y2 = (page->width - rectangle.x1) * page->document->scale;
|
||||
break;
|
||||
default:
|
||||
tmp.x1 = rectangle.x1 * page->document->scale;
|
||||
tmp.x2 = rectangle.x2 * page->document->scale;
|
||||
tmp.y1 = (page->height - rectangle.y1) * page->document->scale;
|
||||
tmp.y2 = (page->height - rectangle.y2) * page->document->scale;
|
||||
tmp.y1 = rectangle.y1 * page->document->scale;
|
||||
tmp.y2 = rectangle.y2 * page->document->scale;
|
||||
}
|
||||
|
||||
return tmp;
|
||||
|
|
Loading…
Reference in a new issue