mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-22 15:10:38 +02:00
eeshow/kicad/: support text justification in page layout
This commit is contained in:
parent
8ac35d9192
commit
356df44952
@ -14,6 +14,7 @@
|
||||
#ifndef KICAD_PL_COMMON_H
|
||||
#define KICAD_PL_COMMON_H
|
||||
|
||||
#include "gfx/text.h"
|
||||
#include "kicad/sexpr.h"
|
||||
|
||||
|
||||
@ -39,6 +40,8 @@ struct pl_obj {
|
||||
float incrx, incry;
|
||||
int incrlabel; /* tbtext */
|
||||
int font; /* tbtext (flags) */
|
||||
enum text_align hor; /* tbtext */
|
||||
enum text_align vert; /* tbtext */
|
||||
|
||||
struct pl_obj *next;
|
||||
};
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "misc/util.h"
|
||||
#include "misc/diag.h"
|
||||
#include "gfx/text.h"
|
||||
#include "file/file.h"
|
||||
#include "kicad/sexpr.h"
|
||||
#include "kicad/pl-common.h"
|
||||
@ -170,8 +171,34 @@ static bool process_font(struct pl_obj *obj, const struct expr *e)
|
||||
if (!get_coord(next, &obj->ex, &obj->ey,
|
||||
&obj->edx, &obj->edy))
|
||||
return 0;
|
||||
} else
|
||||
} else {
|
||||
warning("ignoring \"%s\"\n", s);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static bool process_justify(struct pl_obj *obj, const struct expr *e)
|
||||
{
|
||||
for (; e; e = e->next) {
|
||||
if (e->e) {
|
||||
warning("ignoring list\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(e->s, "center"))
|
||||
obj->hor = obj->vert = text_mid;
|
||||
else if (!strcmp(e->s, "left"))
|
||||
obj->hor = text_min;
|
||||
else if (!strcmp(e->s, "right"))
|
||||
obj->hor = text_max;
|
||||
else if (!strcmp(e->s, "top"))
|
||||
obj->vert = text_max;
|
||||
else if (!strcmp(e->s, "bottom"))
|
||||
obj->vert = text_min;
|
||||
else
|
||||
warning("ignoring \"%s\"\n", e->s);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -194,6 +221,8 @@ static bool process_obj(struct pl_ctx *pl, const struct expr *e,
|
||||
obj->incry = 0;
|
||||
obj->incrlabel = 0;
|
||||
obj->font = 0;
|
||||
obj->hor = text_min;
|
||||
obj->vert = text_mid;
|
||||
|
||||
for (; e; e = e->next) {
|
||||
if (e->s) {
|
||||
@ -242,6 +271,9 @@ static bool process_obj(struct pl_ctx *pl, const struct expr *e,
|
||||
} else if (!strcmp(s, "font")) {
|
||||
if (!process_font(obj, next))
|
||||
return 0;
|
||||
} else if (!strcmp(s, "justify")) {
|
||||
if (!process_justify(obj, next))
|
||||
return 0;
|
||||
} else
|
||||
warning("ignoring \"%s\"\n", s);
|
||||
}
|
||||
|
@ -42,6 +42,22 @@ static int coord(int v, int d, int o, int e)
|
||||
}
|
||||
|
||||
|
||||
static void render_text(const struct pl_obj *obj, int x, int y)
|
||||
{
|
||||
struct text txt = {
|
||||
.s = obj->s,
|
||||
.size = mil(obj->ey),
|
||||
.x = x,
|
||||
.y = y,
|
||||
.rot = 0,
|
||||
.hor = obj->hor,
|
||||
.vert = obj->vert,
|
||||
};
|
||||
|
||||
text_fig(&txt, COLOR_COMP_DWG, LAYER_COMP_DWG);
|
||||
}
|
||||
|
||||
|
||||
static void render_obj(const struct pl_ctx *pl, const struct pl_obj *obj,
|
||||
unsigned i, int w, int h)
|
||||
{
|
||||
@ -80,8 +96,7 @@ static void render_obj(const struct pl_ctx *pl, const struct pl_obj *obj,
|
||||
}
|
||||
break;
|
||||
case pl_obj_text:
|
||||
gfx_text(x, y, obj->s, mil(obj->ey), text_min, 0,
|
||||
COLOR_COMP_DWG, LAYER_COMP_DWG);
|
||||
render_text(obj, x, y);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user