gpforge
An advanced bitmap font editor
Loading...
Searching...
No Matches
gui.h File Reference

The editor state and the functions everything in the GUI goes through. More...

#include <widgets/gp_widgets.h>
#include "font.h"
#include "resolve.h"
#include "face.h"
#include "undo.h"
#include "unicode_blocks.h"

Go to the source code of this file.

Data Structures

struct  gpf_block_sel
 The glyph selected last in a block, to go back to when the block is switched to again. More...
struct  gpf_gui
 The editor state. More...

Functions

const gp_font_face * gpf_gui_face (enum gpf_variant_id id)
 The resolved variant compiled into a gfxprim face.
void gpf_gui_invalidate (void)
 Throws the compiled faces away.
void gpf_gui_select (uint32_t code)
 Selects a glyph and turns the table to it.
void gpf_gui_select_keep (uint32_t code)
 Selects a glyph without moving the table to it.
void gpf_gui_create_glyph (uint32_t code)
 Creates a glyph the font has not got.
void gpf_gui_pixel_set (int col, int height, int set)
 Sets or clears a pixel of the glyph being edited.
unsigned int gpf_gui_accented (uint32_t *codes, unsigned int max)
 The accented letters that follow the glyph being edited.
void gpf_gui_set_block (unsigned int block)
 Selects a block and turns the table to its first page.
gp_pixel gpf_gui_back_color (gp_widget *self)
 The color a widget is drawn on.
void gpf_gui_set_canvas_zoom (unsigned int zoom)
 Sets the canvas zoom and the spinner that shows it.
void gpf_gui_sync_block (unsigned int block)
 Makes the block selector follow the table.
void gpf_gui_set_variant (enum gpf_variant_id id)
 Switches the variant being edited.
void gpf_gui_move_variant (int offset)
 Moves the current variant in the variant ordering.
void gpf_gui_redraw (void)
 Repaints everything that shows the font.
const struct gpf_ucode_block * gpf_gui_blocks (void)
 The block list, built on demand.
const struct gpf_ucode_block * gpf_gui_block (void)
 The block being browsed.
void gpf_gui_set_dirty (int dirty)
 Marks the font as changed or as written.
int gpf_gui_modified (uint32_t code)
 Whether the glyph has changed since the font was written.
struct gpf_glyph * gpf_gui_edit_glyph (void)
 The glyph entry to edit in the current variant.
struct gpf_glyph * gpf_gui_edit_code (uint32_t code)
 The glyph entry to edit, for any glyph.
void gpf_gui_shift (int dx, int dy)
 Moves the ink of the glyph being edited.
void gpf_gui_edit_begin (void)
 Starts an edit, one undo entry.
void gpf_gui_edit_commit (void)
 Commits the edit started by gpf_gui_edit_begin() and repaints.
void gpf_gui_edited (void)
 The font changed.
void gpf_pixmap_resize (gp_widget_event *ev)
 Allocates the backing pixmap on a resize.

Variables

struct gpf_gui gui
 The editor state.

Detailed Description

The editor state and the functions everything in the GUI goes through.

The state is one global, gui, and the functions here, implemented in gpforge.c, are the funnels the widgets change it through: selecting, editing and redrawing. The widgets themselves have headers of their own, see browser.h, canvas.h, preview.h and cell.h, and so do the dialogs.

The editor runs with no font open, gpf_gui::font is NULL then, and it is the GUI that checks for it, never the model.

Definition in file gui.h.

Function Documentation

◆ gpf_gui_accented()

unsigned int gpf_gui_accented ( uint32_t * codes,
unsigned int max )

The accented letters that follow the glyph being edited.

The ones the font has, when the update box is ticked; editing Á does not drag À along, only the letter they are both accented forms of does.

Parameters
codesAn array to fill in.
maxThe size of the array.
Returns
The number of codepoints, zero when the update box is not ticked.

Definition at line 458 of file gpforge.c.

References gpf_resolve(), and gpf_resolved_clear().

◆ gpf_gui_back_color()

