This commit is contained in:
nakst 2021-10-05 16:21:47 +01:00
parent 8ce9eddea3
commit 4dc7f88d22
4 changed files with 19 additions and 18 deletions

View File

@ -2783,8 +2783,8 @@ void ScrollPane::Setup(EsElement *_parent, uint8_t _xMode, uint8_t _yMode, uint1
mode[1] = _yMode; mode[1] = _yMode;
flags = _flags; flags = _flags;
if (mode[0] == ES_SCROLL_MODE_NONE) flags &= ~SCROLL_X_DRAG; if (mode[0] == ES_SCROLL_MODE_NONE) flags &= ~ES_SCROLL_X_DRAG;
if (mode[1] == ES_SCROLL_MODE_NONE) flags &= ~SCROLL_Y_DRAG; if (mode[1] == ES_SCROLL_MODE_NONE) flags &= ~ES_SCROLL_Y_DRAG;
for (int axis = 0; axis < 2; axis++) { for (int axis = 0; axis < 2; axis++) {
if (mode[axis] == ES_SCROLL_MODE_FIXED || mode[axis] == ES_SCROLL_MODE_AUTO) { if (mode[axis] == ES_SCROLL_MODE_FIXED || mode[axis] == ES_SCROLL_MODE_AUTO) {
@ -2844,7 +2844,7 @@ void ScrollPane::ReceivedMessage(EsMessage *message) {
if (message->type == ES_MSG_LAYOUT) { if (message->type == ES_MSG_LAYOUT) {
Refresh(); Refresh();
} else if (message->type == ES_MSG_MOUSE_LEFT_DRAG || message->type == ES_MSG_MOUSE_RIGHT_DRAG || message->type == ES_MSG_MOUSE_MIDDLE_DRAG) { } else if (message->type == ES_MSG_MOUSE_LEFT_DRAG || message->type == ES_MSG_MOUSE_RIGHT_DRAG || message->type == ES_MSG_MOUSE_MIDDLE_DRAG) {
if (flags & (SCROLL_X_DRAG | SCROLL_Y_DRAG)) { if (flags & (ES_SCROLL_X_DRAG | ES_SCROLL_Y_DRAG)) {
parent->StartAnimating(); parent->StartAnimating();
dragScrolling = true; dragScrolling = true;
} }
@ -2858,8 +2858,8 @@ void ScrollPane::ReceivedMessage(EsMessage *message) {
double distanceY = point.y < bounds.t ? point.y - bounds.t : point.y >= bounds.b ? point.y - bounds.b + 1 : 0; double distanceY = point.y < bounds.t ? point.y - bounds.t : point.y >= bounds.b ? point.y - bounds.b + 1 : 0;
double deltaX = message->animate.deltaMs * distanceX / 300.0; double deltaX = message->animate.deltaMs * distanceX / 300.0;
double deltaY = message->animate.deltaMs * distanceY / 300.0; double deltaY = message->animate.deltaMs * distanceY / 300.0;
if (deltaX && (flags & SCROLL_X_DRAG)) SetX(position[0] + deltaX, true); if (deltaX && (flags & ES_SCROLL_X_DRAG)) SetX(position[0] + deltaX, true);
if (deltaY && (flags & SCROLL_Y_DRAG)) SetY(position[1] + deltaY, true); if (deltaY && (flags & ES_SCROLL_Y_DRAG)) SetY(position[1] + deltaY, true);
message->animate.complete = false; message->animate.complete = false;
} }
} else if (message->type == ES_MSG_GET_HEIGHT) { } else if (message->type == ES_MSG_GET_HEIGHT) {
@ -2961,7 +2961,7 @@ void ScrollPane::Refresh() {
if (bar[0]) ScrollbarSetMeasurements(bar[0], bounds.r - fixedViewport[0], contentWidth - fixedViewport[0]); if (bar[0]) ScrollbarSetMeasurements(bar[0], bounds.r - fixedViewport[0], contentWidth - fixedViewport[0]);
if (bar[1]) ScrollbarSetMeasurements(bar[1], bounds.b - fixedViewport[1], contentHeight - fixedViewport[1]); if (bar[1]) ScrollbarSetMeasurements(bar[1], bounds.b - fixedViewport[1], contentHeight - fixedViewport[1]);
if (~flags & SCROLL_MANUAL) { if (~flags & ES_SCROLL_MANUAL) {
SetPosition(0, position[0], true); SetPosition(0, position[0], true);
SetPosition(1, position[1], true); SetPosition(1, position[1], true);
} }
@ -3836,7 +3836,7 @@ EsCanvasPane *EsCanvasPaneCreate(EsElement *parent, uint64_t flags, const EsStyl
pane->Initialise(parent, flags, ProcessCanvasPaneMessage, style); pane->Initialise(parent, flags, ProcessCanvasPaneMessage, style);
pane->cName = "canvas pane"; pane->cName = "canvas pane";
pane->zoom = 1.0; pane->zoom = 1.0;
pane->scroll.Setup(pane, ES_SCROLL_MODE_AUTO, ES_SCROLL_MODE_AUTO, SCROLL_MANUAL); pane->scroll.Setup(pane, ES_SCROLL_MODE_AUTO, ES_SCROLL_MODE_AUTO, ES_SCROLL_MANUAL);
return pane; return pane;
} }
@ -6287,7 +6287,7 @@ EsThemeMetrics EsElementGetMetrics(EsElement *element) {
m.insets = RECTANGLE_8_TO_ES_RECTANGLE(metrics->insets); m.insets = RECTANGLE_8_TO_ES_RECTANGLE(metrics->insets);
m.clipInsets = RECTANGLE_8_TO_ES_RECTANGLE(metrics->clipInsets); m.clipInsets = RECTANGLE_8_TO_ES_RECTANGLE(metrics->clipInsets);
m.clipEnabled = metrics->clipEnabled; m.clipEnabled = metrics->clipEnabled;
m.cursor = metrics->cursor; m.cursor = (EsCursorStyle) metrics->cursor;
m.preferredWidth = metrics->preferredWidth; m.preferredWidth = metrics->preferredWidth;
m.preferredHeight = metrics->preferredHeight; m.preferredHeight = metrics->preferredHeight;
m.minimumWidth = metrics->minimumWidth; m.minimumWidth = metrics->minimumWidth;

View File

@ -1939,7 +1939,7 @@ void EsListViewChangeStyles(EsListView *view, const EsStyle *style, const EsStyl
scrollYMode = ES_SCROLL_MODE_AUTO; scrollYMode = ES_SCROLL_MODE_AUTO;
} }
view->scroll.Setup(view, scrollXMode, scrollYMode, SCROLL_X_DRAG | SCROLL_Y_DRAG); view->scroll.Setup(view, scrollXMode, scrollYMode, ES_SCROLL_X_DRAG | ES_SCROLL_Y_DRAG);
ListViewCalculateTotalColumnWidth(view); ListViewCalculateTotalColumnWidth(view);
// Remove existing visible items; the list will need to be repopulated. // Remove existing visible items; the list will need to be repopulated.

View File

@ -742,9 +742,9 @@ define ES_SCROLL_MODE_HIDDEN (1) // Scrolling takes place, but there is no visib
define ES_SCROLL_MODE_FIXED (2) // The scrollbar is always visible. define ES_SCROLL_MODE_FIXED (2) // The scrollbar is always visible.
define ES_SCROLL_MODE_AUTO (3) // The scrollbar is only visible if the content is larger than the viewport. define ES_SCROLL_MODE_AUTO (3) // The scrollbar is only visible if the content is larger than the viewport.
// Scroll view flags. // Scroll view flags.
define SCROLL_X_DRAG (1 << 0) define ES_SCROLL_X_DRAG (1 << 0)
define SCROLL_Y_DRAG (1 << 1) define ES_SCROLL_Y_DRAG (1 << 1)
private define SCROLL_MANUAL (1 << 2) // The parent is responsible for updating the position of the scroll bars. private define ES_SCROLL_MANUAL (1 << 2) // The parent is responsible for updating the position of the scroll bars.
include desktop/icons.header include desktop/icons.header
@ -1319,11 +1319,12 @@ struct EsPanelBand {
struct EsThemeMetrics { struct EsThemeMetrics {
uint64_t mask; uint64_t mask;
EsRectangle insets, clipInsets; EsRectangle insets, clipInsets;
int clipEnabled, cursor; bool clipEnabled;
int preferredWidth, preferredHeight; EsCursorStyle cursor;
int minimumWidth, minimumHeight; int32_t preferredWidth, preferredHeight;
int maximumWidth, maximumHeight; int32_t minimumWidth, minimumHeight;
int gapMajor, gapMinor, gapWrap; int32_t maximumWidth, maximumHeight;
int32_t gapMajor, gapMinor, gapWrap;
uint32_t textColor, selectedBackground, selectedText, iconColor; uint32_t textColor, selectedBackground, selectedText, iconColor;
int textAlign, textSize, fontFamily, fontWeight, iconSize; int textAlign, textSize, fontFamily, fontWeight, iconSize;
bool isItalic, layoutVertical; bool isItalic, layoutVertical;

View File

@ -4716,7 +4716,7 @@ EsTextbox *EsTextboxCreate(EsElement *parent, uint64_t flags, const EsStyle *sty
textbox->scroll.Setup(textbox, textbox->scroll.Setup(textbox,
(flags & ES_TEXTBOX_MULTILINE) ? ES_SCROLL_MODE_AUTO : ES_SCROLL_MODE_HIDDEN, (flags & ES_TEXTBOX_MULTILINE) ? ES_SCROLL_MODE_AUTO : ES_SCROLL_MODE_HIDDEN,
(flags & ES_TEXTBOX_MULTILINE) ? ES_SCROLL_MODE_AUTO : ES_SCROLL_MODE_NONE, (flags & ES_TEXTBOX_MULTILINE) ? ES_SCROLL_MODE_AUTO : ES_SCROLL_MODE_NONE,
SCROLL_X_DRAG | SCROLL_Y_DRAG); ES_SCROLL_X_DRAG | ES_SCROLL_Y_DRAG);
textbox->undo = &textbox->localUndo; textbox->undo = &textbox->localUndo;
textbox->undo->instance = textbox->instance; textbox->undo->instance = textbox->instance;