mirror of https://gitlab.com/nakst/essence
canvas pane: optional shadow; use cell flags
This commit is contained in:
parent
f65c768292
commit
2fcb2878fc
|
@ -887,8 +887,8 @@ void InstanceCreate(EsMessage *message) {
|
||||||
|
|
||||||
EsWindowSetIcon(instance->window, ES_ICON_MULTIMEDIA_PHOTO_MANAGER);
|
EsWindowSetIcon(instance->window, ES_ICON_MULTIMEDIA_PHOTO_MANAGER);
|
||||||
|
|
||||||
EsCanvasPane *canvasPane = EsCanvasPaneCreate(instance->window, ES_CELL_FILL, ES_STYLE_PANEL_WINDOW_BACKGROUND);
|
EsCanvasPane *canvasPane = EsCanvasPaneCreate(instance->window, ES_CELL_FILL | ES_CANVAS_PANE_SHOW_SHADOW, ES_STYLE_PANEL_WINDOW_BACKGROUND);
|
||||||
instance->canvas = EsCustomElementCreate(canvasPane, ES_CELL_FILL | ES_ELEMENT_FOCUSABLE);
|
instance->canvas = EsCustomElementCreate(canvasPane, ES_CELL_CENTER | ES_ELEMENT_FOCUSABLE);
|
||||||
instance->canvas->messageUser = CanvasMessage;
|
instance->canvas->messageUser = CanvasMessage;
|
||||||
EsElementFocus(instance->canvas, false);
|
EsElementFocus(instance->canvas, false);
|
||||||
|
|
||||||
|
|
|
@ -654,6 +654,14 @@ const EsStyle styleList = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const EsStyle styleImageViewerPane = {
|
||||||
|
.metrics = {
|
||||||
|
.mask = ES_THEME_METRICS_CLIP_ENABLED | ES_THEME_METRICS_MAXIMUM_HEIGHT,
|
||||||
|
.clipEnabled = true,
|
||||||
|
.maximumHeight = 400,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
void AddREPLResult(ExecutionContext *context, EsElement *parent, Node *type, Value value) {
|
void AddREPLResult(ExecutionContext *context, EsElement *parent, Node *type, Value value) {
|
||||||
// TODO Truncating/scrolling/collapsing/saving/copying output.
|
// TODO Truncating/scrolling/collapsing/saving/copying output.
|
||||||
// TODO Letting scripts register custom views for structs.
|
// TODO Letting scripts register custom views for structs.
|
||||||
|
@ -688,7 +696,8 @@ void AddREPLResult(ExecutionContext *context, EsElement *parent, Node *type, Val
|
||||||
|
|
||||||
if ((valueBytes > sizeof(pngSignature) && 0 == EsMemoryCompare(&pngSignature, valueText, sizeof(pngSignature)))
|
if ((valueBytes > sizeof(pngSignature) && 0 == EsMemoryCompare(&pngSignature, valueText, sizeof(pngSignature)))
|
||||||
|| (valueBytes > sizeof(jpgSignature) && 0 == EsMemoryCompare(&jpgSignature, valueText, sizeof(jpgSignature)))) {
|
|| (valueBytes > sizeof(jpgSignature) && 0 == EsMemoryCompare(&jpgSignature, valueText, sizeof(jpgSignature)))) {
|
||||||
EsImageDisplay *display = EsImageDisplayCreate(parent, ES_CELL_H_FILL);
|
EsCanvasPane *canvasPane = EsCanvasPaneCreate(parent, ES_CELL_H_FILL, EsStyleIntern(&styleImageViewerPane));
|
||||||
|
EsImageDisplay *display = EsImageDisplayCreate(canvasPane, ES_CELL_H_LEFT | ES_CELL_V_TOP);
|
||||||
EsImageDisplayLoadFromMemory(display, valueText, valueBytes);
|
EsImageDisplayLoadFromMemory(display, valueText, valueBytes);
|
||||||
} else if (EsUTF8IsValid(valueText, valueBytes)) {
|
} else if (EsUTF8IsValid(valueText, valueBytes)) {
|
||||||
char *buffer = EsStringAllocateAndFormat(&bytes, "\u201C%s\u201D", valueBytes, valueText);
|
char *buffer = EsStringAllocateAndFormat(&bytes, "\u201C%s\u201D", valueBytes, valueText);
|
||||||
|
|
|
@ -3943,12 +3943,26 @@ int ProcessCanvasPaneMessage(EsElement *element, EsMessage *message) {
|
||||||
if (pane->panY < 0) pane->panY = 0;
|
if (pane->panY < 0) pane->panY = 0;
|
||||||
if (pane->panY > height - Height(bounds) / pane->zoom) pane->panY = height - Height(bounds) / pane->zoom;
|
if (pane->panY > height - Height(bounds) / pane->zoom) pane->panY = height - Height(bounds) / pane->zoom;
|
||||||
|
|
||||||
if (width * pane->zoom <= Width(bounds) || pane->center) {
|
bool widthFits = width * pane->zoom <= Width(bounds);
|
||||||
|
bool heightFits = height * pane->zoom <= Height(bounds);
|
||||||
|
|
||||||
|
if (pane->center) {
|
||||||
pane->panX = width / 2 - Width(bounds) / pane->zoom / 2;
|
pane->panX = width / 2 - Width(bounds) / pane->zoom / 2;
|
||||||
|
pane->panY = height / 2 - Height(bounds) / pane->zoom / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height * pane->zoom <= Height(bounds) || pane->center) {
|
if (widthFits) {
|
||||||
pane->panY = height / 2 - Height(bounds) / pane->zoom / 2;
|
uint64_t cellH = canvas->flags & (ES_CELL_H_LEFT | ES_CELL_H_RIGHT);
|
||||||
|
if (cellH == ES_CELL_H_LEFT) pane->panX = 0;
|
||||||
|
if (cellH == ES_CELL_H_CENTER) pane->panX = width / 2 - Width(bounds) / pane->zoom / 2;
|
||||||
|
if (cellH == ES_CELL_H_RIGHT) pane->panX = width - Width(bounds) / pane->zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (heightFits) {
|
||||||
|
uint64_t cellV = canvas->flags & (ES_CELL_V_TOP | ES_CELL_V_BOTTOM);
|
||||||
|
if (cellV == ES_CELL_V_TOP) pane->panY = 0;
|
||||||
|
if (cellV == ES_CELL_V_CENTER) pane->panY = height / 2 - Height(bounds) / pane->zoom / 2;
|
||||||
|
if (cellV == ES_CELL_V_BOTTOM) pane->panY = height - Height(bounds) / pane->zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
pane->scroll.position[0] = pane->panX;
|
pane->scroll.position[0] = pane->panX;
|
||||||
|
@ -3964,9 +3978,12 @@ 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);
|
|
||||||
EsRectangle shadow = ES_RECT_4PD(canvas->offsetX, canvas->offsetY, canvas->width, canvas->height);
|
if (element->flags & ES_CANVAS_PANE_SHOW_SHADOW) {
|
||||||
style->PaintLayers(message->painter, shadow, THEME_CHILD_TYPE_ONLY, ES_FLAGS_DEFAULT);
|
UIStyle *style = GetStyle(MakeStyleKey(ES_STYLE_CANVAS_SHADOW, 0), true);
|
||||||
|
EsRectangle shadow = ES_RECT_4PD(canvas->offsetX, canvas->offsetY, canvas->width, canvas->height);
|
||||||
|
style->PaintLayers(message->painter, shadow, THEME_CHILD_TYPE_ONLY, ES_FLAGS_DEFAULT);
|
||||||
|
}
|
||||||
} else if (message->type == ES_MSG_MOUSE_MIDDLE_DOWN) {
|
} else if (message->type == ES_MSG_MOUSE_MIDDLE_DOWN) {
|
||||||
pane->lastPanPoint = EsMouseGetPosition(pane);
|
pane->lastPanPoint = EsMouseGetPosition(pane);
|
||||||
} else if (message->type == ES_MSG_MOUSE_MIDDLE_DRAG) {
|
} else if (message->type == ES_MSG_MOUSE_MIDDLE_DRAG) {
|
||||||
|
|
|
@ -777,6 +777,8 @@ define ES_LIST_VIEW_CHOOSE_ITEM_MIDDLE_CLICK (4)
|
||||||
define ES_SHUTDOWN_ACTION_POWER_OFF (1)
|
define ES_SHUTDOWN_ACTION_POWER_OFF (1)
|
||||||
define ES_SHUTDOWN_ACTION_RESTART (2)
|
define ES_SHUTDOWN_ACTION_RESTART (2)
|
||||||
|
|
||||||
|
define ES_CANVAS_PANE_SHOW_SHADOW (1 << 0)
|
||||||
|
|
||||||
include desktop/icons.header
|
include desktop/icons.header
|
||||||
|
|
||||||
enum EsFatalError {
|
enum EsFatalError {
|
||||||
|
|
Loading…
Reference in New Issue