Skip to content

Commit 23090eb

Browse files
committed
perf(gui): use LCUI_STYPE_INT instead of LCUI_STYPE_VALUE
1 parent 3a7b53f commit 23090eb

6 files changed

Lines changed: 14 additions & 15 deletions

File tree

include/LCUI/types.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,15 @@ typedef enum LCUI_StyleType {
179179
LCUI_STYPE_COLOR,
180180
LCUI_STYPE_IMAGE,
181181
LCUI_STYPE_STYLE,
182-
LCUI_STYPE_VALUE,
182+
LCUI_STYPE_INT,
183183
LCUI_STYPE_BOOL,
184184
LCUI_STYPE_STRING,
185185
LCUI_STYPE_WSTRING
186186
} LCUI_StyleType;
187187

188188
#define LCUI_STYPE_px LCUI_STYPE_PX
189189
#define LCUI_STYPE_pt LCUI_STYPE_PT
190-
#define LCUI_STYPE_value LCUI_STYPE_VALUE
191-
#define LCUI_STYPE_int LCUI_STYPE_VALUE
190+
#define LCUI_STYPE_int LCUI_STYPE_INT
192191
#define LCUI_STYPE_color LCUI_STYPE_COLOR
193192
#define LCUI_STYPE_scale LCUI_STYPE_SCALE
194193
#define LCUI_STYPE_style LCUI_STYPE_STYLE

src/gui/css_fontstyle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static void OnComputeLineHeight(LCUI_CSSFontStyle fs, LCUI_Style s)
277277
{
278278
int h;
279279
if (s->is_valid) {
280-
if (s->type == LCUI_STYPE_VALUE) {
280+
if (s->type == LCUI_STYPE_INT) {
281281
h = iround(fs->font_size * s->val_int);
282282
} else if (s->type == LCUI_STYPE_SCALE) {
283283
h = iround(fs->font_size * s->val_scale);

src/gui/css_library.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ void LCUI_PrintStyleSheet(LCUI_StyleSheet ss)
12961296
case LCUI_STYPE_STYLE:
12971297
LOG("%s", LCUI_GetStyleValueName(s->val_style));
12981298
break;
1299-
case LCUI_STYPE_VALUE:
1299+
case LCUI_STYPE_INT:
13001300
LOG("%d", s->val_int);
13011301
break;
13021302
default:

src/gui/css_parser.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static int OnParseValue(LCUI_CSSParserStyleContext ctx, const char *str)
134134
LCUI_Style s = &ctx->sheet->sheet[ctx->parser->key];
135135
if (sscanf(str, "%d", &s->val_int) == 1) {
136136
s->is_valid = TRUE;
137-
s->type = LCUI_STYPE_VALUE;
137+
s->type = LCUI_STYPE_INT;
138138
return 0;
139139
}
140140
return -1;
@@ -229,7 +229,7 @@ static int OnParseBorder(LCUI_CSSParserStyleContext ctx, const char *str)
229229
ss->sheet[key_border_left_color] = slist[i];
230230
break;
231231
case LCUI_STYPE_PX:
232-
case LCUI_STYPE_VALUE:
232+
case LCUI_STYPE_INT:
233233
ss->sheet[key_border_top_width] = slist[i];
234234
ss->sheet[key_border_right_width] = slist[i];
235235
ss->sheet[key_border_bottom_width] = slist[i];
@@ -276,7 +276,7 @@ static int OnParseBorderLeft(LCUI_CSSParserStyleContext ctx, const char *str)
276276
ss->sheet[key_border_left_color] = slist[i];
277277
break;
278278
case LCUI_STYPE_PX:
279-
case LCUI_STYPE_VALUE:
279+
case LCUI_STYPE_INT:
280280
ss->sheet[key_border_left_width] = slist[i];
281281
break;
282282
case LCUI_STYPE_style:
@@ -303,7 +303,7 @@ static int OnParseBorderTop(LCUI_CSSParserStyleContext ctx, const char *str)
303303
ss->sheet[key_border_top_color] = slist[i];
304304
break;
305305
case LCUI_STYPE_PX:
306-
case LCUI_STYPE_VALUE:
306+
case LCUI_STYPE_INT:
307307
ss->sheet[key_border_top_width] = slist[i];
308308
break;
309309
case LCUI_STYPE_style:
@@ -330,7 +330,7 @@ static int OnParseBorderRight(LCUI_CSSParserStyleContext ctx, const char *str)
330330
ss->sheet[key_border_right_color] = slist[i];
331331
break;
332332
case LCUI_STYPE_PX:
333-
case LCUI_STYPE_VALUE:
333+
case LCUI_STYPE_INT:
334334
ss->sheet[key_border_right_width] = slist[i];
335335
break;
336336
case LCUI_STYPE_style:
@@ -357,7 +357,7 @@ static int OnParseBorderBottom(LCUI_CSSParserStyleContext ctx, const char *str)
357357
ss->sheet[key_border_bottom_color] = slist[i];
358358
break;
359359
case LCUI_STYPE_PX:
360-
case LCUI_STYPE_VALUE:
360+
case LCUI_STYPE_INT:
361361
ss->sheet[key_border_bottom_width] = slist[i];
362362
break;
363363
case LCUI_STYPE_style:

src/gui/widget_base.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ void Widget_UpdateOpacity(LCUI_Widget w)
381381
LCUI_Style s = &w->style->sheet[key_opacity];
382382
if (s->is_valid) {
383383
switch (s->type) {
384-
case LCUI_STYPE_VALUE:
385-
opacity = 1.0f * s->value;
384+
case LCUI_STYPE_INT:
385+
opacity = 1.0f * s->val_int;
386386
break;
387387
case LCUI_STYPE_SCALE:
388388
opacity = s->val_scale;
@@ -413,7 +413,7 @@ void Widget_ExecUpdateZIndex(LCUI_Widget w)
413413
LinkedList *list;
414414
LinkedListNode *cnode, *csnode, *snode;
415415
LCUI_Style s = &w->style->sheet[key_z_index];
416-
if (s->is_valid && s->type == LCUI_STYPE_VALUE) {
416+
if (s->is_valid && s->type == LCUI_STYPE_INT) {
417417
z_index = s->val_int;
418418
} else {
419419
z_index = 0;

src/util/parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ LCUI_BOOL ParseNumber(LCUI_Style s, const char *str)
123123
break;
124124
}
125125
if (1 == sscanf(num_str, "%d", &s->val_int)) {
126-
s->type = LCUI_STYPE_VALUE;
126+
s->type = LCUI_STYPE_INT;
127127
break;
128128
}
129129
default:

0 commit comments

Comments
 (0)