Skip to content

Commit

Permalink
GridView, TreeGridView: add headerCornerSkin (closes #161)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtynjala committed Nov 29, 2023
1 parent dee0e1f commit 6d904c5
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/feathers/controls/GridView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,19 @@ class GridView extends BaseScrollContainer implements IIndexSelector implements
@:style
public var columnResizeSkin:DisplayObject = null;

private var _currentHeaderCornerSkin:DisplayObject;

/**
The skin to display next to the headers when the vertical scroll bar is
displayed, and `extendedScrollBarY` is `false`.
@see `GridView.extendedScrollBarY`
@since 1.3.0
**/
@:style
public var headerCornerSkin:DisplayObject = null;

private var _sortOrder:SortOrder = NONE;

/**
Expand Down Expand Up @@ -1390,6 +1403,10 @@ class GridView extends BaseScrollContainer implements IIndexSelector implements
this.refreshSortedColumn(sortInvalid);
}

if (stylesInvalid) {
this.refreshHeaderCornerSkin();
}

if (stylesInvalid || layoutInvalid) {
this.refreshColumnResizeSkin();
}
Expand Down Expand Up @@ -1603,6 +1620,18 @@ class GridView extends BaseScrollContainer implements IIndexSelector implements
} else {
this._headerContainer.scrollRect = null;
}

if (this._currentHeaderCornerSkin != null) {
if (this.fixedScrollBars && !this.extendedScrollBarY && this.scrollBarY != null && this.scrollBarY.visible) {
this._currentHeaderCornerSkin.x = this.scrollBarY.x;
this._currentHeaderCornerSkin.width = this.scrollBarY.width;
this._currentHeaderCornerSkin.y = this._headerContainer.y;
this._currentHeaderCornerSkin.height = this._headerContainer.height;
this._currentHeaderCornerSkin.visible = true;
} else {
this._currentHeaderCornerSkin.visible = false;
}
}
}

private function layoutHeaderDividers():Void {
Expand Down Expand Up @@ -1647,6 +1676,45 @@ class GridView extends BaseScrollContainer implements IIndexSelector implements
this.topViewPortOffset = oldTopViewPortOffset;
}

private function refreshHeaderCornerSkin():Void {
var oldSkin = this._currentHeaderCornerSkin;
this._currentHeaderCornerSkin = this.getCurrentHeaderCornerSkin();
if (this._currentHeaderCornerSkin == oldSkin) {
return;
}
this.removeCurrentHeaderCornerSkin(oldSkin);
this.addCurrentHeaderCornerSkin(this._currentHeaderCornerSkin);
}

private function getCurrentHeaderCornerSkin():DisplayObject {
return this.headerCornerSkin;
}

private function addCurrentHeaderCornerSkin(skin:DisplayObject):Void {
if (skin == null) {
return;
}
if ((skin is IUIControl)) {
cast(skin, IUIControl).initializeNow();
}
if ((skin is IProgrammaticSkin)) {
cast(skin, IProgrammaticSkin).uiContext = this;
}
this.addChild(skin);
}

private function removeCurrentHeaderCornerSkin(skin:DisplayObject):Void {
if (skin == null) {
return;
}
if ((skin is IProgrammaticSkin)) {
cast(skin, IProgrammaticSkin).uiContext = null;
}
if (skin.parent == this) {
this.removeChild(skin);
}
}

private function refreshColumnResizeSkin():Void {
var oldSkin = this._currentColumnResizeSkin;
this._currentColumnResizeSkin = this.getCurrentColumnResizeSkin();
Expand Down
68 changes: 68 additions & 0 deletions src/feathers/controls/TreeGridView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,19 @@ class TreeGridView extends BaseScrollContainer implements IDataSelector<Dynamic>
@:style
public var columnResizeSkin:DisplayObject = null;

private var _currentHeaderCornerSkin:DisplayObject;

/**
The skin to display next to the headers when the vertical scroll bar is
displayed, and `extendedScrollBarY` is `false`.
@see `TreeGridView.extendedScrollBarY`
@since 1.3.0
**/
@:style
public var headerCornerSkin:DisplayObject = null;

private var dataToHeaderRenderer = new ObjectMap<TreeGridViewColumn, DisplayObject>();
private var headerRendererToHeaderState = new ObjectMap<DisplayObject, TreeGridViewHeaderState>();
private var inactiveRowRenderers:Array<TreeGridViewRowRenderer> = [];
Expand Down Expand Up @@ -1204,6 +1217,10 @@ class TreeGridView extends BaseScrollContainer implements IDataSelector<Dynamic>

this.validateColumns();

if (stylesInvalid) {
this.refreshHeaderCornerSkin();
}

if (stylesInvalid || layoutInvalid) {
this.refreshColumnResizeSkin();
}
Expand Down Expand Up @@ -1415,6 +1432,18 @@ class TreeGridView extends BaseScrollContainer implements IDataSelector<Dynamic>
} else {
this._headerContainer.scrollRect = null;
}

