diff --git a/apps/file_manager/main.cpp b/apps/file_manager/main.cpp index 0bda57e..4ebe10b 100644 --- a/apps/file_manager/main.cpp +++ b/apps/file_manager/main.cpp @@ -505,10 +505,15 @@ void _start() { InstanceCreateUI(instance); } } else if (message->type == ES_MSG_INSTANCE_DESTROY) { - // TODO Cleanup/cancel any unfinished non-blocking tasks before we get here! Instance *instance = message->instanceDestroy.instance; - InstanceDestroy(instance); - instances.FindAndDeleteSwap(instance, true); + EsApplicationStartupRequest request = EsInstanceGetStartupRequest(instance); + + if (request.flags & ES_APPLICATION_STARTUP_BACKGROUND_SERVICE) { + // No cleanup to do. + } else { + InstanceDestroy(instance); + instances.FindAndDeleteSwap(instance, true); + } } else if (message->type == ES_MSG_APPLICATION_EXIT) { #ifdef DEBUG_BUILD for (uintptr_t i = 0; i < drives.Length(); i++) { diff --git a/apps/gl_test.c b/apps/gl_test.c index d1f93e8..b6e23e8 100644 --- a/apps/gl_test.c +++ b/apps/gl_test.c @@ -299,7 +299,7 @@ int main(int argc, char **argv) { uint32_t i0 = strtoul(position, &position, 10) - 1; uint32_t i1 = strtoul(position, &position, 10) - 1; uint32_t i2 = strtoul(position, &position, 10) - 1; - EsAssert(i0 < vertexCount); + EsAssert(i0 < vertexCount); // TODO Error reporting. EsAssert(i1 < vertexCount); EsAssert(i2 < vertexCount); modelIBOArray[3 * triangleIndex + 0] = i0; @@ -310,7 +310,7 @@ int main(int argc, char **argv) { } } - EsPrint("%F -> %F, %F -> %F, %F -> %F\n", minimumX, maximumX, minimumY, maximumY, minimumZ, maximumZ); + EsPrint("Model bounds: %F -> %F, %F -> %F, %F -> %F\n", minimumX, maximumX, minimumY, maximumY, minimumZ, maximumZ); EsAssert(vertexIndex == vertexCount); EsAssert(triangleIndex == triangleCount); #endif diff --git a/apps/installer.cpp b/apps/installer.cpp index fda669a..ca161a3 100644 --- a/apps/installer.cpp +++ b/apps/installer.cpp @@ -921,11 +921,11 @@ void WriteNewConfiguration() { ///////////////////////////////////////////// void ButtonViewLicenses(EsInstance *, EsElement *, EsCommand *) { - EsPanelSwitchTo(switcher, panelLicenses, ES_TRANSITION_FADE_IN); + EsPanelSwitchTo(switcher, panelLicenses, ES_TRANSITION_FADE); } void ButtonInstallOptions(EsInstance *, EsElement *, EsCommand *) { - EsPanelSwitchTo(switcher, panelInstallOptions, ES_TRANSITION_FADE_IN); + EsPanelSwitchTo(switcher, panelInstallOptions, ES_TRANSITION_FADE); } void ButtonShutdown(EsInstance *, EsElement *, EsCommand *) { @@ -938,7 +938,7 @@ void ButtonRestart(EsInstance *, EsElement *, EsCommand *) { void ButtonInstall(EsInstance *, EsElement *, EsCommand *) { useMBR = EsButtonGetCheck(useMBRCheckbox) == ES_CHECK_CHECKED; - EsPanelSwitchTo(switcher, panelCustomizeOptions, ES_TRANSITION_FADE_IN); + EsPanelSwitchTo(switcher, panelCustomizeOptions, ES_TRANSITION_FADE); EsElementFocus(userNameTextbox); startedInstallation = true; EsThreadCreate(InstallThread, nullptr, 0); @@ -956,7 +956,7 @@ void ButtonFont(EsInstance *, EsElement *element, EsCommand *) { void Complete() { if (installError == ES_SUCCESS) { WriteNewConfiguration(); - EsPanelSwitchTo(switcher, panelComplete, ES_TRANSITION_FADE_IN); + EsPanelSwitchTo(switcher, panelComplete, ES_TRANSITION_FADE); } else { EsPanel *row = EsPanelCreate(panelError, ES_CELL_H_FILL | ES_PANEL_HORIZONTAL); EsIconDisplayCreate(row, ES_FLAGS_DEFAULT, 0, ES_ICON_DIALOG_ERROR); @@ -975,7 +975,7 @@ void Complete() { EsSpacerCreate(buttonsRow, ES_CELL_H_FILL); EsButtonOnCommand(EsButtonCreate(buttonsRow, ES_FLAGS_DEFAULT, 0, INTERFACE_STRING(DesktopRestartAction)), ButtonRestart); - EsPanelSwitchTo(switcher, panelError, ES_TRANSITION_FADE_IN); + EsPanelSwitchTo(switcher, panelError, ES_TRANSITION_FADE); } } @@ -984,7 +984,7 @@ void ButtonFinish(EsInstance *, EsElement *, EsCommand *) { Complete(); } else { onWaitScreen = true; - EsPanelSwitchTo(switcher, panelWait, ES_TRANSITION_FADE_IN); + EsPanelSwitchTo(switcher, panelWait, ES_TRANSITION_FADE); } } diff --git a/desktop/desktop.cpp b/desktop/desktop.cpp index 412e3a3..e3e1e48 100644 --- a/desktop/desktop.cpp +++ b/desktop/desktop.cpp @@ -1070,7 +1070,7 @@ void TaskBarTasksButtonUpdate() { if (desktop.allOngoingUserTasks.Length()) { if (EsElementIsHidden(desktop.tasksButton)) { EsPanelStartMovementAnimation((EsPanel *) EsElementGetLayoutParent(desktop.tasksButton), 1.5f /* duration scale */); - EsElementStartTransition(desktop.tasksButton, ES_TRANSITION_FADE_IN, ES_ELEMENT_TRANSITION_ENTRANCE, 1.5f); + EsElementStartTransition(desktop.tasksButton, ES_TRANSITION_FADE_IN, ES_FLAGS_DEFAULT, 1.5f); EsElementSetHidden(desktop.tasksButton, false); } diff --git a/desktop/gui.cpp b/desktop/gui.cpp index c1db1b7..04ed68c 100644 --- a/desktop/gui.cpp +++ b/desktop/gui.cpp @@ -109,7 +109,6 @@ void InspectorNotifyElementContentChanged(EsElement *element); #define UI_STATE_ANIMATING (1 << 13) #define UI_STATE_ENTERED (1 << 14) -#define UI_STATE_EXITING (1 << 15) #define UI_STATE_BLOCK_INTERACTION (1 << 16) #define UI_STATE_TEMP (1 << 17) @@ -1172,7 +1171,7 @@ EsRectangle UIGetTransitionEffectRectangle(EsRectangle bounds, EsTransitionType int width = Width(bounds), height = Height(bounds); double ratio = (double) height / (double) width; - if (type == ES_TRANSITION_FADE_IN || type == ES_TRANSITION_FADE_OUT || type == ES_TRANSITION_FADE_VIA_TRANSPARENT) { + if (type == ES_TRANSITION_FADE_IN || type == ES_TRANSITION_FADE_OUT || type == ES_TRANSITION_FADE_VIA_TRANSPARENT || type == ES_TRANSITION_FADE) { return bounds; } else if (!to) { if (type == ES_TRANSITION_SLIDE_UP) { @@ -1269,7 +1268,7 @@ EsRectangle UIGetTransitionEffectRectangle(EsRectangle bounds, EsTransitionType } void UIDrawTransitionEffect(EsPainter *painter, EsPaintTarget *sourceSurface, EsRectangle bounds, EsTransitionType type, double progress, bool to) { - if (type == ES_TRANSITION_FADE_OUT && to) { + if ((type == ES_TRANSITION_FADE_OUT && to) || (type == ES_TRANSITION_FADE_IN && !to)) { return; } @@ -1294,6 +1293,12 @@ void EsElementStartTransition(EsElement *element, EsTransitionType transitionTyp return; } + if (transitionType == ES_TRANSITION_FADE_IN) { + flags |= ES_ELEMENT_TRANSITION_ENTRANCE; + } else if (transitionType == ES_TRANSITION_FADE_OUT) { + flags |= ES_ELEMENT_TRANSITION_EXIT; + } + if (element->previousTransitionFrame) { EsPaintTargetDestroy(element->previousTransitionFrame); element->previousTransitionFrame = nullptr; @@ -1459,24 +1464,23 @@ void EsElement::InternalPaint(EsPainter *painter, int paintFlags) { bounds.l -= paintOutsets.l, bounds.r += paintOutsets.r; bounds.t -= paintOutsets.t, bounds.b += paintOutsets.b; - if (EsPaintTargetTake(&target, targetWidth, targetHeight)) { - if (previousTransitionFrame) { - UIDrawTransitionEffect(painter, previousTransitionFrame, bounds, - (EsTransitionType) transitionType, progress, false); + if (previousTransitionFrame) { + UIDrawTransitionEffect(painter, previousTransitionFrame, bounds, (EsTransitionType) transitionType, progress, false); + } + + if (~transitionFlags & ES_ELEMENT_TRANSITION_EXIT) { + if (EsPaintTargetTake(&target, targetWidth, targetHeight)) { + EsPainter p = {}; + p.clip = ES_RECT_4(0, targetWidth, 0, targetHeight); + p.offsetX = paintOutsets.l; + p.offsetY = paintOutsets.t; + p.target = ⌖ + InternalPaint(&p, PAINT_NO_TRANSITION | PAINT_NO_OFFSET); + UIDrawTransitionEffect(painter, &target, bounds, (EsTransitionType) transitionType, progress, true); + EsPaintTargetReturn(&target); + } else { + goto paintBackground; } - - EsPainter p = {}; - p.clip = ES_RECT_4(0, targetWidth, 0, targetHeight); - p.offsetX = paintOutsets.l; - p.offsetY = paintOutsets.t; - p.target = ⌖ - InternalPaint(&p, PAINT_NO_TRANSITION | PAINT_NO_OFFSET); - - UIDrawTransitionEffect(painter, &target, bounds, (EsTransitionType) transitionType, progress, true); - - EsPaintTargetReturn(&target); - } else { - goto paintBackground; } } else { paintBackground:; @@ -1672,17 +1676,6 @@ void ProcessAnimations() { gui.animatingElements.DeleteSwap(i); element->state &= ~UI_STATE_ANIMATING; i--; - - if (element->state & UI_STATE_EXITING) { - EsElement *ancestor = element; - - while (ancestor) { - ancestor->state |= UI_STATE_DESTROYING_CHILD; - ancestor = ancestor->parent; - } - - element->state &= ~UI_STATE_EXITING; - } } else if (m.animate.waitMs < waitMs || waitMs == -1) { waitMs = m.animate.waitMs; } @@ -1724,10 +1717,6 @@ bool EsElement::RefreshStyleState() { } } - if (state & UI_STATE_EXITING) { - styleStateFlags |= THEME_STATE_AFTER_EXIT; - } - bool observedBitsChanged = false; if (!currentStyle || currentStyle->IsStateChangeObserved(styleStateFlags, previousStyleState)) { @@ -2387,10 +2376,6 @@ int EsElement::GetHeight(int width) { } void EsElement::InternalMove(int _width, int _height, int _offsetX, int _offsetY) { - if (state & UI_STATE_EXITING) { - return; - } - #ifdef TRACE_LAYOUT if (parent) { EsElement *parent = this->parent->parent; @@ -5456,26 +5441,6 @@ void EsElement::Destroy(bool manual) { } if (manual) { -#ifndef DISABLE_ALL_ANIMATIONS - if (currentStyle->metrics->exitDuration) { - if (previousTransitionFrame) { - EsPaintTargetDestroy(previousTransitionFrame); - } - - previousTransitionFrame = EsPaintTargetCreate(width, height, true); - - if (previousTransitionFrame) { - // TODO Doesn't support shadows. - EsPainter painter = {}; - painter.clip = ES_RECT_4(0, width, 0, height); - painter.target = previousTransitionFrame; - InternalPaint(&painter, PAINT_NO_TRANSITION | PAINT_NO_OFFSET); - state |= UI_STATE_EXITING; - RefreshStyle(); - } - } -#endif - EsElement *ancestor = parent; while (ancestor && (~ancestor->state & UI_STATE_DESTROYING_CHILD)) { @@ -5555,10 +5520,6 @@ bool EsElement::InternalDestroy() { children.Free(); - if (state & UI_STATE_EXITING) { - return false; - } - InspectorNotifyElementDestroyed(this); if (state & UI_STATE_ANIMATING) { @@ -6007,10 +5968,6 @@ EsThemeMetrics EsElementGetMetrics(EsElement *element) { m.globalOffset = RECTANGLE_8_TO_ES_RECTANGLE(metrics->globalOffset); m.clipEnabled = metrics->clipEnabled; m.cursor = metrics->cursor; - m.entranceTransition = metrics->entranceTransition; - m.exitTransition = metrics->exitTransition; - m.entranceDuration = metrics->entranceDuration; - m.exitDuration = metrics->exitDuration; m.preferredWidth = metrics->preferredWidth; m.preferredHeight = metrics->preferredHeight; m.minimumWidth = metrics->minimumWidth; diff --git a/desktop/os.header b/desktop/os.header index 0e28448..e5ae9b1 100644 --- a/desktop/os.header +++ b/desktop/os.header @@ -674,7 +674,8 @@ define ES_MEMORY_RESERVE_COMMIT_ALL (1 << 0) define ES_PANEL_SWITCHER_DESTROY_PREVIOUS_AFTER_TRANSITION (1 << 0) define ES_ELEMENT_TRANSITION_ENTRANCE (1 << 0) -define ES_ELEMENT_TRANSITION_HIDE_AFTER_COMPLETE (1 << 1) +define ES_ELEMENT_TRANSITION_EXIT (1 << 1) +define ES_ELEMENT_TRANSITION_HIDE_AFTER_COMPLETE (1 << 2) define ES_TEXT_GET_CHARACTER_AT_POINT_MIDDLE (1 << 0) @@ -1105,6 +1106,7 @@ enum EsTransitionType { ES_TRANSITION_REVEAL_DOWN ES_TRANSITION_FADE_IN ES_TRANSITION_FADE_OUT + ES_TRANSITION_FADE ES_TRANSITION_FADE_VIA_TRANSPARENT ES_TRANSITION_SLIDE_UP_OVER ES_TRANSITION_SLIDE_DOWN_OVER @@ -1314,8 +1316,7 @@ struct EsThemeMetrics { uint64_t mask; EsRectangle insets, clipInsets; EsRectangle globalOffset; - int clipEnabled, cursor, entranceTransition, exitTransition; - int entranceDuration, exitDuration; + int clipEnabled, cursor; int preferredWidth, preferredHeight; int minimumWidth, minimumHeight; int maximumWidth, maximumHeight; diff --git a/desktop/theme.cpp b/desktop/theme.cpp index e01bc3c..b0f39c1 100644 --- a/desktop/theme.cpp +++ b/desktop/theme.cpp @@ -200,8 +200,8 @@ typedef struct ThemeLayer { typedef struct ThemeMetrics { Rectangle16 insets, clipInsets; Rectangle16 globalOffset; - uint8_t clipEnabled, cursor, entranceTransition, exitTransition; - uint16_t entranceDuration, exitDuration, fontFamily; + uint8_t clipEnabled, cursor; + uint16_t fontFamily; int16_t preferredWidth, preferredHeight; int16_t minimumWidth, minimumHeight; int16_t maximumWidth, maximumHeight; @@ -1558,10 +1558,6 @@ void ThemeStylePrepare(UIStyle *style, UIStyleKey key) { if (customMetrics->mask & ES_THEME_METRICS_GLOBAL_OFFSET) style->metrics->globalOffset = ES_RECTANGLE_TO_RECTANGLE_8(customMetrics->globalOffset); if (customMetrics->mask & ES_THEME_METRICS_CLIP_ENABLED) style->metrics->clipEnabled = customMetrics->clipEnabled; if (customMetrics->mask & ES_THEME_METRICS_CURSOR) style->metrics->cursor = customMetrics->cursor; - if (customMetrics->mask & ES_THEME_METRICS_ENTRANCE_TRANSITION) style->metrics->entranceTransition = customMetrics->entranceTransition; - if (customMetrics->mask & ES_THEME_METRICS_EXIT_TRANSITION) style->metrics->exitTransition = customMetrics->exitTransition; - if (customMetrics->mask & ES_THEME_METRICS_ENTRANCE_DURATION) style->metrics->entranceDuration = customMetrics->entranceDuration; - if (customMetrics->mask & ES_THEME_METRICS_EXIT_DURATION) style->metrics->exitDuration = customMetrics->exitDuration; if (customMetrics->mask & ES_THEME_METRICS_PREFERRED_WIDTH) style->metrics->preferredWidth = customMetrics->preferredWidth; if (customMetrics->mask & ES_THEME_METRICS_PREFERRED_HEIGHT) style->metrics->preferredHeight = customMetrics->preferredHeight; if (customMetrics->mask & ES_THEME_METRICS_MINIMUM_WIDTH) style->metrics->minimumWidth = customMetrics->minimumWidth; diff --git a/res/Theme Source.dat b/res/Theme Source.dat index b8570c4..4e5bbe9 100644 Binary files a/res/Theme Source.dat and b/res/Theme Source.dat differ diff --git a/res/Themes/Theme.dat b/res/Themes/Theme.dat index 2040f88..e5e0cd8 100644 Binary files a/res/Themes/Theme.dat and b/res/Themes/Theme.dat differ diff --git a/util/designer/designer.c b/util/designer/designer.c index c11b924..e63adb6 100644 --- a/util/designer/designer.c +++ b/util/designer/designer.c @@ -85,7 +85,7 @@ typedef struct ModContext { struct Keyframe *keyframe; } ModContext; -const uint32_t saveFormatVersion = 21; +const uint32_t saveFormatVersion = 22; void SetSelectedItems(ModContext context); void ColorListRefresh(); @@ -1402,6 +1402,10 @@ void StyleSetOp(RfState *state, RfItem *item, void *pointer) { printf("exporting '%.*s' (id: %ld)\n", (int) style->name.byteCount, (char *) style->name.buffer, (style->id << 1) | 1); + for (uintptr_t i = 0; i < arrlenu(style->layers); i++) { + printf("\thas layer %ld\n", style->layers[i]); + } + if (style->id && stylesPath) { fprintf(f, "%s ES_STYLE_", style->publicStyle ? "define" : "private define"); @@ -1491,6 +1495,9 @@ void StyleSetOp(RfState *state, RfItem *item, void *pointer) { header.duration = sequence->duration; header.isLastSequence = j == arrlenu(layer->sequences) - 1; state->access(state, &header, sizeof(header)); + + if (sequence->flagBeforeEnter) printf("before enter %ld\n", layer->id); + if (sequence->flagAfterExit) printf("after exit %ld\n", layer->id); } uint32_t overrideCount = 0; diff --git a/util/designer/designer.rf b/util/designer/designer.rf index c517ca1..b4abc3d 100644 --- a/util/designer/designer.rf +++ b/util/designer/designer.rf @@ -183,10 +183,10 @@ struct LayerMetrics LayerMetrics_Type LayerMetricsOp { Size16_Type Size16 maximumSize #StringOption { "Maximum size" }; Gaps8_Type Gaps8 gaps #StringOption { "Gaps" }; Cursor_Type uint32_t cursor #StringOption { "Cursor" }; - Transition_Type uint32_t entranceTransition #StringOption { "Entrance transition" }; - StyleI16_Type int16_t entranceDuration #StringOption { "Entrance duration (ms)" }; - Transition_Type uint32_t exitTransition #StringOption { "Exit transition" }; - StyleI16_Type int16_t exitDuration #StringOption { "Exit duration (ms)" }; + Transition_Type uint32_t entranceTransition #StringOption { "Entrance transition" } to 21; + StyleI16_Type int16_t entranceDuration #StringOption { "Entrance duration (ms)" } to 21; + Transition_Type uint32_t exitTransition #StringOption { "Exit transition" } to 21; + StyleI16_Type int16_t exitDuration #StringOption { "Exit duration (ms)" } to 21; Rectangle8_Type Rectangle8 globalOffset #StringOption { "Global offset" }; Align_Type uint32_t textVerticalAlign #StringOption { "Text vertical align: " }; Align_Type uint32_t textHorizontalAlign #StringOption { "Text horizontal align: " }; diff --git a/util/designer/reflect.h b/util/designer/reflect.h index a591eda..a9bd283 100644 --- a/util/designer/reflect.h +++ b/util/designer/reflect.h @@ -350,20 +350,22 @@ void RfEnumOp(RfState *state, RfItem *item, void *pointer) { } else if (state->op == RF_OP_LOAD) { RfIntegerLoad(state, pointer, item->byteCount); - uint32_t value = 0; + if (pointer) { + uint32_t value = 0; - if (item->byteCount == 1) { - value = *(uint8_t *) pointer; - } else if (item->byteCount == 2) { - value = *(uint16_t *) pointer; - } else if (item->byteCount == 4) { - value = *(uint32_t *) pointer; - } else { - RF_ASSERT(false); - } + if (item->byteCount == 1) { + value = *(uint8_t *) pointer; + } else if (item->byteCount == 2) { + value = *(uint16_t *) pointer; + } else if (item->byteCount == 4) { + value = *(uint32_t *) pointer; + } else { + RF_ASSERT(false); + } - if (value >= item->type->fieldCount) { - state->error = true; + if (value >= item->type->fieldCount) { + state->error = true; + } } } }