gp_pixel gpf_gui_back_color ( gp_widget * self)

The color a widget is drawn on.

The foreground color while the widget is focused, which is when the keys work on it, and the background color otherwise.

Parameters
selfA widget.
Returns
A pixel value.

Definition at line 1161 of file gpforge.c.

◆ gpf_gui_block()

const struct gpf_ucode_block * gpf_gui_block ( void )

The block being browsed.

Returns
The block, do not free it; NULL when there is no font open.

Definition at line 78 of file gpforge.c.

References gpf_gui_blocks().

◆ gpf_gui_blocks()

const struct gpf_ucode_block * gpf_gui_blocks ( void )

The block list, built on demand.

Returns
The list, do not free it; NULL when there is no font open.

Definition at line 67 of file gpforge.c.

References gpf_blocks_build().

Referenced by gpf_browser_show_sel(), and gpf_gui_block().

◆ gpf_gui_create_glyph()

void gpf_gui_create_glyph ( uint32_t code)

Creates a glyph the font has not got.

Draws it once, as ink: its base with the accent this font draws on it. From then on it is an ordinary glyph. Clicking an empty slot of the accented letters strip is what asks for it.

Parameters
codeA codepoint of an accented letter.

Definition at line 641 of file gpforge.c.

References gpf_decomposition::code, gpf_decompose(), gpf_gui_edit_begin(), gpf_gui_edit_commit(), gpf_gui_edited(), and GPF_VARIANTS.

◆ gpf_gui_edit_begin()

void gpf_gui_edit_begin ( void )

Starts an edit, one undo entry.

Journals nothing with no font open.

Definition at line 664 of file gpforge.c.

Referenced by gpf_gui_create_glyph(), and gpf_gui_shift().

◆ gpf_gui_edit_code()

struct gpf_glyph * gpf_gui_edit_code ( uint32_t code)

The glyph entry to edit, for any glyph.

The same as gpf_gui_edit_glyph(), and it retargets the pending journal entry, so that an edit that lands on another glyph is undoable and marked as modified.

Parameters
codeA codepoint.
Returns
The entry, NULL when there is no font open.

Definition at line 443 of file gpforge.c.

References gpf_glyph::code.

◆ gpf_gui_edit_glyph()

struct gpf_glyph * gpf_gui_edit_glyph ( void )

The glyph entry to edit in the current variant.

An inherited or derived glyph is materialized here, which is what creating an overlay is, and a glyph the font does not have yet starts empty.

Returns
The entry, NULL when there is no font open.

Definition at line 448 of file gpforge.c.

Referenced by gpf_gui_pixel_set(), and gpf_gui_shift().

◆ gpf_gui_edited()

void gpf_gui_edited ( void )

The font changed.

The faces are stale, the display is stale, the file is dirty.

Definition at line 732 of file gpforge.c.

References gpf_gui_invalidate(), and gpf_gui_redraw().

Referenced by gpf_gui_create_glyph(), gpf_gui_pixel_set(), and gpf_gui_shift().

◆ gpf_gui_face()

const gp_font_face * gpf_gui_face ( enum gpf_variant_id id)

The resolved variant compiled into a gfxprim face.

Built on demand and kept until gpf_gui_invalidate().

Parameters
idA variant.
Returns
The face, NULL when there is no font open.

Definition at line 46 of file gpforge.c.

References gpf_gui::faces, and GPF_VARIANTS.

◆ gpf_gui_invalidate()

void gpf_gui_invalidate ( void )

Throws the compiled faces away.

Called when the font changes. The block list is kept, it only changes with the set of glyphs the font has.

Definition at line 57 of file gpforge.c.

References GPF_VARIANTS.

Referenced by gpf_gui_edited().

◆ gpf_gui_modified()

int gpf_gui_modified ( uint32_t code)

Whether the glyph has changed since the font was written.

The entry that says so is the one the ink comes from, which in a variant that inherits it is the parent's.

Parameters
codeA codepoint.
Returns
Non-zero when the glyph was modified.

