diff --git a/desktop/api.cpp b/desktop/api.cpp index 5208913..0666a54 100644 --- a/desktop/api.cpp +++ b/desktop/api.cpp @@ -203,6 +203,10 @@ struct APIInstance { EsFileStore *fileStore; + // Do not propagate messages about this instance to the application. + // Currently only used for inspectors. + bool internalOnly; + union { EsInstanceClassEditorSettings editorSettings; EsInstanceClassViewerSettings viewerSettings; @@ -714,8 +718,13 @@ const EsApplicationStartupInformation *EsInstanceGetStartupInformation(EsInstanc void EsInstanceDestroy(EsInstance *instance) { InspectorWindow **inspector = &((APIInstance *) instance->_private)->attachedInspector; - if (*inspector) EsInstanceDestroy(*inspector); - *inspector = nullptr; + + if (*inspector) { + EsInstanceDestroy(*inspector); + (*inspector)->window->InternalDestroy(); + *inspector = nullptr; + } + UndoManagerDestroy(instance->undoManager); EsAssert(instance->window->instance == instance); instance->window->destroyInstanceAfterClose = true; @@ -957,6 +966,12 @@ EsMessage *EsMessageReceive() { return &message.message; } } + } else if (type == ES_MSG_INSTANCE_DESTROY) { + APIInstance *instance = (APIInstance *) message.message.instanceDestroy.instance->_private; + + if (!instance->internalOnly) { + return &message.message; + } } else { return &message.message; } diff --git a/desktop/desktop.cpp b/desktop/desktop.cpp index bc4b811..8bbe113 100644 --- a/desktop/desktop.cpp +++ b/desktop/desktop.cpp @@ -729,6 +729,65 @@ int TaskBarMessage(EsElement *element, EsMessage *message) { return 0; } +int TaskBarTasksButtonMessage(EsElement *element, EsMessage *message) { + if (message->type == ES_MSG_GET_WIDTH) { + message->measure.width = GetConstantNumber("taskBarTasksButtonWidth"); + return ES_HANDLED; + } else if (message->type == ES_MSG_PAINT_ICON) { + float progress = 0.33f; + + uint32_t color1 = GetConstantNumber("taskBarTasksButtonWheelColor1"); + uint32_t color2 = GetConstantNumber("taskBarTasksButtonWheelColor2"); + + EsPainter *painter = message->painter; + + EsRectangle destination = EsPainterBoundsClient(painter); + destination = EsRectangleFit(destination, ES_RECT_2S(1, 1), true); // Center with a 1:1 aspect ratio. + + RastSurface surface = {}; + surface.buffer = (uint32_t *) painter->target->bits; + surface.stride = painter->target->stride; + + if (RastSurfaceInitialise(&surface, painter->target->width, painter->target->height, true)) { + RastVertex center = { (destination.l + destination.r) * 0.5f, (destination.t + destination.b) * 0.5f }; + + RastContourStyle style = {}; + style.internalWidth = 5.0f * theming.scale; + style.capMode = RAST_LINE_CAP_FLAT; + + RastPaint paint = {}; + paint.type = RAST_PAINT_SOLID; + + { + paint.solid.color = color1 & 0xFFFFFF; + paint.solid.alpha = (color1 >> 24) / 255.0f; + + RastPath path = {}; + RastPathAppendArc(&path, center, Width(destination) * 0.45f, ES_PI * 2.0f, 0.0f); + RastShape shape = RastShapeCreateContour(&path, style, true); + RastSurfaceFill(surface, shape, paint, false); + RastPathDestroy(&path); + } + + { + paint.solid.color = color2 & 0xFFFFFF; + paint.solid.alpha = (color2 >> 24) / 255.0f; + + RastPath path = {}; + RastPathAppendArc(&path, center, Width(destination) * 0.45f, ES_PI * 1.5f + progress * ES_PI * 2.0f, ES_PI * 1.5f); + RastShape shape = RastShapeCreateContour(&path, style, true); + RastSurfaceFill(surface, shape, paint, false); + RastPathDestroy(&path); + } + } + + RastSurfaceDestroy(&surface); + return ES_HANDLED; + } + + return 0; +} + void ShutdownModalCreate() { if (desktop.shutdownWindowOpen) { return; @@ -1824,13 +1883,15 @@ void DesktopSetup() { desktop.taskBar.taskList.Initialise(panel, ES_CELL_FILL, ReorderListMessage, nullptr); desktop.taskBar.taskList.cName = "task list"; + EsButton *tasksButton = EsButtonCreate(panel, ES_ELEMENT_HIDDEN, ES_STYLE_TASK_BAR_BUTTON, "Copying files" ELLIPSIS, -1); + tasksButton->messageUser = TaskBarTasksButtonMessage; + EsButton *shutdownButton = EsButtonCreate(panel, ES_FLAGS_DEFAULT, ES_STYLE_TASK_BAR_EXTRA); EsButtonSetIcon(shutdownButton, ES_ICON_SYSTEM_SHUTDOWN_SYMBOLIC); EsButtonOnCommand(shutdownButton, [] (EsInstance *, EsElement *, EsCommand *) { ShutdownModalCreate(); }); - } } diff --git a/desktop/gui.cpp b/desktop/gui.cpp index e008ea0..84f2929 100644 --- a/desktop/gui.cpp +++ b/desktop/gui.cpp @@ -6818,7 +6818,7 @@ struct InspectorElementEntry { }; struct InspectorWindow : EsInstance { - EsInstance *instance; + EsInstance *instance; // The instance being inspected. EsListView *elementList; Array elements; @@ -6854,7 +6854,8 @@ int InspectorElementItemCallback(EsElement *element, EsMessage *message) { else entry->element->Repaint(true); inspector->hoveredElement = *entry; } else if (message->type == ES_MSG_HOVERED_END || message->type == ES_MSG_DESTROY) { - InspectorElementEntry *entry = &inspector->elements[EsListViewGetIndexFromItem(element)]; + EsListViewIndex index = EsListViewGetIndexFromItem(element); + InspectorElementEntry *entry = &inspector->elements[index]; if (entry->element->parent) entry->element->parent->Repaint(true); else entry->element->Repaint(true); inspector->hoveredElement = {}; @@ -7304,6 +7305,7 @@ void InspectorSetup(EsWindow *window) { inspector->window = window; InstanceSetup(inspector); inspector->instance = window->instance; + ((APIInstance *) inspector->_private)->internalOnly = true; window->instance = inspector; inspector->selectedElement = -1; diff --git a/desktop/renderer.cpp b/desktop/renderer.cpp index fbbde89..47cf175 100644 --- a/desktop/renderer.cpp +++ b/desktop/renderer.cpp @@ -815,6 +815,19 @@ void RastPathAppendLinear(RastPath *path, RastVertex *vertices, size_t vertexCou } } +void RastPathAppendArc(RastPath *path, RastVertex center, float radius, float startAngle, float endAngle) { + float deltaAngle = EsCRTacosf(1 - 0.5f * RAST_FLATTEN_TOLERANCE * RAST_FLATTEN_TOLERANCE / radius / radius); // From cosine rule. + size_t steps = EsCRTfabsf(endAngle - startAngle) / deltaAngle; + + for (uintptr_t i = 0; i <= steps; i++) { + float angle = (endAngle - startAngle) / steps * i + startAngle; + RastVertex vertex; + vertex.x = center.x + radius * EsCRTcosf(angle); + vertex.y = center.y + radius * EsCRTsinf(angle); + _RastPathAddVertex(path, vertex); + } +} + void RastPathTranslate(RastPath *path, float x, float y) { if (!x && !y) return; diff --git a/desktop/theme.cpp b/desktop/theme.cpp index e16314f..56655b0 100644 --- a/desktop/theme.cpp +++ b/desktop/theme.cpp @@ -542,6 +542,15 @@ void ThemeFillCorner(EsPainter *painter, EsRectangle bounds, int cx, int cy, uint32_t borderAlpha = borderColor >> 24; if (outsideCount == (1 << (2 * STYLE_CORNER_OVERSAMPLING))) { + } else if (mainPaint.type == THEME_PAINT_OVERWRITE) { + // TODO Support borders when using an overwrite main paint. + uint32_t m1 = ((mainCount << 8) >> STYLE_CORNER_OVERSAMPLING * 2); + uint32_t m2 = 256 - m1; + uint32_t r2 = m2 * (*b & 0x00FF00FF); + uint32_t g2 = m2 * ((*b >> 8) & 0x00FF00FF); + uint32_t r1 = m1 * (mainColor & 0x00FF00FF); + uint32_t g1 = m1 * ((mainColor >> 8) & 0x00FF00FF); + *b = (0xFF00FF00 & (g1 + g2)) | (0x00FF00FF & ((r1 + r2) >> 8)); } else if (outsideCount || ((borderColor & 0xFF000000) != 0xFF000000) || (mainColor & 0xFF000000) != 0xFF000000) { BlendPixel(b, (mainColor & 0x00FFFFFF) | (((mainAlpha * mainCount) << (24 - STYLE_CORNER_OVERSAMPLING * 2)) & 0xFF000000), painter->target->fullAlpha); diff --git a/res/System Configuration Template.ini b/res/System Configuration Template.ini index 7a02d48..85f44aa 100644 --- a/res/System Configuration Template.ini +++ b/res/System Configuration Template.ini @@ -1,18 +1,13 @@ [general] -; General settings. -startup_sound=0:/Essence/Media/Startup Sound.wav fonts_path=0:/Essence/Fonts temporary_path=0:/Essence/Temporary default_settings_path=0:/Settings default_user_documents_path=0:/ -installation_state=0 click_chain_timeout_ms=500 show_cursor_shadow=1 -use_cursor_alt_slow=1 scroll_lines_per_notch=3 [ui] -; User interface settings that are accessible by all applications. font_fallback=Inter font_sans=Inter font_serif=Inter diff --git a/res/Theme Source.dat b/res/Theme Source.dat index 4ba3ad0..bec4f90 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 2d2069f..1e07420 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 96eacae..bccf10b 100644 --- a/util/designer/designer.c +++ b/util/designer/designer.c @@ -769,6 +769,11 @@ void LayerBoxOp(RfState *state, RfItem *item, void *pointer) { ExportState *export = (ExportState *) state; LayerBox *box = (LayerBox *) pointer; +#if 0 +#define EsContainerOf(type, member, pointer) ((type *) ((uint8_t *) pointer - offsetof(type, member))) + uint64_t layerID = EsContainerOf(Layer, base.box, box)->id; +#endif + ThemeLayerBox themeBox = { 0 }; ExportAddPathToOffset2(export, LayerBox_borders, Rectangle8_l, offsetof(ThemeLayerBox, borders.l)); ExportAddPathToOffset2(export, LayerBox_borders, Rectangle8_r, offsetof(ThemeLayerBox, borders.r)); @@ -1943,8 +1948,8 @@ int CanvasMessage(UIElement *element, UIMessage message, int di, void *dp) { } if (previewShowGuides->e.flags & UI_BUTTON_CHECKED) { - UIDrawBlock(painter, UIRectangleAdd(generalBounds, UI_RECT_1I(-5)), 0xFFA2A0A4); - UIDrawBlock(painter, UIRectangleAdd(generalBounds, UI_RECT_1I(-3)), 0xFFC2C0C4); + UIDrawBlock(painter, UIRectangleAdd(generalBounds, UI_RECT_1I(-2)), 0xFFA2A0A4); + UIDrawBlock(painter, UIRectangleAdd(generalBounds, UI_RECT_1I(0)), 0xFFC2C0C4); } Rectangle8 opaqueInsets = StyleCalculateOpaqueInsets(selected.style->layers);