From 69c81e774368713207ab9921e1cc8ba41b4f5c6d Mon Sep 17 00:00:00 2001 From: nakst <> Date: Fri, 8 Oct 2021 21:57:58 +0100 Subject: [PATCH] bugfixes --- apps/system_monitor.cpp | 4 + desktop/gui.cpp | 13 ++- desktop/theme.cpp | 8 +- ports/freetype/build.sh | 2 +- ports/harfbuzz/build.sh | 2 +- res/Theme Source.dat | Bin 559912 -> 556632 bytes res/Theme.dat | Bin 29384 -> 29368 bytes util/designer2.cpp | 195 +++++++++++++++++++++------------------- 8 files changed, 122 insertions(+), 102 deletions(-) diff --git a/apps/system_monitor.cpp b/apps/system_monitor.cpp index 1ee7801..6990705 100644 --- a/apps/system_monitor.cpp +++ b/apps/system_monitor.cpp @@ -186,6 +186,10 @@ void UpdateProcesses(Instance *instance) { totalCPUTimeSlices += processes[i].cpuUsage; } + if (!totalCPUTimeSlices) { + totalCPUTimeSlices = 1; + } + int64_t percentageSum = 0; for (uintptr_t i = 0; i < processes.Length(); i++) { diff --git a/desktop/gui.cpp b/desktop/gui.cpp index 2d76057..ca50358 100644 --- a/desktop/gui.cpp +++ b/desktop/gui.cpp @@ -7017,13 +7017,18 @@ bool UIHandleKeyMessage(EsWindow *window, EsMessage *message) { if (message->keyboard.scancode == ES_SCANCODE_TAB && (message->keyboard.modifiers & ~ES_MODIFIER_SHIFT) == 0) { EsElement *element = window->focused ?: window; EsElement *start = element; + bool backwards = message->keyboard.modifiers & ES_MODIFIER_SHIFT; - do { - element = UITabTraversalDo(element, message->keyboard.modifiers & ES_MODIFIER_SHIFT); - } while (!element->IsTabTraversable() && element != start); + tryAgain: + element = UITabTraversalDo(element, backwards); + if (!element->IsTabTraversable() && element != start) goto tryAgain; if (element->state & UI_STATE_RADIO_GROUP) { - element = EsPanelRadioGroupGetChecked((EsPanel *) element); + if (backwards && start->parent == element) { + goto tryAgain; + } else { + element = EsPanelRadioGroupGetChecked((EsPanel *) element); + } } EsElementFocus(element, ES_ELEMENT_FOCUS_ENSURE_VISIBLE | ES_ELEMENT_FOCUS_FROM_KEYBOARD); diff --git a/desktop/theme.cpp b/desktop/theme.cpp index 50dffa1..6040a3a 100644 --- a/desktop/theme.cpp +++ b/desktop/theme.cpp @@ -1577,10 +1577,10 @@ void ThemeStylePrepare(UIStyle *style, UIStyleKey key) { style->borders.t = themeStyle->approximateBorders.t * key.scale; style->borders.b = themeStyle->approximateBorders.b * key.scale; - style->paintOutsets.l = themeStyle->paintOutsets.l * key.scale; - style->paintOutsets.r = themeStyle->paintOutsets.r * key.scale; - style->paintOutsets.t = themeStyle->paintOutsets.t * key.scale; - style->paintOutsets.b = themeStyle->paintOutsets.b * key.scale; + style->paintOutsets.l = EsCRTceilf(themeStyle->paintOutsets.l * key.scale); + style->paintOutsets.r = EsCRTceilf(themeStyle->paintOutsets.r * key.scale); + style->paintOutsets.t = EsCRTceilf(themeStyle->paintOutsets.t * key.scale); + style->paintOutsets.b = EsCRTceilf(themeStyle->paintOutsets.b * key.scale); if (style->opaqueInsets.l != 0x7F) { style->opaqueInsets.l = themeStyle->opaqueInsets.l * key.scale; diff --git a/ports/freetype/build.sh b/ports/freetype/build.sh index ef0a982..8376e1c 100755 --- a/ports/freetype/build.sh +++ b/ports/freetype/build.sh @@ -15,7 +15,7 @@ if [ ! -d "bin/freetype" ]; then cd bin/freetype ./configure --without-zlib --without-bzip2 --without-png --without-harfbuzz \ - CC=x86_64-essence-gcc CFLAGS="-g -ffreestanding -DARCH_X86_64 -Wno-unused-function" \ + CC=x86_64-essence-gcc CFLAGS="-g -ffreestanding -DARCH_X86_64 -Wno-unused-function -O3" \ LDFLAGS="-nostdlib -lgcc" --host=x86_64-essence > ../freetype_configure.txt make ANSIFLAGS="" > /dev/null cd ../.. diff --git a/ports/harfbuzz/build.sh b/ports/harfbuzz/build.sh index 34c1655..a777757 100755 --- a/ports/harfbuzz/build.sh +++ b/ports/harfbuzz/build.sh @@ -11,7 +11,7 @@ if [ ! -d "bin/harfbuzz" ]; then cd bin/harfbuzz ./configure --with-glib=no --with-icu=no --with-freetype=no --with-cairo=no --with-fontconfig=no --enable-shared \ - CFLAGS="-g -O2 -DHB_TINY" CXXFLAGS="-g -O2 -DHB_TINY" > ../harfbuzz_configure.txt + CFLAGS="-g -O3 -DHB_TINY" CXXFLAGS="-g -O3 -DHB_TINY" > ../harfbuzz_configure.txt cd ../.. cp ports/harfbuzz/essence-config.h bin/harfbuzz/config.h diff --git a/res/Theme Source.dat b/res/Theme Source.dat index d03beeaeec50998aec64b35030dd47517a7c89d1..beb7658e00c66bf1c9d56fb1fa98f543403432bf 100644 GIT binary patch delta 844 zcmX|9QAkr^6yCr8?(TQaZEES1Nz;^#GFV_186s3PWQ9_RLgWmiRijL#dx-=!ZD~u) zvpi~(W)b+HIl026haL=rJxCb{78LCvL}EokLJupu>Rk^9{_i{I|IRtz|4$4ReMlA> zh(@D1Pc@pS9KI;0dzVa_jrEA2nw zgj!yZnhh}mwjw833Po5jhQO7zbsjV|qWPmX4Sc2r`mM_a?~D~tY2qc(Y|WIsB_1bo&H+R7Y2N{!$ z{$E-yyuPsk@#PYDWfCBAJ){k<lj8FnH?-#jTE~VBb$j8 zC-n3xUfmC=J8sEK&A}tO)cg}rn0`w-I=GJ`pP=@)18e~iEErPJY_|xFMceh(9U=&)7Mou4z%{l-`di_H6YUxb4@&@e7rj=OpSX(S7vS}3| zbvVas9XPOCvA{j5b>d((6tWW-&ZB1BYi0TLhhk~8pjh_i&{cw# zJX(c6ixjoCJZdL!=(H=4$frthO6cT7K0n`z_Da1IEy_2-mtTnpC;#ekpq*MVa+Na# zy83y!t6%^9IU#aO8LM}t%pI23n%Oc_Ar9EM2FRehWZyOB&P^4$loy!5&o@~%uv6BD jc217oWydL;^_mUt%a?q9CE7e_aqu~q=w%E``&jZHBWyj< delta 1245 zcmZ9Le`s4(6vuPlyLs;>&5sxAXjiv2U5g1tW~!yDC~Yd4*0RnH1C3o|4Q68#=U(eH zZ)#b)v9)7e+w^2RRR;Et%~t3iuRKRK{6Um~6Cw_sQ2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%ptSaC-ZqiZF~NI>@s(Tz?i9ub zz!X>nZUbgC+u$BZNM)=6i~|i{DjygHvmhy*v2JkLiND5yk-=CW_ypK98S4RW zA7JbOaJt|J=3K0o83*AA`d`LxVIT<~iC`9EV~0^I@Byd+BVY-vW}{O#It44B1O$-UB0`CYP}rU=0Ml7!>*%84G|(un62o zVFL?5*3Ovm5Xu617s#Smh=Ml)W`HbyzA}s)%z=b*#xC~aHUn0H z&xee_EJ#8Dn+L86bO_-tSOtGnmu_$aSWs7t8YBqZwMZWLUcsz^ z2f%q8NdRvhep?*IZ3V=gz*+%&J&ZtWV60AZlCfK-5VR4AfCZ4%gam-C8J&YE5O*3Q z1xp|vr>F$n0+s+q31&dl8O#>A0xV|{?<{+j&7xtP!^>a^ID>Ei%fNLWn+DtkNf*!t a_EsbalG?Cuz!+fd7%3P4OTgQ~*#7_`Yb{>@ diff --git a/util/designer2.cpp b/util/designer2.cpp index b71b993..829836b 100644 --- a/util/designer2.cpp +++ b/util/designer2.cpp @@ -1942,6 +1942,99 @@ uint32_t GraphGetColorFromProperty(Property *property) { ////////////////////////////////////////////////////////////// +Rectangle8 ExportCalculatePaintOutsets(Object *object) { + Rectangle8 paintOutsets = {}; + + int32_t layerCount = PropertyReadInt32(object, "layers_count"); + if (layerCount < 0) layerCount = 0; + if (layerCount > 100) layerCount = 100; + + for (int32_t i = 0; i < layerCount; i++) { + char cPropertyName[PROPERTY_NAME_SIZE]; + sprintf(cPropertyName, "layers_%d_layer", i); + Property *layerProperty = PropertyFind(object, cPropertyName, PROP_OBJECT); + Object *layerObject = ObjectFind(layerProperty ? layerProperty->object : 0); + if (!layerObject) continue; + +#define LAYER_READ_INT32(x) sprintf(cPropertyName, "layers_%d_" #x, i); int8_t x = PropertyReadInt32(object, cPropertyName) + LAYER_READ_INT32(offset0); + LAYER_READ_INT32(offset1); + LAYER_READ_INT32(offset2); + LAYER_READ_INT32(offset3); + LAYER_READ_INT32(position0); + LAYER_READ_INT32(position1); + LAYER_READ_INT32(position2); + LAYER_READ_INT32(position3); +#undef LAYER_READ_INT32 + + if (layerObject->type == OBJ_LAYER_BOX) { + Object *object = layerObject; + int depth = 0; + + while (object && (depth++ < 100)) { + int32_t boxOffset0 = PropertyReadInt32(object, "offset0"); + int32_t boxOffset1 = PropertyReadInt32(object, "offset1"); + int32_t boxOffset2 = PropertyReadInt32(object, "offset2"); + int32_t boxOffset3 = PropertyReadInt32(object, "offset3"); + if (boxOffset0 < offset0) offset0 = boxOffset0; + if (boxOffset1 > offset1) offset1 = boxOffset1; + if (boxOffset2 < offset2) offset2 = boxOffset2; + if (boxOffset3 > offset3) offset3 = boxOffset3; + Property *property = PropertyFind(object, "_parent", PROP_OBJECT); + object = ObjectFind(property ? property->object : 0); + } + } + + if (position0 == 0 && -offset0 > paintOutsets.l) paintOutsets.l = -offset0; + if (position1 == 100 && offset1 > paintOutsets.r) paintOutsets.r = offset1; + if (position2 == 0 && -offset2 > paintOutsets.t) paintOutsets.t = -offset2; + if (position3 == 100 && offset3 > paintOutsets.b) paintOutsets.b = offset3; + } + + return paintOutsets; +} + +Rectangle8 ExportCalculateOpaqueInsets(Object *object) { + return { 0x7F, 0x7F, 0x7F, 0x7F }; // TODO; +} + +Rectangle8 ExportCalculateApproximateBorders(Object *object) { + int32_t layerCount = PropertyReadInt32(object, "layers_count"); + if (layerCount < 0) layerCount = 0; + if (layerCount > 100) layerCount = 100; + + for (int32_t i = 0; i < layerCount; i++) { + char cPropertyName[PROPERTY_NAME_SIZE]; + sprintf(cPropertyName, "layers_%d_layer", i); + Property *layerProperty = PropertyFind(object, cPropertyName, PROP_OBJECT); + Object *layerObject = ObjectFind(layerProperty ? layerProperty->object : 0); + if (!layerObject) continue; + +#define LAYER_READ_INT32(x) sprintf(cPropertyName, "layers_%d_" #x, i); int8_t x = PropertyReadInt32(object, cPropertyName) + LAYER_READ_INT32(position0); + LAYER_READ_INT32(position1); + LAYER_READ_INT32(position2); + LAYER_READ_INT32(position3); + LAYER_READ_INT32(mode); +#undef LAYER_READ_INT32 + + if (layerObject->type == OBJ_LAYER_BOX && position0 == 0 && position1 == 100 && position2 == 0 && position3 == 100 + && !PropertyReadInt32(layerObject, "shadowHiding") && !PropertyReadInt32(layerObject, "isBlurred") + && mode == THEME_LAYER_MODE_BACKGROUND && PropertyFind(layerObject, "borderPaint")) { + return { + (int8_t) PropertyReadInt32(layerObject, "borders0"), + (int8_t) PropertyReadInt32(layerObject, "borders1"), + (int8_t) PropertyReadInt32(layerObject, "borders2"), + (int8_t) PropertyReadInt32(layerObject, "borders3"), + }; + } + } + + return {}; +} + +////////////////////////////////////////////////////////////// + struct ExportContext { EsBuffer *baseData; EsBuffer *overrideData; @@ -2535,7 +2628,16 @@ int CanvasMessage(UIElement *element, UIMessage message, int di, void *dp) { } else if (object->type == OBJ_INSTANCE) { Property *style = PropertyFind(object, "style", PROP_OBJECT); canvas->previewStateActive = object->id == selectedObjectID; - CanvasDrawStyle(ObjectFind(style ? style->object : 0), bounds, painter); + Object *styleObject = ObjectFind(style ? style->object : 0); + Rectangle8 paintOutsets = ExportCalculatePaintOutsets(PropertyFindOrInheritReadObject(styleObject, "appearance")); + UIRectangle clip = bounds; + clip.l -= ceilf(paintOutsets.l * canvas->zoom); + clip.r += ceilf(paintOutsets.r * canvas->zoom); + clip.t -= ceilf(paintOutsets.t * canvas->zoom); + clip.b += ceilf(paintOutsets.b * canvas->zoom); + UIPainter painter2 = *painter; + painter2.clip = UIRectangleIntersection(painter2.clip, clip); + CanvasDrawStyle(styleObject, bounds, &painter2); } else if (object->type == OBJ_LAYER_METRICS) { // TODO Visually show the preferred size, insets and gaps? UIDrawString(painter, bounds, "Metrics", -1, 0xFF000000, UI_ALIGN_CENTER, nullptr); @@ -2968,97 +3070,6 @@ void ObjectDuplicateCommand(void *) { ////////////////////////////////////////////////////////////// -Rectangle8 ExportCalculatePaintOutsets(Object *object) { - Rectangle8 paintOutsets = {}; - - int32_t layerCount = PropertyReadInt32(object, "layers_count"); - if (layerCount < 0) layerCount = 0; - if (layerCount > 100) layerCount = 100; - - for (int32_t i = 0; i < layerCount; i++) { - char cPropertyName[PROPERTY_NAME_SIZE]; - sprintf(cPropertyName, "layers_%d_layer", i); - Property *layerProperty = PropertyFind(object, cPropertyName, PROP_OBJECT); - Object *layerObject = ObjectFind(layerProperty ? layerProperty->object : 0); - if (!layerObject) continue; - -#define LAYER_READ_INT32(x) sprintf(cPropertyName, "layers_%d_" #x, i); int8_t x = PropertyReadInt32(object, cPropertyName) - LAYER_READ_INT32(offset0); - LAYER_READ_INT32(offset1); - LAYER_READ_INT32(offset2); - LAYER_READ_INT32(offset3); - LAYER_READ_INT32(position0); - LAYER_READ_INT32(position1); - LAYER_READ_INT32(position2); - LAYER_READ_INT32(position3); -#undef LAYER_READ_INT32 - - if (layerObject->type == OBJ_LAYER_BOX) { - Object *object = layerObject; - int depth = 0; - - while (object && (depth++ < 100)) { - int32_t boxOffset0 = PropertyReadInt32(object, "offset0"); - int32_t boxOffset1 = PropertyReadInt32(object, "offset1"); - int32_t boxOffset2 = PropertyReadInt32(object, "offset2"); - int32_t boxOffset3 = PropertyReadInt32(object, "offset3"); - if (boxOffset0 < offset0) offset0 = boxOffset0; - if (boxOffset1 > offset1) offset1 = boxOffset1; - if (boxOffset2 < offset2) offset2 = boxOffset2; - if (boxOffset3 > offset3) offset3 = boxOffset3; - Property *property = PropertyFind(object, "_parent", PROP_OBJECT); - object = ObjectFind(property ? property->object : 0); - } - } - - if (position0 == 0 && -offset0 > paintOutsets.l) paintOutsets.l = -offset0; - if (position1 == 100 && offset1 > paintOutsets.r) paintOutsets.r = offset1; - if (position2 == 0 && -offset2 > paintOutsets.t) paintOutsets.t = -offset2; - if (position3 == 100 && offset3 > paintOutsets.b) paintOutsets.b = offset3; - } - - return paintOutsets; -} - -Rectangle8 ExportCalculateOpaqueInsets(Object *object) { - return { 0x7F, 0x7F, 0x7F, 0x7F }; // TODO; -} - -Rectangle8 ExportCalculateApproximateBorders(Object *object) { - int32_t layerCount = PropertyReadInt32(object, "layers_count"); - if (layerCount < 0) layerCount = 0; - if (layerCount > 100) layerCount = 100; - - for (int32_t i = 0; i < layerCount; i++) { - char cPropertyName[PROPERTY_NAME_SIZE]; - sprintf(cPropertyName, "layers_%d_layer", i); - Property *layerProperty = PropertyFind(object, cPropertyName, PROP_OBJECT); - Object *layerObject = ObjectFind(layerProperty ? layerProperty->object : 0); - if (!layerObject) continue; - -#define LAYER_READ_INT32(x) sprintf(cPropertyName, "layers_%d_" #x, i); int8_t x = PropertyReadInt32(object, cPropertyName) - LAYER_READ_INT32(position0); - LAYER_READ_INT32(position1); - LAYER_READ_INT32(position2); - LAYER_READ_INT32(position3); - LAYER_READ_INT32(mode); -#undef LAYER_READ_INT32 - - if (layerObject->type == OBJ_LAYER_BOX && position0 == 0 && position1 == 100 && position2 == 0 && position3 == 100 - && !PropertyReadInt32(layerObject, "shadowHiding") && !PropertyReadInt32(layerObject, "isBlurred") - && mode == THEME_LAYER_MODE_BACKGROUND && PropertyFind(layerObject, "borderPaint")) { - return { - (int8_t) PropertyReadInt32(layerObject, "borders0"), - (int8_t) PropertyReadInt32(layerObject, "borders1"), - (int8_t) PropertyReadInt32(layerObject, "borders2"), - (int8_t) PropertyReadInt32(layerObject, "borders3"), - }; - } - } - - return {}; -} - #ifndef OS_ESSENCE void Export() { DocumentLoad();