if (this._currentHeaderCornerSkin != null) {
if (this.fixedScrollBars && !this.extendedScrollBarY && this.scrollBarY != null && this.scrollBarY.visible) {
this._currentHeaderCornerSkin.x = this.scrollBarY.x;
this._currentHeaderCornerSkin.width = this.scrollBarY.width;
this._currentHeaderCornerSkin.y = this._headerContainer.y;
this._currentHeaderCornerSkin.height = this._headerContainer.height;
this._currentHeaderCornerSkin.visible = true;
} else {
this._currentHeaderCornerSkin.visible = false;
}
}
}

private function layoutHeaderDividers():Void {
Expand Down Expand Up @@ -1459,6 +1488,45 @@ class TreeGridView extends BaseScrollContainer implements IDataSelector<Dynamic>
this.topViewPortOffset = oldTopViewPortOffset;
}

private function refreshHeaderCornerSkin():Void {
var oldSkin = this._currentHeaderCornerSkin;
this._currentHeaderCornerSkin = this.getCurrentHeaderCornerSkin();
if (this._currentHeaderCornerSkin == oldSkin) {
return;
}
this.removeCurrentHeaderCornerSkin(oldSkin);
this.addCurrentHeaderCornerSkin(this._currentHeaderCornerSkin);
}

private function getCurrentHeaderCornerSkin():DisplayObject {
return this.headerCornerSkin;
}

private function addCurrentHeaderCornerSkin(skin:DisplayObject):Void {
if (skin == null) {
return;
}
if ((skin is IUIControl)) {
cast(skin, IUIControl).initializeNow();
}
if ((skin is IProgrammaticSkin)) {
cast(skin, IProgrammaticSkin).uiContext = this;
}
this.addChild(skin);
}

private function removeCurrentHeaderCornerSkin(skin:DisplayObject):Void {
if (skin == null) {
return;
}
if ((skin is IProgrammaticSkin)) {
cast(skin, IProgrammaticSkin).uiContext = null;
}
if (skin.parent == this) {
this.removeChild(skin);
}
}

private function refreshColumnResizeSkin():Void {
var oldSkin = this._currentColumnResizeSkin;
this._currentColumnResizeSkin = this.getCurrentColumnResizeSkin();
Expand Down
12 changes: 12 additions & 0 deletions src/feathers/themes/steel/components/SteelGridViewStyles.hx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ class SteelGridViewStyles {
gridView.columnResizeSkin = columnResizeSkin;
}

if (gridView.headerCornerSkin == null) {
var headerCornerSkin = new RectangleSkin();
headerCornerSkin.fill = theme.getSubHeadingFill();
gridView.headerCornerSkin = headerCornerSkin;
}

if (gridView.focusRectSkin == null) {
var focusRectSkin = new RectangleSkin();
focusRectSkin.fill = null;
Expand Down Expand Up @@ -111,6 +117,12 @@ class SteelGridViewStyles {
gridView.columnResizeSkin = columnResizeSkin;
}

if (gridView.headerCornerSkin == null) {
var headerCornerSkin = new RectangleSkin();
headerCornerSkin.fill = theme.getSubHeadingFill();
gridView.headerCornerSkin = headerCornerSkin;
}

if (gridView.focusRectSkin == null) {
var skin = new RectangleSkin();
skin.fill = null;
Expand Down
12 changes: 12 additions & 0 deletions src/feathers/themes/steel/components/SteelTreeGridViewStyles.hx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ class SteelTreeGridViewStyles {
gridView.columnResizeSkin = columnResizeSkin;
}

if (gridView.headerCornerSkin == null) {
var headerCornerSkin = new RectangleSkin();
headerCornerSkin.fill = theme.getSubHeadingFill();
gridView.headerCornerSkin = headerCornerSkin;
}

if (gridView.focusRectSkin == null) {
var focusRectSkin = new RectangleSkin();
focusRectSkin.fill = null;
Expand Down Expand Up @@ -110,6 +116,12 @@ class SteelTreeGridViewStyles {
gridView.columnResizeSkin = columnResizeSkin;
}

if (gridView.headerCornerSkin == null) {
var headerCornerSkin = new RectangleSkin();
headerCornerSkin.fill = theme.getSubHeadingFill();
gridView.headerCornerSkin = headerCornerSkin;
}

if (gridView.focusRectSkin == null) {
var skin = new RectangleSkin();
skin.fill = null;
Expand Down

0 comments on commit 6d904c5

Please sign in to comment.