various fixes

This commit is contained in:
nakst 2021-10-13 17:51:49 +01:00
parent be6bd9cce8
commit 2e1327046c
9 changed files with 59 additions and 18 deletions

View File

@ -351,7 +351,8 @@ void FolderDetachInstance(Instance *instance) {
Folder *folder = instance->folder;
if (!folder) return;
instance->folder = nullptr;
folder->attachedInstances.FindAndDeleteSwap(instance, true);
folder->attachedInstances.FindAndDeleteSwap(instance, false /* in case the instance stopped loading the folder before it was ready */);
EsAssert(folder->referenceCount);
folder->referenceCount--;
if (!folder->referenceCount) {

View File

@ -342,7 +342,8 @@ void BlockingTaskQueue(Instance *instance, Task task) {
if (result == ES_ERROR_TIMEOUT_REACHED) {
instance->blockingTaskReachedTimeout = true;
EsDialogShow(instance->window, task.cDescription, -1, INTERFACE_STRING(FileManagerOngoingTaskDescription), ES_ICON_TOOLS_TIMER_SYMBOLIC);
instance->blockingDialog = EsDialogShow(instance->window, task.cDescription, -1,
INTERFACE_STRING(FileManagerOngoingTaskDescription), ES_ICON_TOOLS_TIMER_SYMBOLIC);
// TODO Progress bar; cancelling tasks.
} else {
instance->blockingTaskReachedTimeout = false;

View File

@ -785,7 +785,6 @@ void UIWindowDestroy(EsWindow *window) {
EsHandleClose(window->handle);
window->checkVisible.Free();
window->sizeAlternatives.Free();
EsAssert(!window->dialogs.Length());
window->dialogs.Free();
window->handle = ES_INVALID_HANDLE;
}
@ -6631,11 +6630,11 @@ void UIMouseUp(EsWindow *window, EsMessage *message, bool sendClick) {
EsRectangle bounds = pressed->GetWindowBounds();
message->mouseDown.positionX -= bounds.l;
message->mouseDown.positionY -= bounds.t;
UIMessageSendPropagateToAncestors(pressed, message);
EsMessageSend(pressed, message);
} else {
EsMessage m = {};
m.type = (EsMessageType) (gui.lastClickButton + 1);
UIMessageSendPropagateToAncestors(pressed, &m);
EsMessageSend(pressed, &m);
}
pressed->state &= ~UI_STATE_LEFT_PRESSED;

View File

@ -1007,10 +1007,23 @@ struct EsListView : EsElement {
int64_t wrapLimit = GetWrapLimit();
int64_t fixedMinorSize = (flags & ES_LIST_VIEW_HORIZONTAL) ? fixedHeight : fixedWidth;
intptr_t itemsPerBand = GetItemsPerBand();
int64_t computedMinorGap = (wrapLimit - itemsPerBand * fixedMinorSize) / (itemsPerBand + 1);
int64_t minorStartOffset = computedMinorGap + ((flags & ES_LIST_VIEW_HORIZONTAL) ? style->insets.t : style->insets.l);
intptr_t startInBand = (((flags & ES_LIST_VIEW_HORIZONTAL) ? y1 : x1) - minorStartOffset) / (fixedMinorSize + computedMinorGap);
intptr_t endInBand = (((flags & ES_LIST_VIEW_HORIZONTAL) ? y2 : x2) - minorStartOffset) / (fixedMinorSize + computedMinorGap);
int64_t centerOffset = (flags & ES_LIST_VIEW_CENTER_TILES) ? (wrapLimit - itemsPerBand * (fixedMinorSize + style->gapMinor) + style->gapMinor) / 2 : 0;
int64_t minorStartOffset = centerOffset + ((flags & ES_LIST_VIEW_HORIZONTAL) ? style->insets.t : style->insets.l);
int64_t s0 = (flags & ES_LIST_VIEW_HORIZONTAL) ? y1 : x1;
int64_t s1 = (flags & ES_LIST_VIEW_HORIZONTAL) ? y2 : x2;
int64_t startEdge = minorStartOffset;
int64_t endEdge = minorStartOffset + (fixedMinorSize + style->gapMinor) * itemsPerBand - style->gapMinor;
if (s1 < startEdge || s0 >= endEdge) return;
if (s0 < startEdge) s0 = startEdge;
if (s1 >= endEdge) s1 = endEdge - 1;
intptr_t startInBand = (s0 - startEdge + style->gapMinor /* round up if in gap */) / (fixedMinorSize + style->gapMinor);
intptr_t endInBand = (s1 - startEdge) / (fixedMinorSize + style->gapMinor);
if (startInBand > endInBand) return;
if (adjustStart) {
ListViewGroup *group = &groups[start.iterateIndex.group];
@ -1046,6 +1059,11 @@ struct EsListView : EsElement {
}
}
if ((start.iterateIndex.group == end.iterateIndex.group && start.iterateIndex.index > end.iterateIndex.index)
|| (start.iterateIndex.group > end.iterateIndex.group)) {
return;
}
SetSelected(start.iterateIndex.group, start.iterateIndex.index, end.iterateIndex.group, end.iterateIndex.index, true, toggle,
itemsPerBand, startInBand, endInBand);
} else {

View File

@ -2996,7 +2996,26 @@ const char *KeyboardLayoutLookup(uint32_t scancode, bool isShiftHeld, bool isAlt
uint32_t ScancodeMapToLabel(uint32_t scancode) {
KeyboardLayoutLoad();
// TODO.
const char *string = KeyboardLayoutLookup(scancode, false, false, false, false);
if (string && string[0] && !string[1]) {
char c = string[0];
if (c >= 'a' && c <= 'z') return ES_SCANCODE_A + c - 'a';
if (c >= 'A' && c <= 'Z') return ES_SCANCODE_A + c - 'A';
if (c >= '0' && c <= '9') return ES_SCANCODE_0 + c - '0';
if (c == '/') return ES_SCANCODE_SLASH;
if (c == '[') return ES_SCANCODE_LEFT_BRACE;
if (c == ']') return ES_SCANCODE_RIGHT_BRACE;
if (c == '=') return ES_SCANCODE_EQUALS;
if (c == '-') return ES_SCANCODE_HYPHEN;
if (c == ',') return ES_SCANCODE_COMMA;
if (c == '.') return ES_SCANCODE_PERIOD;
if (c == '\\') return ES_SCANCODE_PUNCTUATION_1;
if (c == ';') return ES_SCANCODE_PUNCTUATION_3;
if (c == '\'') return ES_SCANCODE_PUNCTUATION_4;
if (c == '`') return ES_SCANCODE_PUNCTUATION_5;
}
return scancode;
}

Binary file not shown.

Binary file not shown.

View File

@ -2754,12 +2754,15 @@ int CanvasMessage(UIElement *element, UIMessage message, int di, void *dp) {
CanvasDrawColorSwatch(object, bounds, painter);
} else if (object->type == OBJ_VAR_COLOR || object->type == OBJ_MOD_COLOR) {
CanvasDrawColorSwatch(object, bounds, painter);
uint32_t color = GraphGetColor(object);
bool isLight = EsColorIsLight(color);
char buffer[32];
snprintf(buffer, sizeof(buffer), "%.8X", color);
UIRectangle area = UI_RECT_4(bounds.l, bounds.r, bounds.t, bounds.t + UIMeasureStringHeight());
UIDrawString(painter, area, buffer, -1, isLight ? 0xFF000000 : 0xFFFFFFFF, UI_ALIGN_CENTER, nullptr);
if (canvas->zoom >= 1.0f) {
uint32_t color = GraphGetColor(object);
bool isLight = EsColorIsLight(color);
char buffer[32];
snprintf(buffer, sizeof(buffer), "%.8X", color);
UIRectangle area = UI_RECT_4(bounds.l, bounds.r, bounds.t, bounds.t + UIMeasureStringHeight());
UIDrawString(painter, area, buffer, -1, isLight ? 0xFF000000 : 0xFFFFFFFF, UI_ALIGN_CENTER, nullptr);
}
} else if (object->type == OBJ_VAR_TEXT_STYLE || object->type == OBJ_STYLE) {
CanvasDrawStyle(object, bounds, painter);
} else if (object->type == OBJ_INSTANCE) {

View File

@ -3075,9 +3075,9 @@ int _UIColorPickerMessage(UIElement *element, UIMessage message, int di, void *d
bool hasOpacity = element->flags & UI_COLOR_PICKER_HAS_OPACITY;
if (message == UI_MSG_GET_WIDTH) {
return (hasOpacity ? 240 : 200) * element->window->scale;
return (hasOpacity ? 280 : 240) * element->window->scale;
} else if (message == UI_MSG_GET_HEIGHT) {
return 160 * element->window->scale;
return 200 * element->window->scale;
} else if (message == UI_MSG_LAYOUT) {
UIRectangle bounds = element->bounds;