mirror of https://github.com/buggins/dlangui.git
console theme - grid enhancement
This commit is contained in:
parent
5d2a799f52
commit
7efe250867
|
@ -1119,7 +1119,7 @@ class Window : CustomEventTarget {
|
||||||
if (!needLayout) {
|
if (!needLayout) {
|
||||||
needLayout = root.needLayout || needLayout;
|
needLayout = root.needLayout || needLayout;
|
||||||
if (needLayout) {
|
if (needLayout) {
|
||||||
debug(DebugRedraw) Log.d("need layout: ", root.id);
|
debug(DebugRedraw) Log.d("need layout: ", root.classinfo.name, " id=", root.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (root.animating && root.visible)
|
if (root.animating && root.visible)
|
||||||
|
@ -1173,7 +1173,7 @@ class Window : CustomEventTarget {
|
||||||
debug(DebugRedraw) Log.d("Requesting update");
|
debug(DebugRedraw) Log.d("Requesting update");
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
debug(DebugRedraw) Log.d("checkUpdateNeeded returned needDraw=", needDraw, " needLayout=", needLayout, " animationActive=", animationActive);
|
debug(DebugRedraw) Log.d("checkUpdateNeeded returned needDraw=", needDraw, " needLayout=", needLayout, " animationActive=", _animationActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool _actionsUpdateRequested = true;
|
protected bool _actionsUpdateRequested = true;
|
||||||
|
@ -1219,7 +1219,7 @@ class Window : CustomEventTarget {
|
||||||
|
|
||||||
/// schedule timer for interval in milliseconds - call window.onTimer when finished
|
/// schedule timer for interval in milliseconds - call window.onTimer when finished
|
||||||
protected void scheduleSystemTimer(long intervalMillis) {
|
protected void scheduleSystemTimer(long intervalMillis) {
|
||||||
Log.d("override scheduleSystemTimer to support timers");
|
//debug Log.d("override scheduleSystemTimer to support timers");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// poll expired timers; returns true if update is needed
|
/// poll expired timers; returns true if update is needed
|
||||||
|
|
|
@ -364,6 +364,10 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
protected uint _cellHeaderBorderColor = 0xC0202020;
|
protected uint _cellHeaderBorderColor = 0xC0202020;
|
||||||
protected uint _cellHeaderBackgroundColor = 0xC0909090;
|
protected uint _cellHeaderBackgroundColor = 0xC0909090;
|
||||||
protected uint _cellHeaderSelectedBackgroundColor = 0x80FFC040;
|
protected uint _cellHeaderSelectedBackgroundColor = 0x80FFC040;
|
||||||
|
protected DrawableRef _cellHeaderBackgroundDrawable;
|
||||||
|
protected DrawableRef _cellHeaderSelectedBackgroundDrawable;
|
||||||
|
protected DrawableRef _cellRowHeaderBackgroundDrawable;
|
||||||
|
protected DrawableRef _cellRowHeaderSelectedBackgroundDrawable;
|
||||||
|
|
||||||
/// row header column count
|
/// row header column count
|
||||||
@property int headerCols() { return _headerCols; }
|
@property int headerCols() { return _headerCols; }
|
||||||
|
@ -405,6 +409,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
}
|
}
|
||||||
@property GridWidgetBase defColumnWidth(int v) {
|
@property GridWidgetBase defColumnWidth(int v) {
|
||||||
_defColumnWidth = v;
|
_defColumnWidth = v;
|
||||||
|
_changedSize = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/// default row height - for newly added rows
|
/// default row height - for newly added rows
|
||||||
|
@ -413,6 +418,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
}
|
}
|
||||||
@property GridWidgetBase defRowHeight(int v) {
|
@property GridWidgetBase defRowHeight(int v) {
|
||||||
_defRowHeight = v;
|
_defRowHeight = v;
|
||||||
|
_changedSize = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,6 +451,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
for (int i = 0; i < _headerRows; i++)
|
for (int i = 0; i < _headerRows; i++)
|
||||||
autoFitRowHeight(i);
|
autoFitRowHeight(i);
|
||||||
invalidate();
|
invalidate();
|
||||||
|
_changedSize = true;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -459,13 +466,18 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
_showRowHeaders = show;
|
_showRowHeaders = show;
|
||||||
for (int i = 0; i < _headerCols; i++)
|
for (int i = 0; i < _headerCols; i++)
|
||||||
autoFitColumnWidth(i);
|
autoFitColumnWidth(i);
|
||||||
|
_changedSize = true;
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected bool _changedSize = true;
|
||||||
/// recalculate colCumulativeWidths, rowCumulativeHeights after resizes
|
/// recalculate colCumulativeWidths, rowCumulativeHeights after resizes
|
||||||
protected void updateCumulativeSizes() {
|
protected void updateCumulativeSizes() {
|
||||||
|
if (!_changedSize)
|
||||||
|
return;
|
||||||
|
_changedSize = false;
|
||||||
_colCumulativeWidths.length = _colWidths.length;
|
_colCumulativeWidths.length = _colWidths.length;
|
||||||
_rowCumulativeHeights.length = _rowHeights.length;
|
_rowCumulativeHeights.length = _rowHeights.length;
|
||||||
for (int i = 0; i < _colCumulativeWidths.length; i++) {
|
for (int i = 0; i < _colCumulativeWidths.length; i++) {
|
||||||
|
@ -486,6 +498,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
void resize(int c, int r) {
|
void resize(int c, int r) {
|
||||||
if (c == cols && r == rows)
|
if (c == cols && r == rows)
|
||||||
return;
|
return;
|
||||||
|
_changedSize = true;
|
||||||
_colWidths.length = c + _headerCols;
|
_colWidths.length = c + _headerCols;
|
||||||
for (int i = _cols; i < c + _headerCols; i++) {
|
for (int i = _cols; i < c + _headerCols; i++) {
|
||||||
_colWidths[i] = _defColumnWidth;
|
_colWidths[i] = _defColumnWidth;
|
||||||
|
@ -505,10 +518,12 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
@property int nonScrollRows() { return _headerRows + fixedRows; }
|
@property int nonScrollRows() { return _headerRows + fixedRows; }
|
||||||
/// return all (fixed + scrollable) cells size in pixels
|
/// return all (fixed + scrollable) cells size in pixels
|
||||||
@property Point fullAreaPixels() {
|
@property Point fullAreaPixels() {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
return Point(_cols ? _colCumulativeWidths[_cols - 1] : 0, _rows ? _rowCumulativeHeights[_rows - 1] : 0);
|
return Point(_cols ? _colCumulativeWidths[_cols - 1] : 0, _rows ? _rowCumulativeHeights[_rows - 1] : 0);
|
||||||
}
|
}
|
||||||
/// non-scrollable area size in pixels
|
/// non-scrollable area size in pixels
|
||||||
@property Point nonScrollAreaPixels() {
|
@property Point nonScrollAreaPixels() {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
int nscols = nonScrollCols;
|
int nscols = nonScrollCols;
|
||||||
int nsrows = nonScrollRows;
|
int nsrows = nonScrollRows;
|
||||||
return Point(nscols ? _colCumulativeWidths[nscols - 1] : 0, nsrows ? _rowCumulativeHeights[nsrows - 1] : 0);
|
return Point(nscols ? _colCumulativeWidths[nscols - 1] : 0, nsrows ? _rowCumulativeHeights[nsrows - 1] : 0);
|
||||||
|
@ -519,6 +534,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
}
|
}
|
||||||
/// get cell rectangle (relative to client area) not counting scroll position
|
/// get cell rectangle (relative to client area) not counting scroll position
|
||||||
Rect cellRectNoScroll(int x, int y) {
|
Rect cellRectNoScroll(int x, int y) {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
if (x < 0 || y < 0 || x >= _cols || y >= _rows)
|
if (x < 0 || y < 0 || x >= _cols || y >= _rows)
|
||||||
return Rect(0,0,0,0);
|
return Rect(0,0,0,0);
|
||||||
return Rect(x ? _colCumulativeWidths[x - 1] : 0, y ? _rowCumulativeHeights[y - 1] : 0,
|
return Rect(x ? _colCumulativeWidths[x - 1] : 0, y ? _rowCumulativeHeights[y - 1] : 0,
|
||||||
|
@ -541,6 +557,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
}
|
}
|
||||||
/// returns true if column is inside client area and not overlapped outside scroll area
|
/// returns true if column is inside client area and not overlapped outside scroll area
|
||||||
bool colVisible(int x) {
|
bool colVisible(int x) {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
if (x < 0 || x >= _cols)
|
if (x < 0 || x >= _cols)
|
||||||
return false;
|
return false;
|
||||||
if (x == 0)
|
if (x == 0)
|
||||||
|
@ -564,6 +581,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
bool rowVisible(int y) {
|
bool rowVisible(int y) {
|
||||||
if (y < 0 || y >= _rows)
|
if (y < 0 || y >= _rows)
|
||||||
return false;
|
return false;
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
if (y == 0)
|
if (y == 0)
|
||||||
return true; // first row always visible
|
return true; // first row always visible
|
||||||
int nsrows = nonScrollRows;
|
int nsrows = nonScrollRows;
|
||||||
|
@ -584,12 +602,12 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
void setColWidth(int x, int w) {
|
void setColWidth(int x, int w) {
|
||||||
_colWidths[x] = w;
|
_colWidths[x] = w;
|
||||||
updateCumulativeSizes();
|
_changedSize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRowHeight(int y, int w) {
|
void setRowHeight(int y, int w) {
|
||||||
_rowHeights[y] = w;
|
_rowHeights[y] = w;
|
||||||
updateCumulativeSizes();
|
_changedSize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// get column width, 0 is header column
|
/// get column width, 0 is header column
|
||||||
|
@ -613,6 +631,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
/// converts client rect relative coordinates to cell coordinates
|
/// converts client rect relative coordinates to cell coordinates
|
||||||
bool pointToCell(int x, int y, ref int col, ref int row, ref Rect cellRect) {
|
bool pointToCell(int x, int y, ref int col, ref int row, ref Rect cellRect) {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
int nscols = nonScrollCols;
|
int nscols = nonScrollCols;
|
||||||
int nsrows = nonScrollRows;
|
int nsrows = nonScrollRows;
|
||||||
Point ns = nonScrollAreaPixels;
|
Point ns = nonScrollAreaPixels;
|
||||||
|
@ -624,6 +643,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
/// update scrollbar positions
|
/// update scrollbar positions
|
||||||
override protected void updateScrollBars() {
|
override protected void updateScrollBars() {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
calcScrollableAreaPos();
|
calcScrollableAreaPos();
|
||||||
correctScrollPos();
|
correctScrollPos();
|
||||||
super.updateScrollBars();
|
super.updateScrollBars();
|
||||||
|
@ -662,16 +682,19 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
/// column by X, ignoring scroll position
|
/// column by X, ignoring scroll position
|
||||||
protected int colByAbsoluteX(int x) {
|
protected int colByAbsoluteX(int x) {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
return findPosIndex(_colCumulativeWidths, x);
|
return findPosIndex(_colCumulativeWidths, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// row by Y, ignoring scroll position
|
/// row by Y, ignoring scroll position
|
||||||
protected int rowByAbsoluteY(int y) {
|
protected int rowByAbsoluteY(int y) {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
return findPosIndex(_rowCumulativeHeights, y);
|
return findPosIndex(_rowCumulativeHeights, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// returns first fully visible column in scroll area
|
/// returns first fully visible column in scroll area
|
||||||
protected int scrollCol() {
|
protected int scrollCol() {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
int x = nonScrollAreaPixels.x + _scrollX;
|
int x = nonScrollAreaPixels.x + _scrollX;
|
||||||
int col = colByAbsoluteX(x);
|
int col = colByAbsoluteX(x);
|
||||||
int start = col ? _colCumulativeWidths[col - 1] : 0;
|
int start = col ? _colCumulativeWidths[col - 1] : 0;
|
||||||
|
@ -684,6 +707,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
/// returns last fully visible column in scroll area
|
/// returns last fully visible column in scroll area
|
||||||
protected int lastScrollCol() {
|
protected int lastScrollCol() {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
int x = nonScrollAreaPixels.x + _scrollX + _visibleScrollableArea.width - 1;
|
int x = nonScrollAreaPixels.x + _scrollX + _visibleScrollableArea.width - 1;
|
||||||
int col = colByAbsoluteX(x);
|
int col = colByAbsoluteX(x);
|
||||||
int start = col ? _colCumulativeWidths[col - 1] : 0;
|
int start = col ? _colCumulativeWidths[col - 1] : 0;
|
||||||
|
@ -697,6 +721,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
/// returns first fully visible row in scroll area
|
/// returns first fully visible row in scroll area
|
||||||
protected int scrollRow() {
|
protected int scrollRow() {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
int y = nonScrollAreaPixels.y + _scrollY;
|
int y = nonScrollAreaPixels.y + _scrollY;
|
||||||
int row = rowByAbsoluteY(y);
|
int row = rowByAbsoluteY(y);
|
||||||
int start = row ? _rowCumulativeHeights[row - 1] : 0;
|
int start = row ? _rowCumulativeHeights[row - 1] : 0;
|
||||||
|
@ -709,6 +734,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
/// returns last fully visible row in scroll area
|
/// returns last fully visible row in scroll area
|
||||||
protected int lastScrollRow() {
|
protected int lastScrollRow() {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
int y = nonScrollAreaPixels.y + _scrollY + _visibleScrollableArea.height - 1;
|
int y = nonScrollAreaPixels.y + _scrollY + _visibleScrollableArea.height - 1;
|
||||||
int row = rowByAbsoluteY(y);
|
int row = rowByAbsoluteY(y);
|
||||||
int start = row ? _rowCumulativeHeights[row - 1] : 0;
|
int start = row ? _rowCumulativeHeights[row - 1] : 0;
|
||||||
|
@ -722,6 +748,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
/// move scroll position horizontally by dx, and vertically by dy; returns true if scrolled
|
/// move scroll position horizontally by dx, and vertically by dy; returns true if scrolled
|
||||||
bool scrollBy(int dx, int dy) {
|
bool scrollBy(int dx, int dy) {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
int col = scrollCol + dx;
|
int col = scrollCol + dx;
|
||||||
int row = scrollRow + dy;
|
int row = scrollRow + dy;
|
||||||
if (col >= _cols)
|
if (col >= _cols)
|
||||||
|
@ -744,6 +771,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
// ensure scroll position is inside min/max area
|
// ensure scroll position is inside min/max area
|
||||||
protected void correctScrollPos() {
|
protected void correctScrollPos() {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
int maxscrollx = _fullScrollableArea.width - _visibleScrollableArea.width;
|
int maxscrollx = _fullScrollableArea.width - _visibleScrollableArea.width;
|
||||||
int maxscrolly = _fullScrollableArea.height - _visibleScrollableArea.height;
|
int maxscrolly = _fullScrollableArea.height - _visibleScrollableArea.height;
|
||||||
if (_scrollX < 0)
|
if (_scrollX < 0)
|
||||||
|
@ -758,6 +786,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
/// set scroll position to show specified cell as top left in scrollable area; col or row -1 value means no change
|
/// set scroll position to show specified cell as top left in scrollable area; col or row -1 value means no change
|
||||||
bool scrollTo(int x, int y, GridWidgetBase source = null, bool doNotify = true) {
|
bool scrollTo(int x, int y, GridWidgetBase source = null, bool doNotify = true) {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
int oldx = _scrollX;
|
int oldx = _scrollX;
|
||||||
int oldy = _scrollY;
|
int oldy = _scrollY;
|
||||||
_scrollX = x;
|
_scrollX = x;
|
||||||
|
@ -808,6 +837,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
/// ensure that cell is visible (scroll if necessary)
|
/// ensure that cell is visible (scroll if necessary)
|
||||||
void makeCellVisible(int col, int row) {
|
void makeCellVisible(int col, int row) {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
bool scrolled = false;
|
bool scrolled = false;
|
||||||
int newx = _scrollX;
|
int newx = _scrollX;
|
||||||
int newy = _scrollY;
|
int newy = _scrollY;
|
||||||
|
@ -850,6 +880,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
return false; // same position
|
return false; // same position
|
||||||
if (col < _headerCols || row < _headerRows || col >= _cols || row >= _rows)
|
if (col < _headerCols || row < _headerRows || col >= _cols || row >= _rows)
|
||||||
return false; // out of range
|
return false; // out of range
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
_col = col;
|
_col = col;
|
||||||
_row = row;
|
_row = row;
|
||||||
invalidate();
|
invalidate();
|
||||||
|
@ -863,6 +894,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
/// Select cell and call onCellActivated handler
|
/// Select cell and call onCellActivated handler
|
||||||
bool activateCell(int col, int row) {
|
bool activateCell(int col, int row) {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
if (_col != col || _row != row) {
|
if (_col != col || _row != row) {
|
||||||
selectCell(col, row, true);
|
selectCell(col, row, true);
|
||||||
}
|
}
|
||||||
|
@ -948,6 +980,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
if (newWidth < 0)
|
if (newWidth < 0)
|
||||||
newWidth = 0;
|
newWidth = 0;
|
||||||
_colWidths[_colResizingIndex] = newWidth;
|
_colWidths[_colResizingIndex] = newWidth;
|
||||||
|
_changedSize = true;
|
||||||
updateCumulativeSizes();
|
updateCumulativeSizes();
|
||||||
updateScrollBars();
|
updateScrollBars();
|
||||||
invalidate();
|
invalidate();
|
||||||
|
@ -958,6 +991,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
|
|
||||||
/// return column index to resize if point is in column resize area in header row, -1 if outside resize area
|
/// return column index to resize if point is in column resize area in header row, -1 if outside resize area
|
||||||
int isColumnResizingPoint(int x, int y) {
|
int isColumnResizingPoint(int x, int y) {
|
||||||
|
if (_changedSize) updateCumulativeSizes();
|
||||||
x -= _clientRect.left;
|
x -= _clientRect.left;
|
||||||
y -= _clientRect.top;
|
y -= _clientRect.top;
|
||||||
if (!_headerRows)
|
if (!_headerRows)
|
||||||
|
@ -970,7 +1004,8 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
x += _scrollX;
|
x += _scrollX;
|
||||||
int col = colByAbsoluteX(x);
|
int col = colByAbsoluteX(x);
|
||||||
int start = col > 0 ? _colCumulativeWidths[col - 1] : 0;
|
int start = col > 0 ? _colCumulativeWidths[col - 1] : 0;
|
||||||
int end = col < _cols ? _colCumulativeWidths[col] : _colCumulativeWidths[$ - 1];
|
int end = (col < _cols ? _colCumulativeWidths[col] : _colCumulativeWidths[$ - 1]) - 1;
|
||||||
|
//Log.d("column range ", start, "..", end, " x=", x);
|
||||||
if (x >= end - resizeRange / 2)
|
if (x >= end - resizeRange / 2)
|
||||||
return col; // resize this column
|
return col; // resize this column
|
||||||
if (x <= start + resizeRange / 2)
|
if (x <= start + resizeRange / 2)
|
||||||
|
@ -1392,7 +1427,8 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
void autoFitColumnWidth(int i) {
|
void autoFitColumnWidth(int i) {
|
||||||
_colWidths[i] = (i < _headerCols && !_showRowHeaders) ? 0 : measureColWidth(i) + (BACKEND_CONSOLE ? 3 : 3.pointsToPixels);
|
_colWidths[i] = (i < _headerCols && !_showRowHeaders) ? 0 : measureColWidth(i) + (BACKEND_CONSOLE ? 1 : 3.pointsToPixels);
|
||||||
|
_changedSize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// extend specified column width to fit client area if grid width
|
/// extend specified column width to fit client area if grid width
|
||||||
|
@ -1403,19 +1439,20 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
totalw += _colWidths[i];
|
totalw += _colWidths[i];
|
||||||
if (w > totalw)
|
if (w > totalw)
|
||||||
_colWidths[colIndex + _headerCols] += w - totalw;
|
_colWidths[colIndex + _headerCols] += w - totalw;
|
||||||
updateCumulativeSizes();
|
_changedSize = true;
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void autoFitColumnWidths() {
|
void autoFitColumnWidths() {
|
||||||
for (int i = 0; i < _cols; i++)
|
for (int i = 0; i < _cols; i++)
|
||||||
autoFitColumnWidth(i);
|
autoFitColumnWidth(i);
|
||||||
updateCumulativeSizes();
|
_changedSize = true;
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void autoFitRowHeight(int i) {
|
void autoFitRowHeight(int i) {
|
||||||
_rowHeights[i] = (i < _headerRows && !_showColHeaders) ? 0 : measureRowHeight(i) + (BACKEND_CONSOLE ? 0 : 2);
|
_rowHeights[i] = (i < _headerRows && !_showColHeaders) ? 0 : measureRowHeight(i) + (BACKEND_CONSOLE ? 0 : 2);
|
||||||
|
_changedSize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void autoFitRowHeights() {
|
void autoFitRowHeights() {
|
||||||
|
@ -1620,8 +1657,8 @@ class StringGridWidget : StringGridWidgetBase {
|
||||||
Align ha = Align.Left;
|
Align ha = Align.Left;
|
||||||
if (col < 0)
|
if (col < 0)
|
||||||
ha = Align.Right;
|
ha = Align.Right;
|
||||||
if (row < 0)
|
//if (row < 0)
|
||||||
ha = Align.HCenter;
|
// ha = Align.HCenter;
|
||||||
applyAlign(rc, sz, ha, Align.VCenter);
|
applyAlign(rc, sz, ha, Align.VCenter);
|
||||||
int offset = BACKEND_CONSOLE ? 0 : 1;
|
int offset = BACKEND_CONSOLE ? 0 : 1;
|
||||||
uint cl = textColor;
|
uint cl = textColor;
|
||||||
|
@ -1637,14 +1674,21 @@ class StringGridWidget : StringGridWidgetBase {
|
||||||
if (_rowSelect && selectedRow)
|
if (_rowSelect && selectedRow)
|
||||||
selectedCell = true;
|
selectedCell = true;
|
||||||
// draw header cell background
|
// draw header cell background
|
||||||
|
DrawableRef dw = c < 0 ? _cellRowHeaderBackgroundDrawable : _cellHeaderBackgroundDrawable;
|
||||||
uint cl = _cellHeaderBackgroundColor;
|
uint cl = _cellHeaderBackgroundColor;
|
||||||
if (c >= _headerCols || r >= _headerRows) {
|
if (c >= 0 || r >= 0) {
|
||||||
if (c < _headerCols && selectedRow)
|
if (c < 0 && selectedRow) {
|
||||||
cl = _cellHeaderSelectedBackgroundColor;
|
cl = _cellHeaderSelectedBackgroundColor;
|
||||||
if (r < _headerRows && selectedCol)
|
dw = _cellRowHeaderSelectedBackgroundDrawable;
|
||||||
|
} else if (r < 0 && selectedCol) {
|
||||||
cl = _cellHeaderSelectedBackgroundColor;
|
cl = _cellHeaderSelectedBackgroundColor;
|
||||||
|
dw = _cellHeaderSelectedBackgroundDrawable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
buf.fillRect(rc, cl);
|
if (!dw.isNull)
|
||||||
|
dw.drawTo(buf, rc);
|
||||||
|
else
|
||||||
|
buf.fillRect(rc, cl);
|
||||||
static if (BACKEND_GUI) {
|
static if (BACKEND_GUI) {
|
||||||
uint borderColor = _cellHeaderBorderColor;
|
uint borderColor = _cellHeaderBorderColor;
|
||||||
buf.drawLine(Point(rc.right - 1, rc.bottom), Point(rc.right - 1, rc.top), _cellHeaderBorderColor); // vertical
|
buf.drawLine(Point(rc.right - 1, rc.bottom), Point(rc.right - 1, rc.top), _cellHeaderBorderColor); // vertical
|
||||||
|
@ -1696,6 +1740,10 @@ class StringGridWidget : StringGridWidgetBase {
|
||||||
_cellHeaderBorderColor = style.customColor("grid_cell_border_color_header", 0xC0202020);
|
_cellHeaderBorderColor = style.customColor("grid_cell_border_color_header", 0xC0202020);
|
||||||
_cellHeaderBackgroundColor = style.customColor("grid_cell_background_header", 0xC0909090);
|
_cellHeaderBackgroundColor = style.customColor("grid_cell_background_header", 0xC0909090);
|
||||||
_cellHeaderSelectedBackgroundColor = style.customColor("grid_cell_background_header_selected", 0x80FFC040);
|
_cellHeaderSelectedBackgroundColor = style.customColor("grid_cell_background_header_selected", 0x80FFC040);
|
||||||
|
_cellHeaderBackgroundDrawable = style.customDrawable("grid_cell_background_header");
|
||||||
|
_cellHeaderSelectedBackgroundDrawable = style.customDrawable("grid_cell_background_header_selected");
|
||||||
|
_cellRowHeaderBackgroundDrawable = style.customDrawable("grid_cell_background_row_header");
|
||||||
|
_cellRowHeaderSelectedBackgroundDrawable = style.customDrawable("grid_cell_background_row_header_selected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,10 @@
|
||||||
<drawable id="scrollbar_button_right" value="{'►' #FFFF00}"/>
|
<drawable id="scrollbar_button_right" value="{'►' #FFFF00}"/>
|
||||||
<drawable id="scrollbar_indicator_vertical" value="{'' #FFFF00}"/>
|
<drawable id="scrollbar_indicator_vertical" value="{'' #FFFF00}"/>
|
||||||
<drawable id="scrollbar_indicator_horizontal" value="{'' #FFFF00}"/>
|
<drawable id="scrollbar_indicator_horizontal" value="{'' #FFFF00}"/>
|
||||||
|
<drawable id="grid_cell_background_header" value="{' │' #000000 bc #808080 ninepatch 0 0 1 0 padding 0 0 1 0}"/>
|
||||||
|
<drawable id="grid_cell_background_row_header" value="{' ▐' #000000 bc #808080 ninepatch 0 0 1 0 padding 0 0 1 0}"/>
|
||||||
|
<drawable id="grid_cell_background_header_selected" value="{' │' #000000 bc #008000 #808080 ninepatch 0 0 1 0 padding 0 0 1 0}"/>
|
||||||
|
<drawable id="grid_cell_background_row_header_selected" value="{' ▐' #000000 bc #008000 ninepatch 0 0 1 0 padding 0 0 1 0}"/>
|
||||||
|
|
||||||
<style id="BUTTON"
|
<style id="BUTTON"
|
||||||
backgroundImageId="{'▄' ' ' '▀' tc 0x808080 bc 0xFFFFFFFF 0x808080 0xFFFFFFFF ninepatch 0 1 0 1 padding 1 1 1 1}"
|
backgroundImageId="{'▄' ' ' '▀' tc 0x808080 bc 0xFFFFFFFF 0x808080 0xFFFFFFFF ninepatch 0 1 0 1 padding 1 1 1 1}"
|
||||||
|
|
Loading…
Reference in New Issue