mirror of https://gitlab.com/nakst/essence
simplify canvas pane shadow
This commit is contained in:
parent
10d936d7fc
commit
7bc509cb4c
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
// TODO Possible candidates for moving in the core API:
|
// TODO Possible candidates for moving in the core API:
|
||||||
// - String/paths utils
|
// - String/paths utils
|
||||||
// - Blocking/non-blocking task systems
|
// - Blocking task systems
|
||||||
|
|
||||||
// TODO Don't show modals if a folder can't be loaded.
|
// TODO Don't show modals if a folder can't be loaded.
|
||||||
// Instead, show a list view with an error message,
|
// Instead, show a list view with an error message,
|
||||||
|
|
|
@ -564,7 +564,7 @@ int EsMessageSend(EsElement *element, EsMessage *message) {
|
||||||
response = element->messageClass(element, message);
|
response = element->messageClass(element, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element->state & UI_STATE_INSPECTING) {
|
if ((element->state & UI_STATE_INSPECTING) && message->type != ES_MSG_GET_INSPECTOR_INFORMATION) {
|
||||||
InspectorNotifyElementEvent(element, "message", "Element processed message '%z' with response %i%z.\n",
|
InspectorNotifyElementEvent(element, "message", "Element processed message '%z' with response %i%z.\n",
|
||||||
EnumLookupNameFromValue(enumStrings_EsMessageType, message->type), response, handledByUser ? " (from user callback)" : "");
|
EnumLookupNameFromValue(enumStrings_EsMessageType, message->type), response, handledByUser ? " (from user callback)" : "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -3538,6 +3538,7 @@ struct EsCanvasPane : EsElement {
|
||||||
double panX, panY, zoom;
|
double panX, panY, zoom;
|
||||||
bool zoomFit, contentsChanged, center;
|
bool zoomFit, contentsChanged, center;
|
||||||
int previousWidth, previousHeight;
|
int previousWidth, previousHeight;
|
||||||
|
EsPoint lastPanPoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
EsElement *CanvasPaneGetCanvas(EsElement *element) {
|
EsElement *CanvasPaneGetCanvas(EsElement *element) {
|
||||||
|
@ -3601,17 +3602,26 @@ int ProcessCanvasPaneMessage(EsElement *element, EsMessage *message) {
|
||||||
} else if (message->type == ES_MSG_PAINT) {
|
} else if (message->type == ES_MSG_PAINT) {
|
||||||
EsElement *canvas = CanvasPaneGetCanvas(element);
|
EsElement *canvas = CanvasPaneGetCanvas(element);
|
||||||
if (!canvas) return 0;
|
if (!canvas) return 0;
|
||||||
|
|
||||||
UIStyle *style = GetStyle(MakeStyleKey(ES_STYLE_CANVAS_SHADOW, 0), true);
|
UIStyle *style = GetStyle(MakeStyleKey(ES_STYLE_CANVAS_SHADOW, 0), true);
|
||||||
EsRectangle shadow1 = ES_RECT_4PD(canvas->offsetX + style->preferredWidth, canvas->offsetY + canvas->height,
|
EsRectangle shadow = ES_RECT_4PD(canvas->offsetX, canvas->offsetY, canvas->width, canvas->height);
|
||||||
canvas->width, style->preferredHeight);
|
style->PaintLayers(message->painter, shadow, THEME_CHILD_TYPE_ONLY, ES_FLAGS_DEFAULT);
|
||||||
EsRectangle shadow2 = ES_RECT_4PD(canvas->offsetX + canvas->width, canvas->offsetY + style->preferredHeight,
|
} else if (message->type == ES_MSG_MOUSE_MIDDLE_DOWN) {
|
||||||
style->preferredWidth, canvas->height - style->preferredHeight);
|
pane->lastPanPoint = EsMouseGetPosition(pane);
|
||||||
style->PaintLayers(message->painter, shadow1, THEME_CHILD_TYPE_ONLY, ES_FLAGS_DEFAULT);
|
} else if (message->type == ES_MSG_MOUSE_MIDDLE_DRAG) {
|
||||||
style->PaintLayers(message->painter, shadow2, THEME_CHILD_TYPE_ONLY, ES_FLAGS_DEFAULT);
|
// 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->lastPanPoint = point;
|
||||||
|
EsElementRelayout(pane);
|
||||||
|
} else if (message->type == ES_MSG_GET_CURSOR && pane->window->dragged == pane) {
|
||||||
|
message->cursorStyle = ES_CURSOR_HAND_DRAG;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return ES_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
EsCanvasPane *EsCanvasPaneCreate(EsElement *parent, uint64_t flags, const EsStyle *style) {
|
EsCanvasPane *EsCanvasPaneCreate(EsElement *parent, uint64_t flags, const EsStyle *style) {
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue