This commit is contained in:
nakst 2021-09-19 11:25:40 +01:00
parent 7bc509cb4c
commit 5b9b87afe9
3 changed files with 25 additions and 11 deletions

View File

@ -3611,8 +3611,8 @@ int ProcessCanvasPaneMessage(EsElement *element, EsMessage *message) {
// TODO Set cursor.
EsPoint point = EsMouseGetPosition(pane);
pane->zoomFit = false;
pane->panX -= (float) (point.x - pane->lastPanPoint.y) / pane->zoom;
pane->panY -= (float) (point.x - pane->lastPanPoint.y) / pane->zoom;
pane->panX -= (float) (point.x - pane->lastPanPoint.x) / pane->zoom;
pane->panY -= (float) (point.y - pane->lastPanPoint.y) / pane->zoom;
pane->lastPanPoint = point;
EsElementRelayout(pane);
} else if (message->type == ES_MSG_GET_CURSOR && pane->window->dragged == pane) {
@ -4143,7 +4143,7 @@ void DrawStyledBox(EsPainter *painter, StyledBox box) {
layerBox.mainPaintType = THEME_PAINT_SOLID;
layerBox.borderPaintType = THEME_PAINT_SOLID;
uint8_t info[sizeof(ThemeLayerBox) + sizeof(ThemePaintCustom) + sizeof(ThemePaintSolid) * 2];
uint8_t info[sizeof(ThemeLayerBox) + sizeof(ThemePaintCustom) + sizeof(ThemePaintSolid) * 2] = {};
if (box.fragmentShader) {
ThemeLayerBox *infoBox = (ThemeLayerBox *) info;
@ -4962,7 +4962,7 @@ EsSplitter *EsSplitterCreate(EsElement *parent, uint64_t flags, const EsStyle *s
// aspect ratio; sizing
// upscale/downscale quality
// subregion, transformations
// transparency, IsRegionCompletelyOpaque, proper blending mode with fragmentShader in DrawStyledBox
// transparency, IsRegionCompletelyOpaque
// image sets, DPI; SVG scaling
// embedding in TextDisplay
// merge with IconDisplay
@ -6850,7 +6850,7 @@ void UIWindowLayoutNow(EsWindow *window, ProcessMessageTiming *timing) {
bool UISetCursor(EsWindow *window) {
EsCursorStyle cursorStyle = ES_CURSOR_NORMAL;
EsElement *element = window->pressed ?: window->hovered;
EsElement *element = window->dragged ?: window->pressed ?: window->hovered;
if (element) {
EsMessage m = { ES_MSG_GET_CURSOR };
@ -7165,7 +7165,8 @@ void UIProcessWindowManagerMessage(EsWindow *window, EsMessage *message, Process
UIFindHoverElement(window);
bool changedCursor = UISetCursor(window);
if (THEME_RECT_VALID(window->updateRegion) && window->width == (int) window->windowWidth && window->height == (int) window->windowHeight) {
if (window->width == (int) window->windowWidth && window->height == (int) window->windowHeight
&& THEME_RECT_VALID(window->updateRegion) && !window->doNotPaint) {
UIWindowPaintNow(window, timing, message->type == ES_MSG_WINDOW_RESIZED);
} else if (changedCursor) {
EsSyscall(ES_SYSCALL_SCREEN_FORCE_UPDATE, 0, 0, 0, 0);

View File

@ -604,6 +604,10 @@ void ThemeFillBlurCorner(EsPainter *painter, EsRectangle bounds, int cx, int cy,
ES_FUNCTION_OPTIMISE_O2
void GradientCacheSetup(GradientCache *cache, const ThemePaintLinearGradient *gradient, int width, int height, EsBuffer *data) {
if (!gradient) {
return;
}
width--, height--;
cache->dx = gradient->transform[0] / width * (GRADIENT_CACHE_COUNT << GRADIENT_COORD_BASE);

View File

@ -93,6 +93,7 @@ struct WindowManager {
KEvent windowsToCloseEvent;
EsObjectID currentWindowID;
size_t inspectorWindowCount;
EsMessageType pressedWindowButton;
// Cursor:
@ -547,16 +548,24 @@ void WindowManager::ClickCursor(unsigned buttons) {
// TODO Setting pressedWindow if holding with other mouse buttons.
if (message.type == ES_MSG_MOUSE_LEFT_DOWN) {
pressedWindow = window;
} else if (message.type == ES_MSG_MOUSE_LEFT_UP) {
if (message.type == ES_MSG_MOUSE_LEFT_DOWN || message.type == ES_MSG_MOUSE_MIDDLE_DOWN || message.type == ES_MSG_MOUSE_RIGHT_DOWN) {
if (!pressedWindow) {
pressedWindowButton = message.type;
pressedWindow = window;
}
}
if (message.type == ES_MSG_MOUSE_LEFT_UP || message.type == ES_MSG_MOUSE_MIDDLE_UP || message.type == ES_MSG_MOUSE_RIGHT_UP) {
if (pressedWindow) {
// Always send the messages to the pressed window, if there is one.
window = pressedWindow;
}
pressedWindow = nullptr;
moveCursorNone = true; // We might have moved outside the window.
if (pressedWindowButton == message.type - 1) {
// Only end pressing if this is the same button as pressing started with.
pressedWindow = nullptr;
moveCursorNone = true; // We might have moved outside the window.
}
}
if (window) {