Ejemplo n.º 1
0
static VALUE
cr_rel_move_to (VALUE self, VALUE x, VALUE y)
{
  cairo_rel_move_to (_SELF, NUM2DBL (x), NUM2DBL (y));
  cr_check_status (_SELF);
  return self;
}
Ejemplo n.º 2
0
/* ...draw multiline string - hmm; need to put that stuff into display */
static inline void draw_string(cairo_t *cr, const char *fmt, ...)
{
	char                    buffer[4096], *p, *end;
	cairo_text_extents_t    text_extents;
	cairo_font_extents_t    font_extents;
	va_list                 argp;

	cairo_save(cr);
	cairo_select_font_face(cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	cairo_set_font_size(cr, 40);
	cairo_font_extents(cr, &font_extents);

	va_start(argp, fmt);
	vsnprintf(buffer, sizeof(buffer), fmt, argp);
	va_end(argp);

    for (p = buffer; *p; p = end + 1)
    {
        /* ...output single line */
		((end = strchr(p, '\n')) != NULL ? *end = 0 : 0);
		cairo_show_text(cr, p);
		cairo_text_extents (cr, p, &text_extents);
		cairo_rel_move_to (cr, -text_extents.x_advance, font_extents.height);
        TRACE(0, _b("print text-line: <%f,%f>"), text_extents.x_advance, font_extents.height);

        /* ...stop when last line processes */
        if (!end)   break;
    }

    /* ...restore drawing context */
	cairo_restore(cr);
}
Ejemplo n.º 3
0
static void
add_rectangle (cairo_t *cr, double size)
{
    double x, y;

    if (size < 1)
	return;

    cairo_get_current_point (cr, &x, &y);

    cairo_rel_move_to (cr, -size/2., -size/2.);
    cairo_rel_line_to (cr, size, 0);
    cairo_rel_line_to (cr, 0, size);
    cairo_rel_line_to (cr, -size, 0);
    cairo_close_path (cr);

    cairo_save (cr);
    cairo_translate (cr, -size/2., size);
    cairo_move_to (cr, x, y);
    cairo_rotate (cr, M_PI/4);
    add_rectangle (cr, size / M_SQRT2);
    cairo_restore (cr);

    cairo_save (cr);
    cairo_translate (cr, size/2., size);
    cairo_move_to (cr, x, y);
    cairo_rotate (cr, -M_PI/4);
    add_rectangle (cr, size / M_SQRT2);
    cairo_restore (cr);
}
Ejemplo n.º 4
0
// cairo_public void
// cairo_rel_move_to (cairo_t *cr,
//              double dx, double dy);
static int l_cairo_rel_move_to(lua_State* L)
{
    cairo_t *cr = get_cairo_t (L, 1);
    double dx = luaL_checknumber(L, 2);
    double dy = luaL_checknumber(L, 3);
    cairo_rel_move_to(cr, dx, dy);
    return 0;
}
Ejemplo n.º 5
0
static int info_split_printf(ToolWin *tw, char *bold, char *fmt, ...) {
	char str[MAX_STRING];
	va_list arg;
	va_start(arg, fmt);
	vsprintf(str, fmt, arg);
	va_end(arg);
	cairo_set_font_face(tw->ctx, conf.bfont);
	cairo_text_extents(tw->ctx,bold,&ext);
	cairo_rel_move_to(tw->ctx, MARGIN, conf.font_size);
	cairo_show_text(tw->ctx,bold);
	cairo_rel_move_to(tw->ctx, -1.0 * ext.x_advance - MARGIN, 0);
	cairo_set_font_face(tw->ctx, conf.font);
	cairo_text_extents(tw->ctx,str,&ext);
	cairo_rel_move_to(tw->ctx, tw->w - ext.x_advance - MARGIN, 0);
	cairo_show_text(tw->ctx,str);
	cairo_rel_move_to(tw->ctx, MARGIN - tw->w, conf.font_size / 3.0);
	return 0;
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRelMoveTo 
   (JNIEnv *env, jobject obj, jdouble dx, jdouble dy)
{
  struct graphics2d *gr = NULL;
  gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
  g_assert (gr != NULL);
  if (gr->debug) printf ("cairo_rel_move_to (%f, %f)\n", dx, dy);
  cairo_rel_move_to (gr->cr, dx, dy);
}
Ejemplo n.º 7
0
static void
relative_move(cairo_t *cr, double x, double y)
{
  if (cairo_has_current_point(cr)) {
    cairo_rel_move_to(cr, x, y);
  } else {
    cairo_move_to(cr, x, y);
  }
}
Ejemplo n.º 8
0
static int ui_rel_move_to(lua_State *L)
{
	struct context *c = lua_touserdata(L, 1);

	cairo_rel_move_to(c->cr,
			  lua_tonumber(L, 2),
			  lua_tonumber(L, 3));
	return 0;
}
Ejemplo n.º 9
0
static int cairo_rel_move_to_l( lua_State* L )
{
  lua_cairo_t* lc = lua_cairo_check( L, 1 );

  cairo_rel_move_to( lc->cairo,
                     luaL_checknumber( L, 2 ),   /* dx */
                     luaL_checknumber( L, 3 ) ); /* dy */

  return( 0 );
}
Ejemplo n.º 10
0
static PyObject *
pycairo_rel_move_to (PycairoContext *o, PyObject *args) {
  double dx, dy;

  if (!PyArg_ParseTuple (args, "dd:Context.rel_move_to", &dx, &dy))
    return NULL;

  cairo_rel_move_to (o->ctx, dx, dy);
  RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
  Py_RETURN_NONE;
}
Ejemplo n.º 11
0
Archivo: te.c Proyecto: ITikhonov/tem
static gboolean on_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
	cairo_t *cr = gdk_cairo_create (widget->window);
	PangoLayout *p=pango_cairo_create_layout(cr);
	PangoFontDescription *desc=pango_font_description_from_string("Courier 12");
	pango_layout_set_font_description(p,desc);
	pango_font_description_free(desc);

	int w,h;
	pango_layout_set_text(p,"0",1);
	pango_layout_get_size(p,&w,&h);
	w/=PANGO_SCALE;
	h/=PANGO_SCALE;

	if(cursor<20*80 && cursor>=0) {
		cairo_save(cr);
		cairo_set_source_rgb(cr,0,0.8,0);
		cairo_rectangle(cr,(cursor%80+1)*w,(cursor/80+1)*h,w,h);
		cairo_fill(cr);
		cairo_restore(cr);
	}

	cairo_move_to(cr,w,h);

	int i;
	for(i=0;i<20;i++) {
		pango_layout_set_text(p,viewbuf+80*i,80);
		pango_cairo_update_layout(cr,p);
		pango_cairo_show_layout(cr,p);
		cairo_rel_move_to(cr,0,h);
	}

	cairo_move_to(cr,w*81+w/2,h);
	cairo_rel_line_to(cr,0,h*20);
	cairo_line_to(cr,w,h*21);
	cairo_stroke(cr);


	for(i=0;i<512;i++) {
#ifndef VIEWA4
		int32_t v=sounds[lastsound][i*8];
		cairo_rectangle(cr,w+i,h*30, 1,5*h*(v/32767.0));
#else
		int32_t v=resample(lastsound,51,i);
		cairo_rectangle(cr,w+i,h*30, 1,5*h*(v/32767.0));
#endif
	}
	cairo_fill(cr);
	g_object_unref(p);


	cairo_destroy(cr);
	return FALSE;
}
static PyObject *
pycairo_rel_move_to (PycairoContext *o, PyObject *args)
{
    double dx, dy;

    if (!PyArg_ParseTuple (args, "dd:Context.rel_move_to", &dx, &dy))
	return NULL;

    cairo_rel_move_to (o->ctx, dx, dy);
    if (Pycairo_Check_Status (cairo_status (o->ctx)))
	return NULL;
    Py_RETURN_NONE;
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRelMoveTo 
   (JNIEnv *env, jobject obj, jdouble dx, jdouble dy)
{
  struct graphics2d *gr = NULL;

  gdk_threads_enter();
  if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }

  gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
  g_assert (gr != NULL);
  if (gr->debug) printf ("cairo_rel_move_to (%f, %f)\n", dx, dy);
  cairo_rel_move_to (gr->cr, dx, dy);
  gdk_threads_leave();
}
Ejemplo n.º 14
0
ETERM * rel_move_to(ETERM* arg, int c_node) {
    ETERM *x, *y;
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) {
        x = erl_element(2, arg);  
        y = erl_element(3, arg); 
        cairo_rel_move_to(ctx->cr, val(x), val(y));
        erl_free_term(x);
        erl_free_term(y);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
Ejemplo n.º 15
0
static int info_draw(ToolWin *tw) {
	toolwin_backing(tw);
	/* info */
	cairo_set_source_rgba(tw->ctx,0,0,0,1.0);
	cairo_set_font_face(tw->ctx, conf.bfont);
	cairo_move_to(tw->ctx, 0, 8);
	info_printf(tw, A_CENTER, "%.3lf sec, %.2lf KHz",
			spect->fft->time[mx],spect->fft->freq[my]);
	cairo_rel_move_to(tw->ctx,0,12);
	info_split_printf(tw, "Threshold:", "%.2lf", -1.0 * conf.thresh);
	info_split_printf(tw, "Spectrogram Floor:", "%.2lf",
			-1.0 * conf.spect_floor);
	info_split_printf(tw, "Path Length:","%.2lf", spect->pex);
	info_split_printf(tw, "Path Duration:","%.3lf", spect->tex);
	info_split_printf(tw, "Frequency Excursion:","%.3lf", spect->fex);
	cairo_move_to(tw->ctx, 0, 145);
	/* modes */
	info_split_printf(tw, "Modes:","");
	cairo_set_font_face(tw->ctx, conf.bfont);
		/* erase */
	set_color(tw->ctx,RGBA_ERASE1)
	if (mode & MODE_ERASE) set_color(tw->ctx,RGBA_ERASE1)
	else cairo_set_source_rgba(tw->ctx,0.8,0.8,0.8,1.0);
	cairo_rectangle(tw->ctx, 10, 170, tw->w / 2.0 - 15, 20);
	cairo_fill_preserve(tw->ctx);
	cairo_set_source_rgba(tw->ctx,0,0,0,1.0);
	cairo_stroke(tw->ctx);
	cairo_text_extents(tw->ctx,"Erase",&ext);
	cairo_move_to(tw->ctx, tw->w / 4.0 - ext.width / 2.0, 185);
	cairo_set_source_rgba(tw->ctx,0,0,0,1.0);
	cairo_show_text(tw->ctx,"Erase");
		/* crop */
	if (mode & MODE_CROP) set_color(tw->ctx, RGBA_CROP)
	else cairo_set_source_rgba(tw->ctx,0.8,0.8,0.8,1.0);
	cairo_rectangle(tw->ctx, 5 + tw->w / 2.0, 170, tw->w / 2.0 - 15, 20);
	cairo_fill_preserve(tw->ctx);
	cairo_set_source_rgba(tw->ctx,0.0,0.0,0.0,1.0);
	cairo_stroke(tw->ctx);
	cairo_text_extents(tw->ctx,"Crop",&ext);
	cairo_move_to(tw->ctx, tw->w * 0.75 - ext.width / 2.0, 185);
	cairo_set_source_rgba(tw->ctx,0,0,0,1.0);
	cairo_show_text(tw->ctx,"Crop");
	/* draw */
	toolwin_draw(tw);
	return 0;
}
Ejemplo n.º 16
0
static void
draw_string(cairo_t *cr,
	    const char *fmt, ...)
{
	char buffer[4096];
	char *p, *end;
	va_list argp;
	cairo_text_extents_t text_extents;
	cairo_font_extents_t font_extents;

	cairo_save(cr);

	cairo_select_font_face(cr, "sans",
			       CAIRO_FONT_SLANT_NORMAL,
			       CAIRO_FONT_WEIGHT_NORMAL);
	cairo_set_font_size(cr, 14);

	cairo_font_extents (cr, &font_extents);

	va_start(argp, fmt);

	vsnprintf(buffer, sizeof(buffer), fmt, argp);

	p = buffer;
	while (*p) {
		end = strchr(p, '\n');
		if (end)
			*end = 0;

		cairo_show_text(cr, p);
		cairo_text_extents (cr, p, &text_extents);
		cairo_rel_move_to (cr, -text_extents.x_advance, font_extents.height);

		if (end)
			p = end + 1;
		else
			break;
	}

	va_end(argp);

	cairo_restore(cr);

}
Ejemplo n.º 17
0
/**
 * igt_cairo_printf_line:
 * @cr: cairo drawing context
 * @align: text alignment
 * @yspacing: additional y-direction feed after this line
 * @fmt: format string
 * @...: optional arguments used in the format string
 *
 * This is a little helper to draw text onto framebuffers. All the initial setup
 * (like setting the font size and the moving to the starting position) still
 * needs to be done manually with explicit cairo calls on @cr.
 *
 * Returns:
 * The width of the drawn text.
 */
int igt_cairo_printf_line(cairo_t *cr, enum igt_text_align align,
				double yspacing, const char *fmt, ...)
{
	double x, y, xofs, yofs;
	cairo_text_extents_t extents;
	char *text;
	va_list ap;
	int ret;

	va_start(ap, fmt);
	ret = vasprintf(&text, fmt, ap);
	igt_assert(ret >= 0);
	va_end(ap);

	cairo_text_extents(cr, text, &extents);

	xofs = yofs = 0;
	if (align & align_right)
		xofs = -extents.width;
	else if (align & align_hcenter)
		xofs = -extents.width / 2;

	if (align & align_top)
		yofs = extents.height;
	else if (align & align_vcenter)
		yofs = extents.height / 2;

	cairo_get_current_point(cr, &x, &y);
	if (xofs || yofs)
		cairo_rel_move_to(cr, xofs, yofs);

	cairo_text_path(cr, text);
	cairo_set_source_rgb(cr, 0, 0, 0);
	cairo_stroke_preserve(cr);
	cairo_set_source_rgb(cr, 1, 1, 1);
	cairo_fill(cr);

	cairo_move_to(cr, x, y + extents.height + yspacing);

	free(text);

	return extents.width;
}
Ejemplo n.º 18
0
static void
mini_svg_shape_renderer (cairo_t        *cr,
			 PangoAttrShape *attr,
			 gboolean        do_path,
			 gpointer        data G_GNUC_UNUSED)
{
  MiniSvg *shape = (MiniSvg *) attr->data;
  double scale_x, scale_y;

  scale_x = (double) attr->ink_rect.width  / (PANGO_SCALE * shape->width );
  scale_y = (double) attr->ink_rect.height / (PANGO_SCALE * shape->height);

  cairo_rel_move_to (cr,
		     (double) attr->ink_rect.x / PANGO_SCALE,
		     (double) attr->ink_rect.y / PANGO_SCALE);
  cairo_scale (cr, scale_x, scale_y);

  mini_svg_render (shape, cr, do_path);
}
Ejemplo n.º 19
0
Archivo: world.c Proyecto: icule/CLE
/* Functions related to drawing */
void world_redraw(core_world_t we, cairo_t *c,int sizeX,int sizeY) {
	int it;
	world_t w = (world_t)we;
	cairo_t *cr = (cairo_t*)c;
	double ratioX = sizeX/w->mother.sizeX;
	double ratioY = sizeY/w->mother.sizeY;
	double ratio = ratioX>ratioY?ratioY:ratioX;

    // grey background everywhere
    cairo_set_source_rgb( cr, 0, 0, .8 );
    cairo_fill(cr);

    // Adapt to the size of the world
	cairo_translate(cr, fabs(sizeX-ratio*w->mother.sizeX)/2., fabs(sizeY-ratio*w->mother.sizeY)/2.);
    cairo_scale(cr, ratio, ratio);

    // white background to the usefull surface
    cairo_set_source_rgb( cr, 1, 1, 1 );
    cairo_rectangle (cr, 0, 0, w->mother.sizeX, w->mother.sizeY);
    //cairo_set_source_rgba (cr, 1, 0, 0, 0.80);
    cairo_fill (cr);

    cairo_set_source_rgb( cr, 0, 0, 0 );

    /* Draw the lines */
    for (it=0;it<w->amount_lines;it++) {
        cairo_move_to(cr, w->lines[it].x1, w->lines[it].y1);
    	cairo_line_to(cr, w->lines[it].x2, w->lines[it].y2);
    	cairo_stroke(cr);
    }

    /* Draw the turtles */
    entity_t t;
    world_foreach_entity(we,it,t) {
    	cairo_move_to(cr, entity_get_x(t), entity_get_y(t));
    	cairo_rotate(cr,entity_get_heading(t));
    	cairo_rel_move_to(cr,10,0);
    	cairo_rel_line_to(cr,-10,-5);
    	cairo_rel_line_to(cr,0,10);
    	cairo_close_path(cr);
    	cairo_fill(cr);
    	cairo_rotate(cr,-entity_get_heading(t));
    }
Ejemplo n.º 20
0
void draw_circle(cairo_t *cr, double x, double y, int num){
  // Draw circumference
  cairo_set_line_width(cr, 5);  
  set_color_arc(cr);
  cairo_translate(cr, x, y);
  cairo_arc(cr, 0, 0, 20, 0, 2 * M_PI);
  cairo_stroke_preserve(cr);

  // Fill
  set_color_circle(cr);
  cairo_fill(cr);

  // Label it.
  set_color_black(cr);
  char label[5];
  snprintf(label, 10, "%d", num);
  cairo_move_to(cr, -12, 8);
  cairo_show_text(cr, label);
  cairo_rel_move_to(cr, 12, -8);
  cairo_fill(cr);

}
Ejemplo n.º 21
0
	void lime_cairo_rel_move_to (value handle, double dx, double dy) {
		
		cairo_rel_move_to ((cairo_t*)val_data (handle), dx, dy);
		
	}
Ejemplo n.º 22
0
/*==================================================================================
 psrmov - subroutine to make a relative move
 ==================================================================================*/
void psrmov_ (double *dx, double *dy) {
	DEBUGPRINT(("In psrmov. delta= (%f, %f), device=(%f, %f)\n", *dx, *dy,deviceW(*dx), deviceH(*dy)));
	dmh_inRelProcess = 1;
	cairo_rel_move_to(dmh_cr, deviceW(*dx), -deviceH(*dy));	/* negative is due to flipped Cairo coordinates */
}
Ejemplo n.º 23
0
/*==================================================================================
	pstext - subroutine to output text strings.

		x, y - coordinates of the label's reference point, in real coordinates (but see valign and halign, below)
		text - character string to be output
		jchar - length of meaningful character string, 0 if unknown.
		textlen - automatic argument supplied by fortran, gives allocated length of string
		valign: integer alignment code for vertical (from possibly rotated character standpoint) alignment.
			0 = top-aligned
			1 = middle-aligned
			2 = bottom-aligned
			10-12 = y should be considered a number of lines from top margin of page, then alignment=valign-10
			100-902 = valign is given by the final digit.  The y-coordinate should be calculated
				based upon the given y, but then add a number of lines to move down the page from there
				given by this code/100 (e.g., 1-9 lines)
			1000-9002 = valign is given by the final digit.  The y-coordinate should be calculated
			based upon the given y, but then add a number of lines to move up the page from there
			given by this code/1000 (e.g., 1-9 lines)
			(e.g., 202 would mean that the text should be bottom-aligned to the reference point, and 
				the y coordinate is two lines below the supplied y coordinate
		halign: integer alignment code for horizontal (from possibly rotated character standpoint) alignment.
			0 = left-aligned
			1 = center-aligned
			2 = right-aligned
			10-12 = x should be considered a number of lines from left margin of page, then alignment=halign-10
			100-9002 = halign is given by the final digit.  The x coordinate should be calculated based upon
			    the given x, but add a number of points given by this code / 100 (e.g., 1-90).
			REFERENCE_TO_TRACKED_MIN_X - REFERENCE_TO_TRACKED_MIN_X+2 = halign is given by the final digit. The
				x coordinate to be used is the tracked minimum x.
 
==================================================================================*/
void pstext_ (double *x, double *y, char *text, int *jchar, int *valign, int *halign, int textlen) {
	cairo_text_extents_t te;
	cairo_font_extents_t fe;
	cairo_matrix_t curMatrix;
	
	double userX, userY;
	double tempX, tempY;
	int valignCode, halignCode;
	int linesToMove = 0;
	double pointsToMove = 0;
	double xOffset = 0;
	double yOffset = 0;
	char *temptext=malloc(255 * sizeof(char));
	char *mytext;
	
	strncpy(temptext, text, 254);	/* copy only as many characters as will fit in value */

	if (*jchar == 0) {
		temptext[textlen]='\0';
	} else {
		temptext[*jchar]='\0';
	}
	
	mytext = trim(temptext);
	compressSpaces(mytext);
	completeRelativeOperation();

	DEBUGPRINT(("In pstext.  Pt=(%f, %f), DevPoint=(%f, %f), Text=%s, jchar=%i, textlen=%i, valign=%i, halign=%i.\n", *x, *y, deviceX(*x), deviceY(*y), mytext, *jchar, textlen, *valign, *halign));
	cairo_text_extents(dmh_cr,mytext,&te);
	cairo_font_extents (dmh_cr, &fe);
	cairo_set_source_rgb (dmh_cr, 0, 0, 0);	/* black */

	userX = deviceX(*x);	/* change coordinates from real to device */
	userY = deviceY(*y);

	if (dmh_debug) {
		tempX = userX;
		tempY = userY;
		cairo_device_to_user(dmh_cr, &tempX, &tempY);	/* need this to deal with possibly rotated transform */
		cairo_rectangle(dmh_cr, tempX-4, tempY-4, 8, 8);
		cairo_set_source_rgb (dmh_cr, 1, 0.5, 0);
		cairo_fill(dmh_cr);
		cairo_set_source_rgb (dmh_cr, 0, 0, 0);
		cairo_move_to(dmh_cr, tempX, tempY);
	}
	
	DEBUGPRINT(("In pstext.  UserPt=(%f, %f) tempPt=(%f, %f).\n", userX, userY, tempX, tempY));
	if (*valign > 9 && *valign < 100) {
		/* y should be considered a number of lines from top of page.  Note that cairo thinks the origin is at top-left */
		userY = TOPMARGIN + ((int)*y * fe.height);
	} else if (*valign > 99 && *valign < 1000) {
		linesToMove = *valign / 100;
	} else if (*valign > 990 && *valign < 10000) {
		linesToMove = -(*valign / 1000);
	}
	DEBUGPRINT(("In pstext.  LinesToMove=%i.\n", linesToMove));
	if (*halign > 9 && *halign < 100) {
		/* x should be considered a number of lines from top of page.  Note that cairo thinks the origin is at top-left */
		userX = LEFTMARGIN + ((int)*x * fe.height);
	} else if (*halign > 99 && *halign < 10000) {
		pointsToMove = (*halign)/100;
	} else if (*halign >= REFERENCE_TO_TRACKED_MIN_X && *halign <= REFERENCE_TO_TRACKED_MIN_X+2) {
		userX = dmh_min_tracked_x;
		dmh_min_tracked_x = DBL_MAX;	/* Now turn off tracking */
		dmh_track_min_x = 0;
	}

	DEBUGPRINT(("In pstext.  UserPt=(%f, %f).\n", userX, userY));
	cairo_device_to_user(dmh_cr, &userX, &userY);	/* need this to deal with possibly rotated transform */
	cairo_move_to(dmh_cr, userX, userY);
	if (linesToMove != 0) {
		cairo_rel_move_to(dmh_cr, 0, linesToMove * fe.height);
	}
	
	if (pointsToMove != 0) {
		cairo_rel_move_to(dmh_cr, pointsToMove, 0);
	}
	
	if (dmh_debug) {
		cairo_get_current_point(dmh_cr, &tempX, &tempY);
		cairo_rectangle(dmh_cr, tempX-2, tempY-2, 4, 4);
		cairo_set_source_rgb (dmh_cr, 0, 0.5, 1);
		cairo_fill(dmh_cr);
		cairo_set_source_rgb (dmh_cr, 0, 0, 0);
		cairo_move_to(dmh_cr, tempX, tempY);
	}

	valignCode = *valign % 10;
	halignCode = *halign % 10;
	switch (valignCode) {
		case 0:	/* Top-aligned */
			yOffset = te.height + EXTRASPACEPTS;
			break;
		case 1:	/* Middle-aligned */
			yOffset = te.height * 0.5;
			break;
		case 2:	/* Bottom-aligned */
			yOffset = -EXTRASPACEPTS;
			break;
	}

	switch (halignCode) {
		case 0:	/* Left-aligned */
			xOffset = EXTRASPACEPTS;
			break;
		case 1:	/* Center-aligned */
			xOffset = -te.width * 0.5;
			break;
		case 2:	/* Right-aligned */
			xOffset = -te.width - EXTRASPACEPTS;
			break;
	}
	DEBUGPRINT(("In pstext.  Offset=(%f, %f).\n", xOffset, yOffset));
	cairo_rel_move_to(dmh_cr, xOffset, yOffset);

	if (dmh_debug) {
		cairo_get_current_point(dmh_cr, &tempX, &tempY);
		cairo_rectangle(dmh_cr, tempX-2, tempY-2, 4, 4);
		cairo_set_source_rgb (dmh_cr, 1, 0, 0.5);
		cairo_fill(dmh_cr);
		cairo_set_source_rgb (dmh_cr, 0, 0, 0);
		cairo_move_to(dmh_cr, tempX, tempY);
	}

	cairo_get_matrix(dmh_cr, &curMatrix);
	DEBUGPRINT(("Current matrix: %f, %f, %f, %f, %f, %f.\n", curMatrix.xx, curMatrix.yx, curMatrix.xy, curMatrix.yy, curMatrix.x0, curMatrix.y0));

	if (dmh_track_min_x) {
		cairo_get_current_point(dmh_cr, &tempX, &tempY);
		if (tempX < dmh_min_tracked_x) {
			dmh_min_tracked_x = tempX;
		}
	}
	cairo_show_text (dmh_cr, mytext);

	DEBUGPRINT(("Status:%s\n",cairo_status_to_string(cairo_status(dmh_cr))));

	free(temptext);
}
Ejemplo n.º 24
0
static void
schgui_cairo_drafter_draw_text(SchGUICairoDrafter *drafter, const struct _SchText *text)
{
    if (text != NULL)
    {
        int visible;

        sch_text_get_visible(text, &visible);

        if (visible)
        {

    SchGUICairoDrafterPrivate *privat = SCHGUI_CAIRO_DRAFTER_GET_PRIVATE(drafter);

    if (privat->cairo != NULL)
    {
        PangoLayout *layout;
        SchMultiline *multiline = sch_text_get_multiline(text);
        int point_size = sch_text_get_size(text);
        float height;
        int alignment;
        cairo_font_options_t *options;
        PangoContext *context;
        int baseline;
        PangoLayoutIter *iter;
        int index;
        int show;
        SchGUIDrawingCfgColor color;
        int          enabled;

        sch_text_get_color(text, &index);

        enabled = schgui_drawing_cfg_get_color(privat->config, index, &color);

        if (enabled)
        {
            if (0) /* show ink rect */
            {
                GeomBounds bounds;
                int        success;

                success = schgui_cairo_drafter_text_bounds(drafter, text, &bounds);

                if (success)
                {
                    cairo_set_source_rgb(privat->cairo, 1.0, 0, 0);
                
                    cairo_move_to(privat->cairo, bounds.min_x, bounds.min_y);
                    cairo_line_to(privat->cairo, bounds.max_x, bounds.min_y);
                
                    cairo_stroke(privat->cairo);

                    cairo_set_source_rgb(privat->cairo, 0.75, 0, 0);
                
                    cairo_move_to(privat->cairo, bounds.max_x, bounds.min_y);
                    cairo_line_to(privat->cairo, bounds.max_x, bounds.max_y);
                    cairo_line_to(privat->cairo, bounds.min_x, bounds.max_y);
                    cairo_line_to(privat->cairo, bounds.min_x, bounds.min_y);
                    //cairo_close_path(privat->cairo);

                    cairo_stroke(privat->cairo);
                
                    cairo_set_source_rgb(privat->cairo, 0, 0, 0);
                }

                cairo_set_source_rgb(privat->cairo, 0, 0, 1.0);
                cairo_new_sub_path(privat->cairo);
                cairo_arc(privat->cairo, sch_text_get_x(text), sch_text_get_y(text), 10, 0, 2 * M_PI);
                cairo_stroke(privat->cairo);
                cairo_set_source_rgb(privat->cairo, 0, 0, 0);
            }

            cairo_save(privat->cairo);
   
            height = 1000 * point_size / 72;

            layout = pango_cairo_create_layout(privat->cairo);
            pango_cairo_context_set_resolution(pango_layout_get_context(layout), 936);

//  context = pango_layout_get_context(layout);
//  options = cairo_font_options_create ();
//  cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
//  cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_MEDIUM);
//  pango_cairo_context_set_font_options (context, options);
//  cairo_font_options_destroy (options);


            cairo_set_source_rgb(privat->cairo, color.red, color.green, color.blue);


            pango_font_description_set_size(privat->desc, point_size * PANGO_SCALE );
            pango_layout_set_spacing(layout, 40000);
        
            pango_layout_set_font_description(layout, privat->desc);

            sch_text_get_show(text, &show);
            pango_layout_set_markup(layout, sch_multiline_peek_markup(multiline, show), -1);


            PangoFontMetrics *metrics = pango_context_get_metrics(
                pango_layout_get_context(layout),
                privat->desc,
                NULL
                );

        
            cairo_move_to(privat->cairo, sch_text_get_x(text), sch_text_get_y(text));
        
            cairo_rotate(privat->cairo, M_PI * sch_text_get_angle(text) / 180);

            cairo_scale(privat->cairo, 1, -1);

            baseline = pango_layout_get_baseline(layout); 

            alignment = sch_text_get_alignment(text);
#if 1
            switch (alignment)
            {
                case 2:
                case 5:
                case 8: 
                /* upper */
                //cairo_rel_move_to(privat->cairo, 0, -pango_font_metrics_get_ascent(metrics)/(privat->zoom * PANGO_SCALE));
                //cairo_rel_move_to(privat->cairo, 0, height);
                break;

                case 1:
                case 4:
                case 7:
                    /* center */
                    cairo_rel_move_to(privat->cairo, 0, -pango_font_metrics_get_ascent(metrics)/(privat->zoom * PANGO_SCALE));
                    cairo_rel_move_to(privat->cairo, 0, height);
                    cairo_rel_move_to(privat->cairo, 0, -pango_font_metrics_get_ascent(metrics) * sch_multiline_lines(multiline)/(2 * privat->zoom * PANGO_SCALE));
                    cairo_rel_move_to(privat->cairo, 0, -pango_font_metrics_get_descent(metrics) * (sch_multiline_lines(multiline) - 1)/(2 * privat->zoom * PANGO_SCALE));
                    break;

                case 0:
                case 3:
                case 6:
                default:
                    /* lower */
                    //cairo_rel_move_to(privat->cairo, 0, -pango_font_metrics_get_ascent(metrics) * sch_multiline_lines(multiline)/(privat->zoom * PANGO_SCALE));
                    //cairo_rel_move_to(privat->cairo, 0, -pango_font_metrics_get_descent(metrics) * (sch_multiline_lines(multiline)-1)/(privat->zoom * PANGO_SCALE));
                    //cairo_rel_move_to(privat->cairo, 0, -pango_layout_get_spacing(layout) * (sch_multiline_lines(multiline)-1)/ PANGO_SCALE);
                    iter = pango_layout_get_iter(layout);
                    while (!pango_layout_iter_at_last_line(iter))
                    {
                        pango_layout_iter_next_line(iter);
                    }
                    cairo_rel_move_to(privat->cairo, 0, -pango_layout_iter_get_baseline(iter) / PANGO_SCALE);
                    pango_layout_iter_free(iter);
            }
#endif

            //g_debug("Ascent:    %d", pango_font_metrics_get_ascent(metrics));
            //g_debug("Descent:   %d", pango_font_metrics_get_descent(metrics));
            //g_debug("Spacing:   %d", pango_layout_get_spacing(layout));
            //g_debug("Font size: %d", pango_font_description_get_size(privat->desc));
            //g_debug("Baseline   %d", pango_layout_get_baseline(layout));            

            pango_font_metrics_unref(metrics);

            pango_cairo_show_layout(privat->cairo, layout);

            cairo_restore(privat->cairo);

            g_object_unref(layout);
        }
    }
}
}
 
}
Ejemplo n.º 25
0
static void
schgui_cairo_text_draw(SchGUICairoDrawItem *item, cairo_t *cairo)
{
    if (cairo != NULL)
    {
        SchGUICairoTextPrivate *privat = SCHGUI_CAIRO_TEXT_GET_PRIVATE(item);

        if (privat != NULL)
        {
            PangoLayout *layout = pango_cairo_create_layout(cairo);

            if (layout != NULL)
            {
                PangoLayoutIter *iter;
                int width;

                cairo_save(cairo);

                cairo_set_source_rgba(cairo, privat->red, privat->green, privat->blue, privat->alpha);


                pango_cairo_context_set_resolution(pango_layout_get_context(layout), 936);
                pango_layout_set_spacing(layout, 40000);
                pango_layout_set_font_description(layout, privat->font_desc);

                pango_layout_set_markup(layout, privat->markup, -1);

                cairo_move_to(cairo, privat->x, privat->y);
                cairo_rotate(cairo, privat->angle);
                cairo_scale(cairo, 1, -1);

                switch (privat->alignment)
                {
                    case 2:
                    case 5:
                    case 8: 
                        /* upper */
                        break;

                    case 1:
                    case 4:
                    case 7:
                        /* center */
                        iter = pango_layout_get_iter(layout);
                        while (!pango_layout_iter_at_last_line(iter))
                        {
                            pango_layout_iter_next_line(iter);
                        }
                        cairo_rel_move_to(cairo, 0, -pango_layout_iter_get_baseline(iter) / PANGO_SCALE / 2);
                        pango_layout_iter_free(iter);
                        break;

                    case 0:
                    case 3:
                    case 6:
                    default:
                        /* lower */
                        iter = pango_layout_get_iter(layout);
                        while (!pango_layout_iter_at_last_line(iter))
                        {
                            pango_layout_iter_next_line(iter);
                        }
                        cairo_rel_move_to(cairo, 0, -pango_layout_iter_get_baseline(iter) / PANGO_SCALE);
                        pango_layout_iter_free(iter);
                }

                switch (privat->alignment)
                {

                    case 3:
                    case 4:
                    case 5:
                        /* center */
                        pango_layout_get_size(layout, &width, NULL);
                        cairo_rel_move_to(cairo, -width / PANGO_SCALE / 2, 0);
                        break;

                    case 6:
                    case 7:
                    case 8:
                        pango_layout_get_size(layout, &width, NULL);
                        cairo_rel_move_to(cairo, -width / PANGO_SCALE, 0);
                        /* right */
                        break;

                    case 0:
                    case 1:
                    case 2:
                    default:
                        /* left */
                        ;
                }

                pango_cairo_show_layout(cairo, layout);

                cairo_restore(cairo);

                g_object_unref(layout);
            }
        }
    }
}
Ejemplo n.º 26
0
	void lime_cairo_rel_move_to (double handle, double dx, double dy) {
		
		cairo_rel_move_to ((cairo_t*)(intptr_t)handle, dx, dy);
		
	}
Ejemplo n.º 27
0
static int
cr_rel_move_to (lua_State *L) {
    cairo_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_CONTEXT);
    cairo_rel_move_to(*obj, luaL_checknumber(L, 2), luaL_checknumber(L, 3));
    return 0;
}
Ejemplo n.º 28
0
void Context::relMoveTo( double dx, double dy )
{
	cairo_rel_move_to( mCairo, dx, dy );
}
Ejemplo n.º 29
0
static void
expose_filemanager (dt_view_t *self, cairo_t *cr, int32_t width, int32_t height, int32_t pointerx, int32_t pointery)
{
  dt_library_t *lib = (dt_library_t *)self->data;

  gboolean offset_changed = FALSE;

  /* query new collection count */
  lib->collection_count = dt_collection_get_count (darktable.collection);

  if(darktable.gui->center_tooltip == 1)
    darktable.gui->center_tooltip = 2;

  /* get grid stride */
  const int iir = dt_conf_get_int("plugins/lighttable/images_in_row");

  /* get image over id */
  lib->image_over = DT_VIEW_DESERT;
  int32_t mouse_over_id, mouse_over_group = -1;
  DT_CTL_GET_GLOBAL(mouse_over_id, lib_image_mouse_over_id);

  /* fill background */
  cairo_set_source_rgb (cr, .2, .2, .2);
  cairo_paint(cr);

  if(lib->first_visible_zoomable >= 0)
  {
    lib->offset = lib->first_visible_zoomable;
  }
  lib->first_visible_zoomable = -1;

  /* check if offset has been changed */
  if(lib->track >  2) lib->offset += iir;
  if(lib->track < -2) lib->offset -= iir;
  lib->track = 0;
  if(lib->center) lib->offset = 0;
  lib->center = 0;
  int offset = lib->offset;

  /* if offset differs then flag as changed */
  if (offset != lib->first_visible_filemanager)
    offset_changed = TRUE;

  lib->first_visible_filemanager = offset;
  static int oldpan = 0;
  const int pan = lib->pan;

  const float wd = width/(float)iir;
  const float ht = width/(float)iir;

  int pi = pointerx / (float)wd;
  int pj = pointery / (float)ht;
  if(pointerx < 0 || pointery < 0) pi = pj = -1;
  //const int pidx = grid_to_index(pj, pi, iir, offset);

  const int img_pointerx = iir == 1 ? pointerx : fmodf(pointerx, wd);
  const int img_pointery = iir == 1 ? pointery : fmodf(pointery, ht);

  const int max_rows = 1 + (int)((height)/ht + .5);
  const int max_cols = iir;

  int id;
  int clicked1 = (oldpan == 0 && pan == 1 && lib->button == 1);

  /* get the count of current collection */

  if(lib->collection_count == 0)
  {
    const float fs = 15.0f;
    const float ls = 1.5f*fs;
    const float offy = height*0.2f;
    const float offx = 60;
    const float at = 0.3f;
    cairo_set_font_size(cr, fs);
    cairo_set_source_rgba(cr, .7, .7, .7, 1.0f);
    cairo_select_font_face (cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
    cairo_move_to(cr, offx, offy);
    cairo_show_text(cr, _("there are no images in this collection"));
    cairo_move_to(cr, offx, offy + 2*ls);
    cairo_show_text(cr, _("if you have not imported any images yet"));
    cairo_move_to(cr, offx, offy + 3*ls);
    cairo_show_text(cr, _("you can do so in the import module"));
    cairo_move_to(cr, offx - 10.0f, offy + 3*ls - ls*.25f);
    cairo_line_to(cr, 0.0f, 10.0f);
    cairo_set_source_rgba(cr, .7, .7, .7, at);
    cairo_stroke(cr);
    cairo_move_to(cr, offx, offy + 5*ls);
    cairo_set_source_rgba(cr, .7, .7, .7, 1.0f);
    cairo_show_text(cr, _("try to relax the filter settings in the top panel"));
    cairo_rel_move_to(cr, 10.0f, -ls*.25f);
    cairo_line_to(cr, width*0.5f, 0.0f);
    cairo_set_source_rgba(cr, .7, .7, .7, at);
    cairo_stroke(cr);
    cairo_move_to(cr, offx, offy + 6*ls);
    cairo_set_source_rgba(cr, .7, .7, .7, 1.0f);
    cairo_show_text(cr, _("or add images in the collection module in the left panel"));
    cairo_move_to(cr, offx - 10.0f, offy + 6*ls - ls*0.25f);
    cairo_rel_line_to(cr, - offx + 10.0f, 0.0f);
    cairo_set_source_rgba(cr, .7, .7, .7, at);
    cairo_stroke(cr);

    return;
  }

  /* do we have a main query collection statement */
  if(!lib->statements.main_query)
    return;

  if(offset < 0)
    lib->offset = offset = 0;

  while(offset >= lib->collection_count)
    lib->offset = (offset -= iir);

  /* update scroll borders */
  dt_view_set_scrollbar(self, 0, 1, 1, offset, lib->collection_count, max_rows*iir);

  /* let's reset and reuse the main_query statement */
  DT_DEBUG_SQLITE3_CLEAR_BINDINGS(lib->statements.main_query);
  DT_DEBUG_SQLITE3_RESET(lib->statements.main_query);

  /* setup offset and row for the main query */
  DT_DEBUG_SQLITE3_BIND_INT(lib->statements.main_query, 1, offset);
  DT_DEBUG_SQLITE3_BIND_INT(lib->statements.main_query, 2, max_rows*iir);

  if(mouse_over_id != -1)
  {
    const dt_image_t *mouse_over_image = dt_image_cache_read_get(darktable.image_cache, mouse_over_id);
    mouse_over_group = mouse_over_image->group_id;
    dt_image_cache_read_release(darktable.image_cache, mouse_over_image);
    DT_DEBUG_SQLITE3_CLEAR_BINDINGS(lib->statements.is_grouped);
    DT_DEBUG_SQLITE3_RESET(lib->statements.is_grouped);
    DT_DEBUG_SQLITE3_BIND_INT(lib->statements.is_grouped, 1, mouse_over_group);
    DT_DEBUG_SQLITE3_BIND_INT(lib->statements.is_grouped, 2, mouse_over_id);
    if(sqlite3_step(lib->statements.is_grouped) != SQLITE_ROW)
      mouse_over_group = -1;
  }

  // prefetch the ids so that we can peek into the future to see if there are adjacent images in the same group.
  int *query_ids = g_malloc0(max_rows*max_cols*sizeof(int));
  for(int row = 0; row < max_rows; row++)
  {
    for(int col = 0; col < max_cols; col++)
    {
      if(sqlite3_step(lib->statements.main_query) == SQLITE_ROW)
        query_ids[row*iir+col] = sqlite3_column_int(lib->statements.main_query, 0);
      else goto end_query_cache;
    }
  }

end_query_cache:

  cairo_save(cr);
  for(int row = 0; row < max_rows; row++)
  {
    for(int col = 0; col < max_cols; col++)
    {
      //curidx = grid_to_index(row, col, iir, offset);

      id = query_ids[row*iir+col];
      if(id > 0)
      {
        if (iir == 1 && row)
          continue;

        /* set mouse over id if pointer is in current row / col */
        if(pi == col && pj == row)
        {
          mouse_over_id = id;
          DT_CTL_SET_GLOBAL(lib_image_mouse_over_id, mouse_over_id);
        }

        /* handle mouse click on current row / col
           this could easily and preferable be moved to button_pressed()
         */
        if (clicked1 && (pi == col && pj == row))
        {
          if ((lib->modifiers & (GDK_SHIFT_MASK|GDK_CONTROL_MASK)) == 0)
            dt_selection_select_single(darktable.selection, id);
          else if ((lib->modifiers & (GDK_CONTROL_MASK)) == GDK_CONTROL_MASK)
            dt_selection_toggle(darktable.selection, id);
          else if ((lib->modifiers & (GDK_SHIFT_MASK)) == GDK_SHIFT_MASK)
            dt_selection_select_range(darktable.selection, id);
        }

        cairo_save(cr);
        // if(iir == 1) dt_image_prefetch(image, DT_IMAGE_MIPF);
        dt_view_image_expose(&(lib->image_over), id, cr, wd, iir == 1 ? height : ht, iir, img_pointerx, img_pointery);

        cairo_restore(cr);
      }
      else
        goto failure;

      cairo_translate(cr, wd, 0.0f);
    }
    cairo_translate(cr, -max_cols*wd, ht);
  }
  cairo_restore(cr);

  // and now the group borders
  for(int row = 0; row < max_rows; row++)
  {
    for(int col = 0; col < max_cols; col++)
    {
      id = query_ids[row*iir+col];
      if(id > 0)
      {
        const dt_image_t *image = dt_image_cache_read_get(darktable.image_cache, id);
        int group_id = -1;
        if(image)
          group_id = image->group_id;
        dt_image_cache_read_release(darktable.image_cache, image);

        if (iir == 1 && row)
          continue;

        cairo_save(cr);

        gboolean paint_border = FALSE;
        // regular highlight border
        if(group_id != -1)
        {
          if(mouse_over_group == group_id && iir > 1 && ((!darktable.gui->grouping && dt_conf_get_bool("plugins/lighttable/draw_group_borders")) || group_id == darktable.gui->expanded_group_id))
          {
            cairo_set_source_rgb(cr, 1, 0.8, 0);
            paint_border = TRUE;
          }
          // border of expanded group
          else if(darktable.gui->grouping && group_id == darktable.gui->expanded_group_id && iir > 1)
          {
            cairo_set_source_rgb(cr, 0, 0, 1);
            paint_border = TRUE;
          }
        }

        if(paint_border)
        {
          int neighbour_group = -1;
          // top border
          if(row > 0)
          {
            int _id = query_ids[(row-1)*iir+col];
            if(_id > 0)
            {
              const dt_image_t *_img = dt_image_cache_read_get(darktable.image_cache, _id);
              neighbour_group = _img->group_id;
              dt_image_cache_read_release(darktable.image_cache, _img);
            }
          }
          if(neighbour_group != group_id)
          {
            cairo_move_to(cr, 0, 0);
            cairo_line_to(cr, wd, 0);
          }
          // left border
          neighbour_group = -1;
          if(col > 0)
          {
            int _id = query_ids[row*iir+(col-1)];
            if(_id > 0)
            {
              const dt_image_t *_img = dt_image_cache_read_get(darktable.image_cache, _id);
              neighbour_group = _img->group_id;
              dt_image_cache_read_release(darktable.image_cache, _img);
            }
          }
          if(neighbour_group != group_id)
          {
            cairo_move_to(cr, 0, 0);
            cairo_line_to(cr, 0, ht);
          }
          // bottom border
          neighbour_group = -1;
          if(row < max_rows-1)
          {
            int _id = query_ids[(row+1)*iir+col];
            if(_id > 0)
            {
              const dt_image_t *_img = dt_image_cache_read_get(darktable.image_cache, _id);
              neighbour_group = _img->group_id;
              dt_image_cache_read_release(darktable.image_cache, _img);
            }
          }
          if(neighbour_group != group_id)
          {
            cairo_move_to(cr, 0, ht);
            cairo_line_to(cr, wd, ht);
          }
          // right border
          neighbour_group = -1;
          if(col < max_cols-1)
          {
            int _id = query_ids[row*iir+(col+1)];
            if(_id > 0)
            {
              const dt_image_t *_img = dt_image_cache_read_get(darktable.image_cache, _id);
              neighbour_group = _img->group_id;
              dt_image_cache_read_release(darktable.image_cache, _img);
            }
          }
          if(neighbour_group != group_id)
          {
            cairo_move_to(cr, wd, 0);
            cairo_line_to(cr, wd, ht);
          }
          cairo_set_line_width(cr, 0.01*wd);
          cairo_stroke(cr);
        }

        cairo_restore(cr);
      }
      else
        goto failure;

      cairo_translate(cr, wd, 0.0f);
    }
    cairo_translate(cr, -max_cols*wd, ht);
  }

  /* check if offset was changed and we need to prefetch thumbs */
  if (offset_changed)
  {
    int32_t imgids_num = 0;
    const int prefetchrows = .5*max_rows+1;
    int32_t imgids[prefetchrows*iir];
    /* clear and reset main query */
    DT_DEBUG_SQLITE3_CLEAR_BINDINGS(lib->statements.main_query);
    DT_DEBUG_SQLITE3_RESET(lib->statements.main_query);

    /* setup offest and row for prefetch */
    DT_DEBUG_SQLITE3_BIND_INT(lib->statements.main_query, 1, offset + max_rows*iir);
    DT_DEBUG_SQLITE3_BIND_INT(lib->statements.main_query, 2, prefetchrows*iir);

    // prefetch jobs in inverse order: supersede previous jobs: most important last
    while(sqlite3_step(lib->statements.main_query) == SQLITE_ROW && imgids_num < prefetchrows*iir)
      imgids[imgids_num++] = sqlite3_column_int(lib->statements.main_query, 0);

    float imgwd = iir == 1 ? 0.97 : 0.8;
    dt_mipmap_size_t mip = dt_mipmap_cache_get_matching_size(
                             darktable.mipmap_cache,
                             imgwd*wd, imgwd*(iir==1?height:ht));
    while(imgids_num > 0)
    {
      imgids_num --;
      dt_mipmap_buffer_t buf;
      dt_mipmap_cache_read_get(
        darktable.mipmap_cache,
        &buf,
        imgids[imgids_num],
        mip,
        DT_MIPMAP_PREFETCH);
    }
  }


failure:
  g_free(query_ids);
  oldpan = pan;
  if(darktable.unmuted & DT_DEBUG_CACHE)
    dt_mipmap_cache_print(darktable.mipmap_cache);

  if(darktable.gui->center_tooltip == 1) // set in this round
  {
    char* tooltip = dt_history_get_items_as_string(mouse_over_id);
    if(tooltip != NULL)
    {
      g_object_set(G_OBJECT(dt_ui_center(darktable.gui->ui)), "tooltip-text", tooltip, (char *)NULL);
      g_free(tooltip);
    }
  }
  else if(darktable.gui->center_tooltip == 2)   // not set in this round
  {
    darktable.gui->center_tooltip = 0;
    g_object_set(G_OBJECT(dt_ui_center(darktable.gui->ui)), "tooltip-text", "", (char *)NULL);
  }
}
Ejemplo n.º 30
0
static void
draw_page (GtkPrintOperation *operation,
           GtkPrintContext   *context,
           gint               page_number,
           gpointer           user_data)
{
  GdictPrintData *data = user_data;
  cairo_t *cr;
  PangoLayout *layout;
  gint text_width, text_height;
  gdouble width;
  gint line, i;
  PangoFontDescription *desc;
  gchar *page_str;

  cr = gtk_print_context_get_cairo_context (context);
  width = gtk_print_context_get_width (context);

  cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT (10));
  
  cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
  cairo_fill_preserve (cr);
  
  cairo_set_source_rgb (cr, 0, 0, 0);
  cairo_set_line_width (cr, 1);
  cairo_stroke (cr);

  /* header */
  layout = gtk_print_context_create_pango_layout (context);

  desc = pango_font_description_from_string ("sans 14");
  pango_layout_set_font_description (layout, desc);
  pango_font_description_free (desc);

  pango_layout_set_text (layout, data->word, -1);
  pango_layout_get_pixel_size (layout, &text_width, &text_height);

  if (text_width > width)
    {
      pango_layout_set_width (layout, width);
      pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_START);
      pango_layout_get_pixel_size (layout, &text_width, &text_height);
    }

  cairo_move_to (cr, (width - text_width) / 2,
                     (HEADER_HEIGHT (10) - text_height) / 2);
  pango_cairo_show_layout (cr, layout);

  page_str = g_strdup_printf ("%d/%d", page_number + 1, data->n_pages);
  pango_layout_set_text (layout, page_str, -1);
  g_free (page_str);

  pango_layout_set_width (layout, -1);
  pango_layout_get_pixel_size (layout, &text_width, &text_height);
  cairo_move_to (cr, width - text_width - 4,
                     (HEADER_HEIGHT (10) - text_height) / 2);
  pango_cairo_show_layout (cr, layout);
  
  g_object_unref (layout);

  /* text */
  layout = gtk_print_context_create_pango_layout (context);
  pango_font_description_set_size (data->font_desc,
                                   data->font_size * PANGO_SCALE);
  pango_layout_set_font_description (layout, data->font_desc);
  
  cairo_move_to (cr, 0, HEADER_HEIGHT (10) + HEADER_GAP (3));
  line = page_number * data->lines_per_page;
  for (i = 0; i < data->lines_per_page && line < data->n_lines; i++) 
    {
      pango_layout_set_text (layout, data->lines[line], -1);

      pango_cairo_show_layout (cr, layout);
      cairo_rel_move_to (cr, 0, data->font_size);
      line++;
    }

  g_object_unref (layout);
}