mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2025-04-21 12:27:27 +03:00
eeshow/: move gui* into subdirectory gui/
This commit is contained in:
207
eeshow/gui/aoi.c
Normal file
207
eeshow/gui/aoi.c
Normal file
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* gui/aoi.c - GUI: areas of interest
|
||||
*
|
||||
* Written 2016 by Werner Almesberger
|
||||
* Copyright 2016 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Resources:
|
||||
*
|
||||
* http://zetcode.com/gfx/cairo/cairobackends/
|
||||
* https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "gui/aoi.h"
|
||||
|
||||
|
||||
#define DRAG_RADIUS 5
|
||||
|
||||
|
||||
static const struct aoi *hovering = NULL;
|
||||
static const struct aoi *clicked = NULL;
|
||||
static const struct aoi *dragging = NULL;
|
||||
static int clicked_x, clicked_y;
|
||||
|
||||
|
||||
struct aoi *aoi_add(struct aoi **aois, const struct aoi *cfg)
|
||||
{
|
||||
struct aoi *new;
|
||||
|
||||
new = alloc_type(struct aoi);
|
||||
*new = *cfg;
|
||||
new->next = *aois;
|
||||
*aois = new;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
void aoi_update(struct aoi *aoi, const struct aoi *cfg)
|
||||
{
|
||||
struct aoi *next = aoi->next;
|
||||
|
||||
*aoi = *cfg;
|
||||
aoi->next = next;
|
||||
}
|
||||
|
||||
|
||||
static const struct aoi *find_aoi(const struct aoi *aois, int x, int y)
|
||||
{
|
||||
const struct aoi *aoi;
|
||||
|
||||
for (aoi = aois; aoi; aoi = aoi->next)
|
||||
if (x >= aoi->x && x < aoi->x + aoi->w &&
|
||||
y >= aoi->y && y < aoi->y + aoi->h)
|
||||
break;
|
||||
return aoi;
|
||||
}
|
||||
|
||||
|
||||
static bool aoi_on_list(const struct aoi *aois, const struct aoi *ref)
|
||||
{
|
||||
const struct aoi *aoi;
|
||||
|
||||
for (aoi = aois; aoi; aoi = aoi->next)
|
||||
if (aoi == ref)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool aoi_hover(const struct aoi *aois, int x, int y)
|
||||
{
|
||||
const struct aoi *aoi;
|
||||
|
||||
if (dragging)
|
||||
return 0;
|
||||
if (hovering) {
|
||||
if (x >= hovering->x && x < hovering->x + hovering->w &&
|
||||
y >= hovering->y && y < hovering->y + hovering->h)
|
||||
return 1;
|
||||
hovering->hover(hovering->user, 0);
|
||||
hovering = NULL;
|
||||
}
|
||||
|
||||
aoi = find_aoi(aois, x, y);
|
||||
if (aoi && aoi->hover && aoi->hover(aoi->user, 1)) {
|
||||
hovering = aoi;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool aoi_move(const struct aoi *aois, int x, int y)
|
||||
{
|
||||
if (dragging) {
|
||||
if (aoi_on_list(aois, dragging)) {
|
||||
dragging->drag(dragging->user,
|
||||
x - clicked_x, y - clicked_y);
|
||||
clicked_x = x;
|
||||
clicked_y = y;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (!clicked)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Ensure we're on the right list and are using the same coordinate
|
||||
* system.
|
||||
*/
|
||||
if (!aoi_on_list(aois, clicked))
|
||||
return 0;
|
||||
|
||||
if (hypot(x - clicked_x, y - clicked_y) > DRAG_RADIUS) {
|
||||
if (clicked && clicked->drag) {
|
||||
dragging = clicked;
|
||||
dragging->drag(dragging->user,
|
||||
x - clicked_x, y - clicked_y);
|
||||
clicked_x = x;
|
||||
clicked_y = y;
|
||||
}
|
||||
clicked = NULL;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool aoi_down(const struct aoi *aois, int x, int y)
|
||||
{
|
||||
assert(!clicked);
|
||||
|
||||
aoi_dehover();
|
||||
|
||||
clicked = find_aoi(aois, x, y);
|
||||
if (!clicked)
|
||||
return 0;
|
||||
if (!clicked->click) {
|
||||
clicked = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
clicked_x = x;
|
||||
clicked_y = y;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool aoi_up(const struct aoi *aois, int x, int y)
|
||||
{
|
||||
const struct aoi *aoi;
|
||||
|
||||
if (!aoi_move(aois, x, y))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Ensure we're on the right list and are using the same coordinate
|
||||
* system.
|
||||
*/
|
||||
for (aoi = aois; aoi; aoi = aoi->next)
|
||||
if (aoi == clicked || aoi == dragging)
|
||||
break;
|
||||
if (!aoi)
|
||||
return 0;
|
||||
if (dragging) {
|
||||
dragging = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
clicked->click(clicked->user);
|
||||
clicked = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void aoi_remove(struct aoi **aois, const struct aoi *aoi)
|
||||
{
|
||||
if (hovering == aoi) {
|
||||
aoi->hover(aoi->user, 0);
|
||||
hovering = NULL;
|
||||
}
|
||||
while (*aois != aoi)
|
||||
aois = &(*aois)->next;
|
||||
*aois = aoi->next;
|
||||
free((void *) aoi);
|
||||
}
|
||||
|
||||
|
||||
void aoi_dehover(void)
|
||||
{
|
||||
if (hovering)
|
||||
hovering->hover(hovering->user, 0);
|
||||
hovering = NULL;
|
||||
}
|
||||
|
||||
43
eeshow/gui/aoi.h
Normal file
43
eeshow/gui/aoi.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* gui/aoi.h - GUI: areas of interest
|
||||
*
|
||||
* Written 2016 by Werner Almesberger
|
||||
* Copyright 2016 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#ifndef GUI_AOI_H
|
||||
#define GUI_AOI_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
struct aoi {
|
||||
int x, y, w, h; /* activation box, eeschema coordinates */
|
||||
/* points to hovered aoi, or NULL */
|
||||
|
||||
bool (*hover)(void *user, bool on);
|
||||
void (*click)(void *user);
|
||||
void (*drag)(void *user, int dx, int dy);
|
||||
void *user;
|
||||
|
||||
struct aoi *next;
|
||||
};
|
||||
|
||||
|
||||
struct aoi *aoi_add(struct aoi **aois, const struct aoi *cfg);
|
||||
void aoi_update(struct aoi *aoi, const struct aoi *cfg);
|
||||
bool aoi_hover(const struct aoi *aois, int x, int y);
|
||||
|
||||
bool aoi_move(const struct aoi *aois, int x, int y);
|
||||
bool aoi_down(const struct aoi *aois, int x, int y);
|
||||
bool aoi_up(const struct aoi *aois, int x, int y);
|
||||
|
||||
void aoi_remove(struct aoi **aois, const struct aoi *aoi);
|
||||
void aoi_dehover(void);
|
||||
|
||||
#endif /* !GUI_AOI_H */
|
||||
1542
eeshow/gui/gui.c
Normal file
1542
eeshow/gui/gui.c
Normal file
File diff suppressed because it is too large
Load Diff
25
eeshow/gui/gui.h
Normal file
25
eeshow/gui/gui.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* gui/gui.h - GUI for eeshow
|
||||
*
|
||||
* Written 2016 by Werner Almesberger
|
||||
* Copyright 2016 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#ifndef GUI_GUI_H
|
||||
#define GUI_GUI_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/*
|
||||
* Note: this isn't (argc, argv) ! args stars right with the first file name
|
||||
* and there is no NULL at the end.
|
||||
*/
|
||||
|
||||
int gui(unsigned n_args, char **args, bool recurse, int limit);
|
||||
|
||||
#endif /* !GUI_GUI_H */
|
||||
305
eeshow/gui/over.c
Normal file
305
eeshow/gui/over.c
Normal file
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
* gui/over.c - GUI: overlays
|
||||
*
|
||||
* Written 2016 by Werner Almesberger
|
||||
* Copyright 2016 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Resources:
|
||||
*
|
||||
* http://zetcode.com/gfx/cairo/cairobackends/
|
||||
* https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html
|
||||
* https://www.cairographics.org/samples/rounded_rectangle/
|
||||
*
|
||||
* Section "Description" in
|
||||
* https://developer.gnome.org/pango/stable/pango-Cairo-Rendering.html
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <cairo/cairo.h>
|
||||
#include <pango/pangocairo.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "fmt-pango.h"
|
||||
#include "gui/aoi.h"
|
||||
#include "gui/style.h"
|
||||
#include "gui/over.h"
|
||||
|
||||
|
||||
struct overlay {
|
||||
const char *s;
|
||||
struct overlay_style style;
|
||||
|
||||
struct aoi **aois;
|
||||
bool (*hover)(void *user, bool on);
|
||||
void (*click)(void *user);
|
||||
void (*drag)(void *user, int dx, int dy);
|
||||
void *user;
|
||||
|
||||
struct aoi *aoi;
|
||||
|
||||
struct overlay *next, *prev;
|
||||
};
|
||||
|
||||
|
||||
static void rrect(cairo_t *cr, int x, int y, int w, int h, int r)
|
||||
{
|
||||
const double deg = M_PI / 180.0;
|
||||
|
||||
cairo_new_path(cr);
|
||||
cairo_arc(cr, x + w - r, y + r, r, -90 * deg, 0);
|
||||
cairo_arc(cr, x + w - r, y + h - r, r, 0, 90 * deg);
|
||||
cairo_arc(cr, x + r, y + h - r, r, 90 * deg, 180 * deg);
|
||||
cairo_arc(cr, x + r, y + r, r, 180 * deg, 270 * deg);
|
||||
cairo_close_path(cr);
|
||||
}
|
||||
|
||||
|
||||
static unsigned overlay_draw(struct overlay *over, cairo_t *cr,
|
||||
unsigned x, unsigned y, int dx, int dy)
|
||||
{
|
||||
const struct overlay_style *style = &over->style;
|
||||
const struct color *fg = &style->fg;
|
||||
const struct color *bg = &style->bg;
|
||||
const struct color *frame = &style->frame;
|
||||
unsigned ink_w, ink_h; /* effectively used text area size */
|
||||
unsigned w, h; /* box size */
|
||||
int tx, ty; /* text start position */
|
||||
|
||||
PangoLayout *layout;
|
||||
PangoFontDescription *desc;
|
||||
PangoRectangle ink_rect;
|
||||
|
||||
desc = pango_font_description_from_string(style->font);
|
||||
layout = pango_cairo_create_layout(cr);
|
||||
pango_layout_set_font_description(layout, desc);
|
||||
pango_layout_set_markup(layout, over->s, -1);
|
||||
pango_font_description_free(desc);
|
||||
|
||||
pango_layout_get_extents(layout, &ink_rect, NULL);
|
||||
#if 0
|
||||
fprintf(stderr, "%d + %d %d + %d\n",
|
||||
ink_rect.x / PANGO_SCALE, ink_rect.width / PANGO_SCALE,
|
||||
ink_rect.y / PANGO_SCALE, ink_rect.height / PANGO_SCALE);
|
||||
#endif
|
||||
ink_w = ink_rect.width / PANGO_SCALE;
|
||||
ink_h = ink_rect.height / PANGO_SCALE;
|
||||
|
||||
ink_w = ink_w > style->wmin ? ink_w : style->wmin;
|
||||
ink_w = !style->wmax || ink_w < style->wmax ? ink_w : style->wmax;
|
||||
w = ink_w + 2 * style->pad;
|
||||
h = ink_h + 2 * style->pad;
|
||||
|
||||
if (dx < 0)
|
||||
x -= w;
|
||||
if (dy < 0)
|
||||
y -= h;
|
||||
|
||||
tx = x - ink_rect.x / PANGO_SCALE + style->pad;
|
||||
ty = y - ink_rect.y / PANGO_SCALE + style->pad;
|
||||
|
||||
rrect(cr, x, y, w, h, style->radius);
|
||||
|
||||
cairo_set_source_rgba(cr, bg->r, bg->g, bg->b, bg->alpha);
|
||||
cairo_fill_preserve(cr);
|
||||
cairo_set_source_rgba(cr, frame->r, frame->g, frame->b, frame->alpha);
|
||||
cairo_set_line_width(cr, style->width);
|
||||
cairo_stroke(cr);
|
||||
|
||||
if (style->wmax) {
|
||||
cairo_new_path(cr);
|
||||
#if 0
|
||||
fprintf(stderr, "%u(%d) %u %.60s\n", ty, ink_rect.y / PANGO_SCALE, ink_h, over->s);
|
||||
#endif
|
||||
/*
|
||||
* @@@ for some mysterious reason, we get
|
||||
* ink_h = ink_rect.height / PANGO_SCALE = 5
|
||||
* instead of 2 if using overlay_style_dense_selected. Strangely, changing
|
||||
* overlay_style_dense_selected such that it becomes more like
|
||||
* overlay_style_dense has no effect.
|
||||
*
|
||||
* This causes the text to be cut vertically, roughly in the middle. We hack
|
||||
* around this problem by growind the clipping area vertically. This works,
|
||||
* since we're currently only concerned about horizontal clipping anyway.
|
||||
*/
|
||||
|
||||
cairo_rectangle(cr, tx, ty, ink_w, ink_h + 20);
|
||||
cairo_clip(cr);
|
||||
}
|
||||
|
||||
cairo_set_source_rgba(cr, fg->r, fg->g, fg->b, fg->alpha);
|
||||
cairo_move_to(cr, tx, ty);
|
||||
|
||||
pango_cairo_update_layout(cr, layout);
|
||||
pango_cairo_show_layout(cr, layout);
|
||||
cairo_reset_clip(cr);
|
||||
g_object_unref(layout);
|
||||
|
||||
if (over->hover || over->click || over->drag) {
|
||||
struct aoi aoi_cfg = {
|
||||
.x = x,
|
||||
.y = y,
|
||||
.w = w,
|
||||
.h = h,
|
||||
.hover = over->hover,
|
||||
.click = over->click,
|
||||
.drag = over->drag,
|
||||
.user = over->user,
|
||||
};
|
||||
|
||||
if (over->aoi)
|
||||
aoi_update(over->aoi, &aoi_cfg);
|
||||
else
|
||||
over->aoi = aoi_add(over->aois, &aoi_cfg);
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
void overlay_draw_all_d(struct overlay *overlays, cairo_t *cr,
|
||||
unsigned x, unsigned y, int dx, int dy)
|
||||
{
|
||||
struct overlay *over = overlays;
|
||||
unsigned h;
|
||||
|
||||
if (dy < 0)
|
||||
while (over && over->next)
|
||||
over = over->next;
|
||||
while (over) {
|
||||
h = overlay_draw(over, cr, x, y, dx, dy);
|
||||
y += dy * (h + over->style.skip);
|
||||
if (dy >= 0)
|
||||
over = over->next;
|
||||
else
|
||||
over = over->prev;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void overlay_draw_all(struct overlay *overlays, cairo_t *cr, int x, int y)
|
||||
{
|
||||
int dx = 1;
|
||||
int dy = 1;
|
||||
|
||||
if (x < 0 || y < 0) {
|
||||
double x1, y1, x2, y2;
|
||||
int sw, sh;
|
||||
|
||||
cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
|
||||
sw = x2 - x1;
|
||||
sh = y2 - y1;
|
||||
if (x < 0) {
|
||||
x = sw + x;
|
||||
dx = -1;
|
||||
}
|
||||
if (y < 0) {
|
||||
y = sh + y;
|
||||
dy = -1;
|
||||
}
|
||||
}
|
||||
|
||||
overlay_draw_all_d(overlays, cr, x, y, dx, dy);
|
||||
}
|
||||
|
||||
|
||||
struct overlay *overlay_add(struct overlay **overlays, struct aoi **aois,
|
||||
bool (*hover)(void *user, bool on), void (*click)(void *user), void *user)
|
||||
{
|
||||
struct overlay *over, *prev;
|
||||
struct overlay **anchor;
|
||||
|
||||
over = alloc_type(struct overlay);
|
||||
over->s = NULL;
|
||||
over->style = overlay_style_default;
|
||||
|
||||
over->aois = aois;
|
||||
over->hover = hover;
|
||||
over->click = click;
|
||||
over->user = user;
|
||||
over->aoi = NULL;
|
||||
|
||||
prev = NULL;
|
||||
for (anchor = overlays; *anchor; anchor = &(*anchor)->next)
|
||||
prev = *anchor;
|
||||
over->next = NULL;
|
||||
over->prev = prev;
|
||||
*anchor = over;
|
||||
|
||||
return over;
|
||||
}
|
||||
|
||||
|
||||
void overlay_style(struct overlay *over, const struct overlay_style *style)
|
||||
{
|
||||
over->style = *style;
|
||||
}
|
||||
|
||||
|
||||
void overlay_draggable(struct overlay *over,
|
||||
void (*drag)(void *user, int dx, int dy))
|
||||
{
|
||||
over->drag = drag;
|
||||
}
|
||||
|
||||
|
||||
void overlay_text_raw(struct overlay *over, const char *s)
|
||||
{
|
||||
free((char *) over->s);
|
||||
over->s = stralloc(s);
|
||||
}
|
||||
|
||||
|
||||
void overlay_text(struct overlay *over, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
overlay_text_raw(over, vfmt_pango(fmt, ap));
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
static void overlay_free(struct overlay *over)
|
||||
{
|
||||
if (over->aoi)
|
||||
aoi_remove(over->aois, over->aoi);
|
||||
free((void *) over->s);
|
||||
free(over);
|
||||
}
|
||||
|
||||
|
||||
void overlay_remove(struct overlay **overlays, struct overlay *over)
|
||||
{
|
||||
if (over->next)
|
||||
over->next->prev = over->prev;
|
||||
if (over->prev)
|
||||
over->prev->next = over->next;
|
||||
else
|
||||
*overlays = over->next;
|
||||
overlay_free(over);
|
||||
}
|
||||
|
||||
|
||||
void overlay_remove_all(struct overlay **overlays)
|
||||
{
|
||||
struct overlay *next;
|
||||
|
||||
while (*overlays) {
|
||||
next = (*overlays)->next;
|
||||
overlay_free(*overlays);
|
||||
*overlays = next;
|
||||
}
|
||||
}
|
||||
58
eeshow/gui/over.h
Normal file
58
eeshow/gui/over.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* gui/over.h - GUI: overlays
|
||||
*
|
||||
* Written 2016 by Werner Almesberger
|
||||
* Copyright 2016 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#ifndef GUI_OVER_H
|
||||
#define GUI_OVER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cairo/cairo.h>
|
||||
|
||||
#include "gui/aoi.h"
|
||||
|
||||
|
||||
struct color {
|
||||
double r, g, b, alpha;
|
||||
};
|
||||
|
||||
|
||||
struct overlay_style {
|
||||
const char *font;
|
||||
unsigned wmin, wmax;
|
||||
unsigned radius;
|
||||
unsigned pad; /* in x and y direction; adjust for radius ! */
|
||||
unsigned skip; /* should be list-specific */
|
||||
struct color fg;
|
||||
struct color bg;
|
||||
struct color frame;
|
||||
double width;
|
||||
};
|
||||
|
||||
struct overlay;
|
||||
|
||||
|
||||
void overlay_draw_all_d(struct overlay *overlays, cairo_t *cr,
|
||||
unsigned x, unsigned y, int dx, int dy);
|
||||
void overlay_draw_all(struct overlay *overlays, cairo_t *cr, int x, int y);
|
||||
|
||||
struct overlay *overlay_add(struct overlay **overlays, struct aoi **aois,
|
||||
bool (*hover)(void *user, bool on), void (*click)(void *user), void *user);
|
||||
void overlay_text_raw(struct overlay *over, const char *s);
|
||||
void overlay_text(struct overlay *over, const char *fmt, ...);
|
||||
void overlay_style(struct overlay *over, const struct overlay_style *style);
|
||||
void overlay_draggable(struct overlay *over,
|
||||
void (*drag)(void *user, int dx, int dy));
|
||||
void overlay_remove(struct overlay **overlays, struct overlay *over);
|
||||
void overlay_remove_all(struct overlay **overlays);
|
||||
|
||||
#endif /* !GUI_OVER_H */
|
||||
78
eeshow/gui/style.c
Normal file
78
eeshow/gui/style.c
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* gui/style.c - GUI: overlay styles
|
||||
*
|
||||
* Written 2016 by Werner Almesberger
|
||||
* Copyright 2016 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "gui/style.h"
|
||||
|
||||
|
||||
#define OVER_BORDER 8
|
||||
#define OVER_RADIUS 6
|
||||
#define OVER_SEP 8
|
||||
|
||||
#define NORMAL_PAD 8
|
||||
#define NORMAL_RADIUS 6
|
||||
#define NORMAL_SKIP 8
|
||||
#define NORMAL_WIDTH 2
|
||||
|
||||
#define DENSE_PAD 4
|
||||
#define DENSE_RADIUS 3
|
||||
#define DENSE_SKIP 5
|
||||
#define DENSE_WIDTH 1
|
||||
|
||||
#define BG_STANDARD { 0.8, 0.9, 1.0, 0.8 }
|
||||
#define FG_STANDARD { 0.0, 0.0, 0.0, 1.0 }
|
||||
#define FRAME_STANDARD { 0.5, 0.5, 1.0, 0.7 }
|
||||
|
||||
#define BG_DIFF_NEW BG_STANDARD
|
||||
#define FG_DIFF_NEW { 0.0, 0.6, 0.0, 1.0 }
|
||||
#define FRAME_DIFF_NEW FRAME_STANDARD
|
||||
|
||||
#define BG_DIFF_OLD BG_STANDARD
|
||||
#define FG_DIFF_OLD { 0.8, 0.0, 0.0, 1.0 }
|
||||
#define FRAME_DIFF_OLD FRAME_STANDARD
|
||||
|
||||
|
||||
#define BOX_ATTRS(style) \
|
||||
.pad = style##_PAD, \
|
||||
.radius = style##_RADIUS, \
|
||||
.skip = style##_SKIP, \
|
||||
.width = style##_WIDTH
|
||||
|
||||
#define NORMAL BOX_ATTRS(NORMAL)
|
||||
#define DENSE BOX_ATTRS(DENSE)
|
||||
|
||||
#define COLOR_ATTRS(style) \
|
||||
.bg = BG_##style, \
|
||||
.fg = FG_##style, \
|
||||
.frame = FRAME_##style
|
||||
|
||||
#define STANDARD COLOR_ATTRS(STANDARD)
|
||||
#define DIFF_NEW COLOR_ATTRS(DIFF_NEW)
|
||||
#define DIFF_OLD COLOR_ATTRS(DIFF_OLD)
|
||||
|
||||
|
||||
struct overlay_style overlay_style_default = {
|
||||
.font = NORMAL_FONT,
|
||||
NORMAL,
|
||||
STANDARD,
|
||||
}, overlay_style_dense = {
|
||||
.font = NORMAL_FONT,
|
||||
DENSE,
|
||||
STANDARD,
|
||||
}, overlay_style_diff_new = {
|
||||
.font = NORMAL_FONT,
|
||||
NORMAL,
|
||||
DIFF_NEW,
|
||||
}, overlay_style_diff_old = {
|
||||
.font = NORMAL_FONT,
|
||||
NORMAL,
|
||||
DIFF_OLD,
|
||||
};
|
||||
35
eeshow/gui/style.h
Normal file
35
eeshow/gui/style.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* gui/style.h - GUI: overlay styles
|
||||
*
|
||||
* Written 2016 by Werner Almesberger
|
||||
* Copyright 2016 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#ifndef GUI_STYLE_H
|
||||
#define GUI_STYLE_H
|
||||
|
||||
#include "gui/over.h"
|
||||
|
||||
|
||||
#define NORMAL_FONT "Helvetica 10"
|
||||
#define BOLD_FONT "Helvetica Bold 10"
|
||||
|
||||
#define FRAME_SEL_ONLY 0.0, 0.0, 0.0, 0.9
|
||||
#define FRAME_SEL_OLD 0.8, 0.2, 0.2, 0.9
|
||||
#define FRAME_SEL_NEW 0.0, 0.6, 0.0, 0.9
|
||||
|
||||
#define BG_NEW 0.6, 1.0, 0.6, 0.8
|
||||
#define BG_OLD 1.0, 0.8, 0.8, 0.8
|
||||
|
||||
|
||||
extern struct overlay_style overlay_style_default;
|
||||
extern struct overlay_style overlay_style_dense;
|
||||
extern struct overlay_style overlay_style_diff_new;
|
||||
extern struct overlay_style overlay_style_diff_old;
|
||||
|
||||
#endif /* !GUI_STYLE_H */
|
||||
Reference in New Issue
Block a user