mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Fix caret alternating in launcher input widgets causing whole input widget to get redrawn instead of just caret area
Also make all launcher widget drawing behaviour consistent with dirtying area and not drawing while hidden
This commit is contained in:
parent
2598ba18ce
commit
f833db6ba8
@ -215,7 +215,7 @@ static void SwitchToUpdates(void* w, int x, int y) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct ChooseModeScreen {
|
static struct ChooseModeScreen {
|
||||||
LScreen_Layout
|
LScreen_Layout
|
||||||
struct LBox seps[2];
|
struct LLine seps[2];
|
||||||
struct LButton btnEnhanced, btnClassicHax, btnClassic, btnBack;
|
struct LButton btnEnhanced, btnClassicHax, btnClassic, btnBack;
|
||||||
struct LLabel lblTitle, lblHelp, lblEnhanced[2], lblClassicHax[2], lblClassic[2];
|
struct LLabel lblTitle, lblHelp, lblEnhanced[2], lblClassicHax[2], lblClassic[2];
|
||||||
bool firstTime;
|
bool firstTime;
|
||||||
@ -253,9 +253,9 @@ static void ChooseModeScreen_Init(struct LScreen* s_) {
|
|||||||
|
|
||||||
if (s->numWidgets) return;
|
if (s->numWidgets) return;
|
||||||
s->widgets = s->_widgets;
|
s->widgets = s->_widgets;
|
||||||
LLabel_Init(s_, &s->lblTitle, "");
|
LLabel_Init(s_, &s->lblTitle, "");
|
||||||
LBox_Init(s_, &s->seps[0], 490, 2);
|
LLine_Init(s_, &s->seps[0], 490);
|
||||||
LBox_Init(s_, &s->seps[1], 490, 2);
|
LLine_Init(s_, &s->seps[1], 490);
|
||||||
|
|
||||||
LButton_Init(s_, &s->btnEnhanced, 145, 35, "Enhanced");
|
LButton_Init(s_, &s->btnEnhanced, 145, 35, "Enhanced");
|
||||||
LLabel_Init(s_, &s->lblEnhanced[0], "&eEnables custom blocks, changing env");
|
LLabel_Init(s_, &s->lblEnhanced[0], "&eEnables custom blocks, changing env");
|
||||||
@ -1049,8 +1049,7 @@ static void ResourcesScreen_UpdateProgress(struct ResourcesScreen* s) {
|
|||||||
|
|
||||||
if (progress == s->sdrProgress.Value) return;
|
if (progress == s->sdrProgress.Value) return;
|
||||||
s->sdrProgress.Value = progress;
|
s->sdrProgress.Value = progress;
|
||||||
s->sdrProgress.Hidden = false;
|
LWidget_Draw(&s->sdrProgress);
|
||||||
s->sdrProgress.VTABLE->Draw(&s->sdrProgress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ResourcesScreen_Error(struct ResourcesScreen* s) {
|
static void ResourcesScreen_Error(struct ResourcesScreen* s) {
|
||||||
@ -1353,7 +1352,7 @@ struct LScreen* SettingsScreen_MakeInstance(void) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct UpdatesScreen {
|
static struct UpdatesScreen {
|
||||||
LScreen_Layout
|
LScreen_Layout
|
||||||
struct LBox seps[2];
|
struct LLine seps[2];
|
||||||
struct LButton btnRel[2], btnDev[2], btnBack;
|
struct LButton btnRel[2], btnDev[2], btnBack;
|
||||||
struct LLabel lblYour, lblRel, lblDev, lblInfo, lblStatus;
|
struct LLabel lblYour, lblRel, lblDev, lblInfo, lblStatus;
|
||||||
struct LWidget* _widgets[12];
|
struct LWidget* _widgets[12];
|
||||||
@ -1490,8 +1489,8 @@ static void UpdatesScreen_Init(struct LScreen* s_) {
|
|||||||
|
|
||||||
s->widgets = s->_widgets;
|
s->widgets = s->_widgets;
|
||||||
LLabel_Init(s_, &s->lblYour, "Your build: (unknown)");
|
LLabel_Init(s_, &s->lblYour, "Your build: (unknown)");
|
||||||
LBox_Init(s_, &s->seps[0], 320, 2);
|
LLine_Init(s_, &s->seps[0], 320);
|
||||||
LBox_Init(s_, &s->seps[1], 320, 2);
|
LLine_Init(s_, &s->seps[1], 320);
|
||||||
|
|
||||||
LLabel_Init(s_, &s->lblRel, "Latest release: Checking..");
|
LLabel_Init(s_, &s->lblRel, "Latest release: Checking..");
|
||||||
LButton_Init(s_, &s->btnRel[0], 130, 35, "Direct3D 9");
|
LButton_Init(s_, &s->btnRel[0], 130, 35, "Direct3D 9");
|
||||||
|
@ -30,9 +30,12 @@ void LWidget_CalcPosition(void* widget) {
|
|||||||
|
|
||||||
void LWidget_Draw(void* widget) {
|
void LWidget_Draw(void* widget) {
|
||||||
struct LWidget* w = (struct LWidget*)widget;
|
struct LWidget* w = (struct LWidget*)widget;
|
||||||
w->VTABLE->Draw(w);
|
|
||||||
w->Last.X = w->X; w->Last.Width = w->Width;
|
w->Last.X = w->X; w->Last.Width = w->Width;
|
||||||
w->Last.Y = w->Y; w->Last.Height = w->Height;
|
w->Last.Y = w->Y; w->Last.Height = w->Height;
|
||||||
|
|
||||||
|
if (w->Hidden) return;
|
||||||
|
w->VTABLE->Draw(w);
|
||||||
|
Launcher_MarkDirty(w->X, w->Y, w->Width, w->Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LWidget_Redraw(void* widget) {
|
void LWidget_Redraw(void* widget) {
|
||||||
@ -133,13 +136,13 @@ static void LButton_Draw(void* widget) {
|
|||||||
|
|
||||||
static void LButton_Hover(void* w, int x, int y, bool wasOver) {
|
static void LButton_Hover(void* w, int x, int y, bool wasOver) {
|
||||||
/* only need to redraw when changing from unhovered to hovered */
|
/* only need to redraw when changing from unhovered to hovered */
|
||||||
if (!wasOver) LButton_Draw(w);
|
if (!wasOver) LWidget_Draw(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct LWidgetVTABLE lbutton_VTABLE = {
|
static struct LWidgetVTABLE lbutton_VTABLE = {
|
||||||
LButton_Draw, NULL,
|
LButton_Draw, NULL,
|
||||||
NULL, NULL, /* Key */
|
NULL, NULL, /* Key */
|
||||||
LButton_Hover, LButton_Draw, /* Hover */
|
LButton_Hover, LWidget_Draw, /* Hover */
|
||||||
NULL, NULL /* Select */
|
NULL, NULL /* Select */
|
||||||
};
|
};
|
||||||
void LButton_Init(struct LScreen* s, struct LButton* w, int width, int height, const char* text) {
|
void LButton_Init(struct LScreen* s, struct LButton* w, int width, int height, const char* text) {
|
||||||
@ -252,9 +255,7 @@ static void LInput_Draw(void* widget) {
|
|||||||
String text; char textBuffer[STRING_SIZE];
|
String text; char textBuffer[STRING_SIZE];
|
||||||
struct DrawTextArgs args;
|
struct DrawTextArgs args;
|
||||||
Size2D size;
|
Size2D size;
|
||||||
|
|
||||||
BitmapCol white = BITMAPCOL_CONST(255, 255, 255, 255);
|
BitmapCol white = BITMAPCOL_CONST(255, 255, 255, 255);
|
||||||
if (w->Hidden) return;
|
|
||||||
|
|
||||||
String_InitArray(text, textBuffer);
|
String_InitArray(text, textBuffer);
|
||||||
LInput_GetText(w, &text);
|
LInput_GetText(w, &text);
|
||||||
@ -274,7 +275,6 @@ static void LInput_Draw(void* widget) {
|
|||||||
Drawer2D_Cols['f'] = Drawer2D_Cols['0'];
|
Drawer2D_Cols['f'] = Drawer2D_Cols['0'];
|
||||||
LInput_DrawText(w, &args);
|
LInput_DrawText(w, &args);
|
||||||
Drawer2D_Cols['f'] = Drawer2D_Cols['F'];
|
Drawer2D_Cols['f'] = Drawer2D_Cols['F'];
|
||||||
Launcher_MarkDirty(w->X, w->Y, w->Width, w->Height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Rect2D LInput_MeasureCaret(struct LInput* w) {
|
static Rect2D LInput_MeasureCaret(struct LInput* w) {
|
||||||
@ -386,14 +386,14 @@ static void LInput_Select(void* widget, bool wasSelected) {
|
|||||||
LInput_MoveCaretToCursor((struct LInput*)widget);
|
LInput_MoveCaretToCursor((struct LInput*)widget);
|
||||||
/* TODO: Only draw outer border */
|
/* TODO: Only draw outer border */
|
||||||
if (wasSelected) return;
|
if (wasSelected) return;
|
||||||
LInput_Draw(widget);
|
LWidget_Draw(widget);
|
||||||
Window_OpenKeyboard();
|
Window_OpenKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LInput_Unselect(void* widget) {
|
static void LInput_Unselect(void* widget) {
|
||||||
caretStart = 0;
|
caretStart = 0;
|
||||||
/* TODO: Only draw outer border */
|
/* TODO: Only draw outer border */
|
||||||
LInput_Draw(widget);
|
LWidget_Draw(widget);
|
||||||
Window_CloseKeyboard();
|
Window_CloseKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,11 +539,9 @@ void LInput_Clear(struct LInput* w) {
|
|||||||
static void LLabel_Draw(void* widget) {
|
static void LLabel_Draw(void* widget) {
|
||||||
struct LLabel* w = (struct LLabel*)widget;
|
struct LLabel* w = (struct LLabel*)widget;
|
||||||
struct DrawTextArgs args;
|
struct DrawTextArgs args;
|
||||||
if (w->Hidden) return;
|
|
||||||
|
|
||||||
DrawTextArgs_Make(&args, &w->Text, w->Font, true);
|
DrawTextArgs_Make(&args, &w->Text, w->Font, true);
|
||||||
Drawer2D_DrawText(&Launcher_Framebuffer, &args, w->X, w->Y);
|
Drawer2D_DrawText(&Launcher_Framebuffer, &args, w->X, w->Y);
|
||||||
Launcher_MarkDirty(w->X, w->Y, w->Width, w->Height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct LWidgetVTABLE llabel_VTABLE = {
|
static struct LWidgetVTABLE llabel_VTABLE = {
|
||||||
@ -581,21 +579,21 @@ void LLabel_SetConst(struct LLabel* w, const char* text) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-------------------------------------------------------BoxWidget---------------------------------------------------------*
|
*-------------------------------------------------------BoxWidget---------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static void LBox_Draw(void* widget) {
|
static void LLine_Draw(void* widget) {
|
||||||
struct LBox* w = (struct LBox*)widget;
|
struct LLine* w = (struct LLine*)widget;
|
||||||
Gradient_Blend(&Launcher_Framebuffer, w->Col, 128, w->X, w->Y, w->Width, w->Height);
|
Gradient_Blend(&Launcher_Framebuffer, w->Col, 128, w->X, w->Y, w->Width, w->Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct LWidgetVTABLE lbox_VTABLE = {
|
static struct LWidgetVTABLE lline_VTABLE = {
|
||||||
LBox_Draw, NULL,
|
LLine_Draw, NULL,
|
||||||
NULL, NULL, /* Key */
|
NULL, NULL, /* Key */
|
||||||
NULL, NULL, /* Hover */
|
NULL, NULL, /* Hover */
|
||||||
NULL, NULL /* Select */
|
NULL, NULL /* Select */
|
||||||
};
|
};
|
||||||
void LBox_Init(struct LScreen* s, struct LBox* w, int width, int height) {
|
void LLine_Init(struct LScreen* s, struct LLine* w, int width) {
|
||||||
w->VTABLE = &lbox_VTABLE;
|
w->VTABLE = &lline_VTABLE;
|
||||||
w->Width = Display_ScaleX(width);
|
w->Width = Display_ScaleX(width);
|
||||||
w->Height = Display_ScaleY(height);
|
w->Height = Display_ScaleY(2);
|
||||||
s->widgets[s->numWidgets++] = (struct LWidget*)w;
|
s->widgets[s->numWidgets++] = (struct LWidget*)w;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,7 +637,6 @@ static void LSlider_DrawBox(struct LSlider* w) {
|
|||||||
static void LSlider_Draw(void* widget) {
|
static void LSlider_Draw(void* widget) {
|
||||||
struct LSlider* w = (struct LSlider*)widget;
|
struct LSlider* w = (struct LSlider*)widget;
|
||||||
int curWidth;
|
int curWidth;
|
||||||
if (w->Hidden) return;
|
|
||||||
|
|
||||||
LSlider_DrawBoxBounds(w);
|
LSlider_DrawBoxBounds(w);
|
||||||
LSlider_DrawBox(w);
|
LSlider_DrawBox(w);
|
||||||
@ -648,7 +645,6 @@ static void LSlider_Draw(void* widget) {
|
|||||||
Drawer2D_Clear(&Launcher_Framebuffer, w->Col,
|
Drawer2D_Clear(&Launcher_Framebuffer, w->Col,
|
||||||
w->X + BORDER, w->Y + BORDER,
|
w->X + BORDER, w->Y + BORDER,
|
||||||
curWidth, w->Height - BORDER2);
|
curWidth, w->Height - BORDER2);
|
||||||
Launcher_MarkDirty(w->X, w->Y, w->Width, w->Height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct LWidgetVTABLE lslider_VTABLE = {
|
static struct LWidgetVTABLE lslider_VTABLE = {
|
||||||
|
@ -103,12 +103,12 @@ CC_NOINLINE void LLabel_Init(struct LScreen* s, struct LLabel* w, const char* te
|
|||||||
CC_NOINLINE void LLabel_SetText(struct LLabel* w, const String* text);
|
CC_NOINLINE void LLabel_SetText(struct LLabel* w, const String* text);
|
||||||
CC_NOINLINE void LLabel_SetConst(struct LLabel* w, const char* text);
|
CC_NOINLINE void LLabel_SetConst(struct LLabel* w, const char* text);
|
||||||
|
|
||||||
/* Represents a coloured rectangle. Usually used as a line separator. */
|
/* Represents a coloured translucent line separator. */
|
||||||
struct LBox {
|
struct LLine {
|
||||||
LWidget_Layout
|
LWidget_Layout
|
||||||
BitmapCol Col;
|
BitmapCol Col;
|
||||||
};
|
};
|
||||||
CC_NOINLINE void LBox_Init(struct LScreen* s, struct LBox* w, int width, int height);
|
CC_NOINLINE void LLine_Init(struct LScreen* s, struct LLine* w, int width);
|
||||||
|
|
||||||
/* Represents a slider bar that may or may not be modifiable by the user. */
|
/* Represents a slider bar that may or may not be modifiable by the user. */
|
||||||
struct LSlider {
|
struct LSlider {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user