package com.peterhi.ui.obsolete;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import com.peterhi.ui.UIImageResource;
public final class StripBar extends Canvas implements Listener {
enum Placement {
TOP,
LEFT_ROTATE_TEXT,
LEFT_ROTATE_ALL,
RIGHT_ROTATE_TEXT,
RIGHT_ROTATE_ALL;
public boolean isRotateText() {
if (equals(LEFT_ROTATE_TEXT)) {
return true;
}
if (equals(RIGHT_ROTATE_TEXT)) {
return true;
}
return false;
}
public boolean isRotateAll() {
if (equals(LEFT_ROTATE_ALL)) {
return true;
}
if (equals(RIGHT_ROTATE_ALL)) {
return true;
}
return false;
}
public boolean isLeft() {
if (equals(LEFT_ROTATE_ALL)) {
return true;
}
if (equals(LEFT_ROTATE_TEXT)) {
return true;
}
return false;
}
public boolean isRight() {
if (equals(RIGHT_ROTATE_ALL)) {
return true;
}
if (equals(RIGHT_ROTATE_TEXT)) {
return true;
}
return false;
}
}
enum ItemSizing {
DEFAULT,
EQUAL,
STRETCH
}
enum ItemCenter {
NONE,
TEXT,
ALL
}
private int hMargin = 5;
private int vMargin = 5;
private int hSpace = 5;
private int hInset = 10;
private int vInset = 5;
private int roundArc = 6;
private int textIndent = 8;
private int closeIndent = 12;
private boolean vFill;
private Placement placement = Placement.LEFT_ROTATE_ALL;
private ItemSizing hSizing = ItemSizing.STRETCH;
private ItemCenter hCenter = ItemCenter.ALL;
private final List<StripItem> items = new ArrayList<StripItem>();
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell(display);
StripBar stripBar = new StripBar(shell, SWT.DOUBLE_BUFFERED | SWT.BORDER);
GridLayout layout = new GridLayout();
GridData layoutData = new GridData();
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginWidth = 0;
layout.marginHeight = 0;
shell.setLayout(layout);
layoutData.horizontalAlignment = SWT.FILL;
layoutData.verticalAlignment = SWT.FILL;
layoutData.grabExcessHorizontalSpace = false;
layoutData.grabExcessVerticalSpace = true;
stripBar.setLayoutData(layoutData);
StripItem item0 = new StripItem(stripBar, SWT.NONE);
StripItem item2 = new StripItem(stripBar, SWT.NONE);
StripItem item3 = new StripItem(stripBar, SWT.NONE);
StripItem item1 = new StripItem(stripBar, SWT.NONE, 1);
item0.setText("Item 0");
item1.setText("Item 1");
item0.setImage(UIImageResource.T.addContact16());
item2.setImage(UIImageResource.T.foo());
shell.layout();
stripBar.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
public StripBar(Composite parent, int style) {
super(parent, style);
addListener(SWT.Paint, this);
addListener(SWT.Dispose, this);
}
@Override
public void handleEvent(Event event) {
if (!equals(event.widget)) {
return;
}
if (event.type == SWT.Paint) {
onPaint(event);
} else if (event.type == SWT.Dispose) {
onDispose(event);
}
}
public int indexOf(StripItem item) {
if (item == null) {
throw new NullPointerException();
}
return items.indexOf(item);
}
public boolean contains(StripItem item) {
int index = indexOf(item);
if (index < 0) {
return false;
}
return true;
}
public int size() {
return items.size();
}
public StripItem[] toArray() {
StripItem[] array = new StripItem[size()];
return items.toArray(array);
}
@Override
public Point computeSize(int widthHint, int heightHint, boolean changed) {
Point size = computeInteriorSize();
int width;
int height;
if (placement == Placement.TOP) {
width = size.x;
height = size.y;
} else {
width = size.y;
height = size.x;
}
Rectangle trim = computeTrim(0, 0, width, height);
size.x = trim.width;
size.y = trim.height;
return size;
}
@Override
public void layout(boolean changed) {
super.layout(changed);
for (StripItem item : items) {
Rectangle bounds = computeBounds(item);
item.setBounds(bounds, false);
}
}
@Override
public void setLayout(Layout layout) {
throw new UnsupportedOperationException();
}
@Override
public void setLayoutDeferred(boolean deferred) {
throw new UnsupportedOperationException();
}
protected void onPaint(Event event) {
GC gc = event.gc;
List<StripItem> items = itemsInPaintOrder();
for (StripItem item : items) {
paint(gc, item);
}
}
protected void onDispose(Event event) {
StripItem[] items = toArray();
for (StripItem item : items) {
item.dispose();
}
}
void internalAdd(StripItem item, int index) {
if (item == null) {
throw new NullPointerException();
}
if (index < -1) {
throw new IllegalArgumentException();
}
if (index > size()) {
throw new IllegalArgumentException();
}
if (contains(item)) {
throw new IllegalArgumentException();
}
if (index == -1) {
index = size();
}
items.add(index, item);
}
void internalRemove(StripItem item) {
check(item);
items.remove(item);
}
private boolean hasImage(StripItem item) {
check(item);
Image image = item.getImage();
if (image == null) {
return false;
}
return true;
}
private boolean hasText(StripItem item) {
check(item);
String text = item.getText();
if (text == null) {
return false;
}
if (text.isEmpty()) {
return false;
}
return true;
}
private Point getImageSize(StripItem item) {
check(item);
Point size = new Point(0, 0);
if (hasImage(item)) {
Image image = item.getImage();
Rectangle imageBounds = image.getBounds();
size.x = imageBounds.width;
size.y = imageBounds.height;
}
return size;
}
private Point getTextSize(StripItem item) {
check(item);
Point size = new Point(0, 0);
if (hasText(item)) {
String text = item.getText();
GC gc = new GC(this);
size = gc.stringExtent(text);
gc.dispose();
}
return size;
}
private Point getCloseButtonSize() {
Image closeButtonImage = getCloseButtonImage(false);
Rectangle closeButtonImageBounds = closeButtonImage.getBounds();
return new Point(closeButtonImageBounds.width, closeButtonImageBounds.height);
}
private void check(StripItem item) {
if (item == null) {
throw new NullPointerException();
}
if (!contains(item)) {
throw new NullPointerException();
}
}
private Image getCloseButtonImage(boolean highlightOrNormal) {
UIImageResource res = UIImageResource.T;
if (highlightOrNormal) {
return res.closeHighlight10();
}
return res.closeNormal10();
}
private Point computeSize(StripItem item) {
check(item);
Point size = new Point(0, 0);
size.x = computeWidth(item);
size.y = computeHeight(item);
return size;
}
private int computeWidth(StripItem item) {
check(item);
int width = 0;
if (hSizing == ItemSizing.EQUAL) {
for (StripItem anItem : items) {
int sum = sumComponentWidthsOf(anItem);
width = Math.max(width, sum);
}
} else if (hSizing == ItemSizing.STRETCH) {
Rectangle clientArea = getClientArea();
int total;
if (placement != Placement.TOP) {
total = clientArea.height;
} else {
total = clientArea.width;
}
total -= hSpace * (size() - 1);
total -= hMargin * 2;
width = total / size();
if (indexOf(item) == size() - 1) {
width = total - width * (size() - 1);
}
} else {
width = sumComponentWidthsOf(item);
}
return width;
}
private int sumComponentWidthsOf(StripItem item) {
int width = 0;
if (hasImage(item)) {
Point imageSize = getImageSize(item);
if (placement.isRotateText()) {
width += imageSize.y;
} else {
width += imageSize.x;
}
}
if (hasText(item)) {
if (hasImage(item)) {
width += textIndent;
}
Point textSize = getTextSize(item);
width += textSize.x;
}
if (hasImage(item) || hasText(item)) {
width += closeIndent;
}
Point closeButtonSize = getCloseButtonSize();
if (placement.isRotateText()) {
width += closeButtonSize.y;
} else {
width += closeButtonSize.x;
}
width += hInset * 2;
return width;
}
private int computeHeight(StripItem item) {
check(item);
int height = 0;
if (vFill) {
Rectangle clientArea = getClientArea();
if (placement != Placement.TOP) {
height = clientArea.width;
} else {
height = clientArea.height;
}
height -= vMargin * 2;
} else {
for (StripItem anItem : items) {
if (hasImage(anItem)) {
Point imageSize = getImageSize(anItem);
int maxHeight;
if (placement.isRotateText()) {
maxHeight = imageSize.x;
} else {
maxHeight = imageSize.y;
}
height = Math.max(height, maxHeight);
}
if (hasText(anItem)) {
Point textSize = getTextSize(anItem);
height = Math.max(height, textSize.y);
}
Point closeButtonSize = getCloseButtonSize();
int maxHeight;
if (placement.isRotateText()) {
maxHeight = closeButtonSize.x;
} else {
maxHeight = closeButtonSize.y;
}
height = Math.max(height, maxHeight);
}
height += vInset * 2;
}
return height;
}
private Point computeInteriorSize() {
Point size = new Point(0, 0);
for (StripItem item : items) {
Point itemSize = computeSize(item);
size.x += itemSize.x;
size.y = Math.max(size.y, itemSize.y);
}
size.x += hMargin * 2;
size.x += hSpace * (size() - 1);
size.y += vMargin * 2;
return size;
}
private Rectangle computeBounds(StripItem item) {
Rectangle bounds = new Rectangle(0, 0, 0, 0);
if (placement != Placement.TOP) {
bounds.x = vMargin;
bounds.y = hMargin;
} else {
bounds.x = hMargin;
bounds.y = vMargin;
}
for (StripItem anItem : items) {
Point size = computeSize(anItem);
if (anItem.equals(item)) {
if (placement != Placement.TOP) {
bounds.height = size.x;
} else {
bounds.width = size.x;
}
break;
} else {
if (placement != Placement.TOP) {
bounds.y += size.x;
bounds.y += hSpace;
} else {
bounds.x += size.x;
bounds.x += hSpace;
}
}
}
if (placement != Placement.TOP) {
bounds.width = computeHeight(item);
} else {
bounds.height = computeHeight(item);
}
return bounds;
}
private List<StripItem> itemsInPaintOrder() {
// TODO: use real impl, not this stub
return new ArrayList<StripItem>(items);
}
private void paint(GC gc, StripItem item) {
paintBackground(gc, item);
paintImage(gc, item);
paintText(gc, item);
paintCloseButton(gc, item);
paintBorder(gc, item);
}
private void paintBackground(GC gc, StripItem item) {
}
private void paintImage(GC gc, StripItem item) {
if (!hasImage(item)) {
return;
}
Display display = getDisplay();
Image image = item.getImage();
Rectangle boundsNow = item.getBoundsNow();
Rectangle imageBounds = computeImageBounds(item, boundsNow);
Transform transform = new Transform(display);
if (placement.isRotateAll()) {
transform.translate(imageBounds.x, imageBounds.y);
if (placement == Placement.LEFT_ROTATE_ALL) {
transform.translate(0, imageBounds.height);
transform.rotate(-90);
} else if (placement == Placement.RIGHT_ROTATE_ALL) {
transform.rotate(90);
transform.translate(0, -imageBounds.width);
}
transform.translate(-imageBounds.x, -imageBounds.y);
}
gc.setTransform(transform);
gc.drawImage(image, imageBounds.x, imageBounds.y);
gc.setTransform(null);
transform.dispose();
}
private void paintText(GC gc, StripItem item) {
if (!hasText(item)) {
return;
}
Display display = getDisplay();
String text = item.getText();
Rectangle boundsNow = item.getBoundsNow();
Rectangle textBounds = computeTextBounds(item, boundsNow);
Transform transform = new Transform(display);
if (placement != Placement.TOP) {
transform.translate(textBounds.x, textBounds.y);
if (placement.isLeft()) {
transform.translate(0, textBounds.height);
transform.rotate(-90);
} else if (placement.isRight()) {
transform.rotate(90);
transform.translate(0, -textBounds.width);
}
transform.translate(-textBounds.x, -textBounds.y);
}
gc.setTransform(transform);
gc.drawText(text, textBounds.x, textBounds.y, true);
gc.setTransform(null);
transform.dispose();
}
private void paintCloseButton(GC gc, StripItem item) {
Display display = getDisplay();
Image closeButtonImage = getCloseButtonImage(false);
Rectangle boundsNow = item.getBoundsNow();
Rectangle closeButtonBounds = computeCloseButtonBounds(item, boundsNow);
Transform transform = new Transform(display);
if (placement.isRotateAll()) {
transform.translate(closeButtonBounds.x, closeButtonBounds.y);
if (placement == Placement.LEFT_ROTATE_ALL) {
transform.translate(0, closeButtonBounds.height);
transform.rotate(-90);
} else if (placement == Placement.RIGHT_ROTATE_ALL) {
transform.rotate(90);
transform.translate(0, -closeButtonBounds.width);
}
transform.translate(-closeButtonBounds.x, -closeButtonBounds.y);
}
gc.setTransform(transform);
gc.drawImage(closeButtonImage, closeButtonBounds.x, closeButtonBounds.y);
gc.setTransform(null);
transform.dispose();
}
private void paintBorder(GC gc, StripItem item) {
Display display = Display.getDefault();
Color oldFore = gc.getForeground();
Color newFore = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
gc.setForeground(newFore);
Rectangle boundsNow = item.getBoundsNow();
boundsNow.width --;
boundsNow.height --;
gc.drawRoundRectangle(boundsNow.x, boundsNow.y, boundsNow.width, boundsNow.height, roundArc, roundArc);
gc.setForeground(oldFore);
}
private Rectangle computeImageBounds(StripItem item, Rectangle bounds) {
if (hCenter == ItemCenter.ALL && hSizing != ItemSizing.DEFAULT) {
Rectangle imageBounds = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
Point imageSize = getImageSize(item);
Point textSize = getTextSize(item);
Point closeButtonSize = getCloseButtonSize();
if (placement != Placement.TOP) {
if (placement.isRotateText()) {
int remaining = bounds.height;
remaining -= hInset * 2;
remaining -= closeButtonSize.y;
remaining -= closeIndent;
int text = remaining;
text -= hasImage(item) ? textIndent : 0;
text -= imageSize.y;
text = Math.min(text, textSize.x);
int total = text;
total += hasImage(item) ? textIndent : 0;
total += imageSize.y;
imageBounds.x += imageBounds.width / 2 - imageSize.x / 2;
imageBounds.y += hInset + remaining / 2 - total / 2;
imageBounds.width = imageSize.x;
imageBounds.height = imageSize.y;
} else {
int remaining = bounds.height;
remaining -= hInset * 2;
remaining -= closeButtonSize.x;
remaining -= closeIndent;
int text = remaining;
text -= hasImage(item) ? textIndent : 0;
text -= imageSize.x;
text = Math.min(text, textSize.x);
int total = text;
total += hasImage(item) ? textIndent : 0;
total += imageSize.x;
imageBounds.x += imageBounds.width / 2 - imageSize.y / 2;
imageBounds.y += hInset + remaining / 2 - total / 2;
imageBounds.width = imageSize.y;
imageBounds.height = imageSize.x;
}
} else {
int remaining = bounds.width;
remaining -= hInset * 2;
remaining -= closeButtonSize.x;
remaining -= closeIndent;
int text = remaining;
text -= hasImage(item) ? textIndent : 0;
text -= imageSize.x;
text = Math.min(text, textSize.x);
int total = text;
total += hasImage(item) ? textIndent : 0;
total += imageSize.x;
imageBounds.x += hInset + remaining / 2 - total / 2;
imageBounds.y += imageBounds.height / 2 - imageSize.y / 2;
imageBounds.width = imageSize.x;
imageBounds.height = imageSize.y;
}
return imageBounds;
} else {
Rectangle imageBounds = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
if (placement != Placement.TOP) {
imageBounds.x += imageBounds.width / 2;
imageBounds.y += hInset;
} else {
imageBounds.x += hInset;
imageBounds.y += imageBounds.height / 2;
}
imageBounds.width = 0;
imageBounds.height = 0;
if (hasImage(item)) {
Point imageSize = getImageSize(item);
if (placement != Placement.TOP) {
if (placement.isRotateText()) {
imageBounds.x -= imageSize.x / 2;
imageBounds.width = imageSize.x;
imageBounds.height = imageSize.y;
} else {
imageBounds.x -= imageSize.y / 2;
imageBounds.width = imageSize.y;
imageBounds.height = imageSize.x;
}
} else {
imageBounds.y -= imageSize.y / 2;
imageBounds.width = imageSize.x;
imageBounds.height = imageSize.y;
}
}
return imageBounds;
}
}
private Rectangle computeTextBounds(StripItem item, Rectangle bounds) {
if (hCenter == ItemCenter.ALL) {
Rectangle textBounds = computeImageBounds(item, bounds);
Point imageSize = getImageSize(item);
Point textSize = getTextSize(item);
Point closeButtonSize = getCloseButtonSize();
if (placement != Placement.TOP) {
textBounds.x += textBounds.width / 2;
textBounds.y += textBounds.height;
textBounds.width = 0;
textBounds.height = 0;
if (hasText(item)) {
if (hasImage(item)) {
textBounds.y += textIndent;
}
int remaining = bounds.height;
remaining -= hInset * 2;
if (placement.isRotateText()) {
remaining -= imageSize.y;
} else {
remaining -= imageSize.x;
}
remaining -= hasImage(item) ? textIndent : 0;
remaining -= closeIndent;
if (placement.isRotateText()) {
remaining -= closeButtonSize.y;
} else {
remaining -= closeButtonSize.x;
}
int text = remaining;
text = Math.min(text, textSize.x);
textBounds.x -= textSize.y / 2;
textBounds.width = textSize.y;
textBounds.height = text;
}
} else {
textBounds.x += textBounds.width;
textBounds.y += textBounds.height / 2;
textBounds.width = 0;
textBounds.height = 0;
if (hasText(item)) {
if (hasImage(item)) {
textBounds.x += textIndent;
}
int remaining = bounds.width;
remaining -= hInset * 2;
if (placement.isRotateText()) {
remaining -= imageSize.y;
} else {
remaining -= imageSize.x;
}
remaining -= hasImage(item) ? textIndent : 0;
remaining -= closeIndent;
if (placement.isRotateText()) {
remaining -= closeButtonSize.y;
} else {
remaining -= closeButtonSize.x;
}
int text = remaining;
text = Math.min(text, textSize.x);
textBounds.y -= textSize.y / 2;
textBounds.width = text;
textBounds.height = textSize.y;
}
}
return textBounds;
} else if (hCenter != ItemCenter.NONE) {
Rectangle textBounds = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
if (placement != Placement.TOP) {
Point imageSize = getImageSize(item);
Point textSize = getTextSize(item);
Point closeButtonSize = getCloseButtonSize();
int remaining = bounds.height;
remaining -= hInset * 2;
if (placement.isRotateText()) {
remaining -= imageSize.y;
} else {
remaining -= imageSize.x;
}
remaining -= hasImage(item) ? textIndent : 0;
remaining -= closeIndent;
if (placement.isRotateText()) {
remaining -= closeButtonSize.y;
} else {
remaining -= closeButtonSize.x;
}
int text = remaining;
text = Math.min(text, textSize.x);
textBounds.x += textBounds.width / 2;
textBounds.x -= textSize.y / 2;
textBounds.y += hInset;
if (placement.isRotateText()) {
textBounds.y += imageSize.y;
} else {
textBounds.y += imageSize.x;
}
textBounds.y += hasImage(item) ? textIndent : 0;
textBounds.y += remaining / 2 - text / 2;
textBounds.width = textSize.y;
textBounds.height = textSize.x;
} else {
Point imageSize = getImageSize(item);
Point textSize = getTextSize(item);
Point closeButtonSize = getCloseButtonSize();
int remaining = bounds.width;
remaining -= hInset * 2;
remaining -= imageSize.x;
remaining -= hasImage(item) ? textIndent : 0;
remaining -= closeIndent;
remaining -= closeButtonSize.x;
int text = remaining;
text = Math.min(text, textSize.x);
textBounds.x += hInset;
textBounds.x += imageSize.x;
textBounds.x += hasImage(item) ? textIndent : 0;
textBounds.x += remaining / 2 - text / 2;
textBounds.y += textBounds.height / 2;
textBounds.y -= textSize.y / 2;
textBounds.width = textSize.x;
textBounds.height = textSize.y;
}
return textBounds;
} else {
Rectangle textBounds = computeImageBounds(item, bounds);
if (placement != Placement.TOP) {
textBounds.x += textBounds.width / 2;
textBounds.y += textBounds.height;
} else {
textBounds.x += textBounds.width;
textBounds.y += textBounds.height / 2;
}
textBounds.width = 0;
textBounds.height = 0;
if (hasText(item)) {
if (hasImage(item)) {
if (placement != Placement.TOP) {
textBounds.y += textIndent;
} else {
textBounds.x += textIndent;
}
}
Point textSize = getTextSize(item);
if (placement != Placement.TOP) {
textBounds.x -= textSize.y / 2;
textBounds.width = textSize.y;
textBounds.height = textSize.x;
} else {
textBounds.y -= textSize.y / 2;
textBounds.width = textSize.x;
textBounds.height = textSize.y;
}
}
return textBounds;
}
}
private Rectangle computeCloseButtonBounds(StripItem item, Rectangle bounds) {
if (hSizing == ItemSizing.DEFAULT) {
Rectangle closeButtonBounds = computeTextBounds(item, bounds);
if (placement != Placement.TOP) {
closeButtonBounds.x += closeButtonBounds.width / 2;
closeButtonBounds.y += closeButtonBounds.height;
} else {
closeButtonBounds.x += closeButtonBounds.width;
closeButtonBounds.y += closeButtonBounds.height / 2;
}
if (hasImage(item) || hasText(item)) {
if (placement != Placement.TOP) {
closeButtonBounds.y += closeIndent;
} else {
closeButtonBounds.x += closeIndent;
}
}
Point closeButtonSize = getCloseButtonSize();
if (placement != Placement.TOP) {
if (placement.isRotateText()) {
closeButtonBounds.x -= closeButtonSize.x / 2;
closeButtonBounds.width = closeButtonSize.x;
closeButtonBounds.height = closeButtonSize.y;
} else {
closeButtonBounds.x -= closeButtonSize.y / 2;
closeButtonBounds.width = closeButtonSize.y;
closeButtonBounds.height = closeButtonSize.x;
}
} else {
closeButtonBounds.y -= closeButtonSize.y / 2;
closeButtonBounds.width = closeButtonSize.x;
closeButtonBounds.height = closeButtonSize.y;
}
return closeButtonBounds;
} else {
Point closeButtonSize = getCloseButtonSize();
Rectangle closeButtonBounds = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
if (placement != Placement.TOP) {
if (placement.isRotateText()) {
closeButtonBounds.x += closeButtonBounds.width / 2;
closeButtonBounds.x -= closeButtonSize.x / 2;
closeButtonBounds.y += closeButtonBounds.height;
closeButtonBounds.y -= hInset;
closeButtonBounds.y -= closeButtonSize.y;
closeButtonBounds.width = closeButtonSize.x;
closeButtonBounds.height = closeButtonSize.y;
} else {
closeButtonBounds.x += closeButtonBounds.width / 2;
closeButtonBounds.x -= closeButtonSize.y / 2;
closeButtonBounds.y += closeButtonBounds.height;
closeButtonBounds.y -= hInset;
closeButtonBounds.y -= closeButtonSize.y;
closeButtonBounds.width = closeButtonSize.y;
closeButtonBounds.height = closeButtonSize.x;
}
} else {
closeButtonBounds.x += closeButtonBounds.width;
closeButtonBounds.x -= hInset;
closeButtonBounds.x -= closeButtonSize.x;
closeButtonBounds.y += closeButtonBounds.height / 2;
closeButtonBounds.y -= closeButtonSize.y / 2;
closeButtonBounds.width = closeButtonSize.x;
closeButtonBounds.height = closeButtonSize.y;
}
return closeButtonBounds;
}
}
}