Definition at line 712 of file gpforge.c.

References gpf_glyph::code, gpf_variant_glyph(), and gpf_resolved::ink_from.

◆ gpf_gui_move_variant()

void gpf_gui_move_variant ( int offset)

Moves the current variant in the variant ordering.

Parameters
offsetHow much the variant should be moved.

Definition at line 967 of file gpforge.c.

References GPF_VARIANTS.

◆ gpf_gui_pixel_set()

void gpf_gui_pixel_set ( int col,
int height,
int set )

Sets or clears a pixel of the glyph being edited.

The same pixel of the accented letters that follow it is set too, a carbon copy, see gpf_gui_accented(). This is what every pixel edit goes through.

Parameters
colA column counted from the glyph origin.
heightA height from the baseline, positive up.
setA value to set the pixel to, 0 or 1.

Definition at line 488 of file gpforge.c.

References gpf_gui_edit_glyph(), gpf_gui_edited(), and gpf_glyph::height.

◆ gpf_gui_redraw()

void gpf_gui_redraw ( void )

Repaints everything that shows the font.

During a stroke only the canvas and the accented letters strip are repainted, the rest waits for the commit.

Definition at line 762 of file gpforge.c.

Referenced by gpf_gui_edit_commit(), gpf_gui_edited(), gpf_gui_set_block(), and gpf_gui_set_variant().

◆ gpf_gui_select()

void gpf_gui_select ( uint32_t code)

Selects a glyph and turns the table to it.

Parameters
codeA codepoint.

Definition at line 872 of file gpforge.c.

References gpf_block_sel::code.

◆ gpf_gui_select_keep()

void gpf_gui_select_keep ( uint32_t code)

Selects a glyph without moving the table to it.

Picking one out of the accented letters strip must not throw away the page you were working on.

Parameters
codeA codepoint.

Definition at line 877 of file gpforge.c.

References gpf_block_sel::code.

◆ gpf_gui_set_block()

void gpf_gui_set_block ( unsigned int block)

Selects a block and turns the table to its first page.

Parameters
blockAn index into the block list.

Definition at line 882 of file gpforge.c.

References gpf_gui_redraw().

◆ gpf_gui_set_canvas_zoom()

void gpf_gui_set_canvas_zoom ( unsigned int zoom)

Sets the canvas zoom and the spinner that shows it.

Parameters
zoomThe pixel multiplier, at least one.

Definition at line 1175 of file gpforge.c.

References GPF_MAX.

◆ gpf_gui_set_dirty()

void gpf_gui_set_dirty ( int dirty)

Marks the font as changed or as written.

The save button follows this and nothing else.

Parameters
dirtyNon-zero when the font has changed since it was last written.

Definition at line 697 of file gpforge.c.

◆ gpf_gui_set_variant()

void gpf_gui_set_variant ( enum gpf_variant_id id)

Switches the variant being edited.

Parameters
idA variant.

Definition at line 957 of file gpforge.c.

References gpf_gui_redraw(), and gpf_variant::id.

◆ gpf_gui_shift()

void gpf_gui_shift ( int dx,
int dy )

Moves the ink of the glyph being edited.

The accented letters that follow it move along with it.

Parameters
dxAn x offset, positive right.
dyAn y offset, positive up.

Definition at line 1996 of file gpforge.c.

References gpf_glyph::dx, gpf_gui_edit_begin(), gpf_gui_edit_commit(), gpf_gui_edit_glyph(), and gpf_gui_edited().

◆ gpf_gui_sync_block()

void gpf_gui_sync_block ( unsigned int block)

Makes the block selector follow the table.

Unlike gpf_gui_set_block() it leaves the page alone, it is called when the selection moved into another block.

Parameters
blockAn index into the block list.

Definition at line 942 of file gpforge.c.

◆ gpf_pixmap_resize()

void gpf_pixmap_resize ( gp_widget_event * ev)

Allocates the backing pixmap on a resize.

The buffered pixmap mode.

Parameters
evA resize event.

Definition at line 982 of file gpforge.c.