1
0
Fork 0

Control: Add Lth_ControlFont

master
Marrub 2016-10-18 20:02:02 -04:00
parent cceece2216
commit 93377a9dc7
6 changed files with 31 additions and 19 deletions

Binary file not shown.

View File

@ -1,5 +1,5 @@
Lth_Control
| Lth_LayoutControl
| \ Lth_Button
\ Lth_Window
Lth_Rect
\-Lth_Control
| |-Lth_Button
\ \-Lth_Window

View File

@ -35,7 +35,7 @@ enum Lth_ButtonState
//
typedef struct Lth_Button
{
Lth_Inherits(Lth_LayoutControl);
Lth_Inherits(Lth_Control);
char *label;
int state;
} Lth_Button;

View File

@ -13,6 +13,9 @@
#ifndef lithos3__Lth_context_h
#define lithos3__Lth_context_h
#include "Lth_types.h"
#include "Lth_font.h"
// Type Definitions ----------------------------------------------------------|
@ -31,6 +34,7 @@
// read-write
// hid: HUD ID range
// mapspace: space between newly mapped windows that are auto-positioned
// font: default font for drawing
//
typedef struct Lth_Context
{
@ -42,6 +46,7 @@ typedef struct Lth_Context
Lth_HIDRange hid;
Lth_IVec2 mapspace;
Lth_Font *font;
} Lth_Context;

View File

@ -56,19 +56,6 @@ typedef struct Lth_Control
Lth_Mixin(Lth_Rect);
} Lth_Control;
//
// Lth_LayoutControl
//
// read-only
// lx: layout x
// ly: layout y
//
typedef struct Lth_LayoutControl
{
Lth_Inherits(Lth_Control);
int lx, ly;
} Lth_LayoutControl;
// Extern Functions ----------------------------------------------------------|

View File

@ -19,6 +19,27 @@
// Extern Functions ----------------------------------------------------------|
//
// Lth_ControlFont
//
Lth_Font *Lth_ControlFont(void *ctrl_)
{
Lth_Control *ctrl = ctrl_;
if(ctrl->font)
return ctrl->font;
else
{
for(Lth_Control *p = ctrl->parent; p; p = p->parent)
{
if(p->font)
return p->font;
}
}
return ctrl->ctx->font;
}
//
// Lth_ControlRun
//
@ -27,7 +48,6 @@ void Lth_ControlRun(void *ctrl_)
Lth_Control *ctrl = ctrl_;
Lth_assert(ctrl != NULL);
Lth_assert(ctrl->ctx != NULL);
Lth_ControlCall(ctrl, update, ctrl);
Lth_ControlCall(ctrl, draw, ctrl);