src/window/window_measure.c
Sizing windows to their text and fitting them on the screen. More…
Included by window.c.
Macros
| Name | Description | |
|---|---|---|
#define | WINDOW_BORDER_WIDTH 16 | The pixels of a window's two border tiles, left and right. |
#define | LINE_GAP_MAX 12 | The widest gap between characters that spreads a line across its window, in pixels, outside Japanese. |
#define | WINDOW_PAD_X (WINDOW_BORDER_WIDTH + 3) | What a window adds to its text's size in pixels before it is cut to tiles: across, its border and 3, so a width rounds up to the next tile only past 4 pixels into it; down, 15, so a height rounds up and takes one tile more. |
#define | WINDOW_PAD_Y 15 | |
#define | DEFINE_MESSAGE_SIZE (name, flags) | Defines a function that decodes message and sizes its window to fit on the screen near tile (*x, *y), as mnWindowFitOnScreen does with flags; it returns 0 when the message is empty. |
#define | MEASURE_CHARACTER (lineWidth) | The kana marks (TEXT_MARK_VOICED and TEXT_MARK_SEMIVOICED) sit over the character before them, a pixel on; codes above TEXT_LAST_FONT_CODE are kanji, outside FontGlyphs. |
Functions
| Name | Description | |
|---|---|---|
void | mnTextMeasureAllPages (Sint32 entryIndex, Uint32 *outWidth, Uint32 *outHeight, Uint16 *spacing) | Measures decoded text from entryIndex over all its pages: the width of the first page's longest line and the height of its tallest page, in pixels, with each line's extra character gap in spacing as mnTextMeasureDecoded. |
void | mnTextMeasureDecoded (Sint32 entryIndex, Uint32 *outWidth, Uint32 *outHeight, Uint16 *spacing) | Measures decoded text from entryIndex to its first page's end: returns the width of the longest line and the height (TEXT_LINE_HEIGHT a line) in pixels. |
void | mnWindowFitOnScreen (Sint32 entryIndex, Sint32 *windowX, Sint32 *windowY, Uint32 *windowWidth, Uint32 *windowHeight, Uint16 *spacing, Uint32 flags) | Sizes a window for decoded text entryIndex and moves (*windowX, *windowY) so the window fits on the screen, as flags (WINDOW_FIT_FLAG) say. |
void | mnTextMeasureMessage (Sint32 msg, Sint32 *x, Sint32 *y) | Decodes message msg and returns its text's width and height in pixels, in *x and *y. |
DEFINE_MESSAGE_SIZE( | mnTextGetMessageSize , 0) | Sizes a message's window by its first page. |
DEFINE_MESSAGE_SIZE( | mnTextGetMessageSizeAllPages , WINDOW_FIT_ALL_PAGES) | Sizes a message's window to hold every page. |
Description
Sizing windows to their text and fitting them on the screen. Part of
window.c.
Macros in detail
WINDOW_BORDER_WIDTH
#define WINDOW_BORDER_WIDTH 16
The pixels of a window's two border tiles, left and right.
Referenced by mnTextMeasureAllPages() and mnTextMeasureDecoded().
Definition at line 14 of file window_measure.c.
LINE_GAP_MAX
#define LINE_GAP_MAX 12
The widest gap between characters that spreads a line across its window, in pixels, outside Japanese.
Referenced by mnTextMeasureDecoded().
Definition at line 17 of file window_measure.c.
WINDOW_PAD_X
#define WINDOW_PAD_X (WINDOW_BORDER_WIDTH + 3)
What a window adds to its text's size in pixels before it is cut to tiles: across, its border and 3, so a width rounds up to the next tile only past 4 pixels into it; down, 15, so a height rounds up and takes one tile more.
Referenced by mnTextMeasureAllPages(), mnTextMeasureDecoded() and mnWindowFitOnScreen().
Definition at line 22 of file window_measure.c.
WINDOW_PAD_Y
#define WINDOW_PAD_Y 15
Referenced by mnWindowFitOnScreen().
Definition at line 23 of file window_measure.c.
DEFINE_MESSAGE_SIZE
#define DEFINE_MESSAGE_SIZE(name, flags)
Defines a function that decodes message and sizes its window to fit on the
screen near tile (*x, *y), as mnWindowFitOnScreen does with flags; it returns
0 when the message is empty.
Definition at line 126 of file window_measure.c.
MEASURE_CHARACTER
#define MEASURE_CHARACTER(lineWidth)
The kana marks (TEXT_MARK_VOICED and TEXT_MARK_SEMIVOICED) sit over the
character before them, a pixel on; codes above TEXT_LAST_FONT_CODE are kanji,
outside FontGlyphs.
Referenced by mnTextMeasureAllPages() and mnTextMeasureDecoded().
Definition at lines 154 and 176 of file window_measure.c.
Functions in detail
mnTextMeasureAllPages
void mnTextMeasureAllPages(Sint32 entryIndex, Uint32 *outWidth, Uint32 *outHeight, Uint16 *spacing)
Measures decoded text from entryIndex over all its pages: the width of the
first page's longest line and the height of its tallest page, in pixels, with
each line's extra character gap in spacing as mnTextMeasureDecoded. The text
must fit 16 pages. Outside Japanese the gaps have no ceiling, and past the
first page they do not fit their lines; its one caller,
mnTextGetMessageSizeAllPages, passes no spacing.
References mnTextResetStyle() and Sint32.
Referenced by mnWindowFitOnScreen().
Definition at lines 4 and 371 of file window_measure.c.
mnTextMeasureDecoded
void mnTextMeasureDecoded(Sint32 entryIndex, Uint32 *outWidth, Uint32 *outHeight, Uint16 *spacing)
Measures decoded text from entryIndex to its first page's end: returns the
width of the longest line and the height (TEXT_LINE_HEIGHT a line) in pixels.
With spacing set, fills one entry per line, MESSAGE_LINE_COUNT at most, with
the extra gap between characters, in 1/256 pixel, that spreads the line
across the window. It leaves WIN_STATE.outline at the last style it passed.
References mnTextResetStyle() and Sint32.
Referenced by mnTextDrawMessageToCanvas(), mnTextMeasureMessage(), mnTextMeasureString() and mnWindowFitOnScreen().
Definition at lines 8 and 211 of file window_measure.c.
mnWindowFitOnScreen
void mnWindowFitOnScreen(Sint32 entryIndex, Sint32 *windowX, Sint32 *windowY, Uint32 *windowWidth, Uint32 *windowHeight, Uint16 *spacing, Uint32 flags)
Sizes a window for decoded text entryIndex and moves (*windowX, *windowY) so
the window fits on the screen, as flags (WINDOW_FIT_FLAG) say. In the
Japanese release, while a mind-read window is open, a measured window is 2
tiles wider and kept off the screen's last column.
References mnTextMeasureAllPages(), mnTextMeasureDecoded() and Sint32.
Referenced by mnMessageOpenWindow() and mnMessageType().
Definition at line 29 of file window_measure.c.
mnTextMeasureMessage
void mnTextMeasureMessage(Sint32 msg, Sint32 *x, Sint32 *y)
Decodes message msg and returns its text's width and height in pixels, in
*x and *y.
References mnMessageDecode(), mnTextMeasureDecoded() and Sint32.
Definition at line 118 of file window_measure.c.
mnTextGetMessageSize
DEFINE_MESSAGE_SIZE(mnTextGetMessageSize, 0)
Sizes a message's window by its first page.
Referenced by mnAreaNameWindowShow(), mnFieldMessageShow(), mnFieldMessageShowCentered(), scEpilogueShowLine() and scLemuriaEntranceShowLineWithPortrait().
Definition at line 143 of file window_measure.c.
mnTextGetMessageSizeAllPages
DEFINE_MESSAGE_SIZE(mnTextGetMessageSizeAllPages, WINDOW_FIT_ALL_PAGES)
Sizes a message's window to hold every page.
Definition at line 145 of file window_measure.c.