You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/10/05 20:24:16 UTC
svn commit: r1004757 - in /pivot/trunk:
wtk-terra/src/org/apache/pivot/wtk/skin/terra/
wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/skin/
Author: gbrown
Date: Tue Oct 5 18:24:16 2010
New Revision: 1004757
URL: http://svn.apache.org/viewvc?rev=1004757&view=rev
Log:
Fix bug with checkbox hit detection in TerraListViewSkin; don't fire button press events from popup buttons unless the button is repeatable; fire press event when a new item is selected in a repeatable list button.
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java?rev=1004757&r1=1004756&r2=1004757&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java Tue Oct 5 18:24:16 2010
@@ -844,10 +844,9 @@ public class TerraListViewSkin extends C
if (itemIndex != -1
&& !listView.isItemDisabled(itemIndex)) {
- int itemY = getItemBounds(itemIndex).y;
-
- if (!(listView.getCheckmarksEnabled()
- && isMouseOverCheckbox(itemY, x, y))) {
+ if (!listView.getCheckmarksEnabled()
+ || listView.isCheckmarkDisabled(itemIndex)
+ || !getCheckboxBounds(itemIndex).contains(x, y)) {
ListView.SelectMode selectMode = listView.getSelectMode();
if (button == Mouse.Button.RIGHT) {
@@ -929,12 +928,11 @@ public class TerraListViewSkin extends C
ListView listView = (ListView)getComponent();
int itemIndex = getItemAt(y);
- if (!listView.isItemDisabled(itemIndex)) {
- int itemY = getItemBounds(itemIndex).y;
-
+ if (itemIndex != -1
+ && !listView.isItemDisabled(itemIndex)) {
if (listView.getCheckmarksEnabled()
&& !listView.isCheckmarkDisabled(itemIndex)
- && isMouseOverCheckbox(itemY, x, y)) {
+ && getCheckboxBounds(itemIndex).contains(x, y)) {
listView.setItemChecked(itemIndex, !listView.isItemChecked(itemIndex));
} else {
if (selectIndex != -1
@@ -953,11 +951,14 @@ public class TerraListViewSkin extends C
return consumed;
}
- private boolean isMouseOverCheckbox(int itemY, int x, int y) {
- return (x > checkboxPadding.left
- && x < checkboxPadding.left + CHECKBOX.getWidth()
- && y > itemY + checkboxPadding.top
- && y < itemY + checkboxPadding.top + CHECKBOX.getHeight());
+ private Bounds getCheckboxBounds(int itemIndex) {
+ Bounds itemBounds = getItemBounds(itemIndex);
+
+ int checkboxHeight = CHECKBOX.getHeight();
+ return new Bounds(checkboxPadding.left,
+ itemBounds.y + (itemBounds.height - checkboxHeight) / 2,
+ CHECKBOX.getWidth(),
+ checkboxHeight);
}
@Override
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java?rev=1004757&r1=1004756&r2=1004757&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java Tue Oct 5 18:24:16 2010
@@ -1478,14 +1478,8 @@ public class ListView extends Component
/**
* Returns the indexes of currently checked items.
*/
- public Sequence<Integer> getCheckedIndexes() {
- ArrayList<Integer> checkedIndexes = new ArrayList<Integer>();
-
- for (int i = 0, n = this.checkedIndexes.getLength(); i < n; i++) {
- checkedIndexes.add(this.checkedIndexes.get(i));
- }
-
- return checkedIndexes;
+ public ImmutableList<Integer> getCheckedIndexes() {
+ return new ImmutableList<Integer>(checkedIndexes);
}
/**
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java?rev=1004757&r1=1004756&r2=1004757&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java Tue Oct 5 18:24:16 2010
@@ -274,16 +274,6 @@ public abstract class CalendarButtonSkin
return consumed;
}
- @Override
- public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
- boolean consumed = super.mouseClick(component, button, x, y, count);
-
- CalendarButton calendarButton = (CalendarButton)getComponent();
- calendarButton.press();
-
- return consumed;
- }
-
/**
* {@link KeyCode#SPACE SPACE} Repaints the component to reflect the pressed
* state.
@@ -320,13 +310,9 @@ public abstract class CalendarButtonSkin
public boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
boolean consumed = false;
- CalendarButton calendarButton = (CalendarButton)getComponent();
-
if (keyCode == Keyboard.KeyCode.SPACE) {
pressed = false;
repaintComponent();
-
- calendarButton.press();
} else {
consumed = super.keyReleased(component, keyCode, keyLocation);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java?rev=1004757&r1=1004756&r2=1004757&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java Tue Oct 5 18:24:16 2010
@@ -289,16 +289,6 @@ public abstract class ColorChooserButton
return consumed;
}
- @Override
- public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
- boolean consumed = super.mouseClick(component, button, x, y, count);
-
- ColorChooserButton colorChooserButton = (ColorChooserButton)getComponent();
- colorChooserButton.press();
-
- return consumed;
- }
-
// ComponentKeyListener methods
/**
@@ -337,13 +327,9 @@ public abstract class ColorChooserButton
public boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
boolean consumed = false;
- ColorChooserButton colorChooserButton = (ColorChooserButton)getComponent();
-
if (keyCode == Keyboard.KeyCode.SPACE) {
pressed = false;
repaintComponent();
-
- colorChooserButton.press();
} else {
consumed = super.keyReleased(component, keyCode, keyLocation);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java?rev=1004757&r1=1004756&r2=1004757&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java Tue Oct 5 18:24:16 2010
@@ -55,6 +55,10 @@ public abstract class ListButtonSkin ext
int index = listView.getSelectedIndex();
listButton.setSelectedIndex(index);
+ if (listButton.isRepeatable()) {
+ listButton.press();
+ }
+
return true;
}
};
@@ -79,6 +83,10 @@ public abstract class ListButtonSkin ext
int index = listView.getSelectedIndex();
listButton.setSelectedIndex(index);
+ if (listButton.isRepeatable()) {
+ listButton.press();
+ }
+
break;
}
@@ -275,7 +283,7 @@ public abstract class ListButtonSkin ext
boolean consumed = super.mouseClick(component, button, x, y, count);
ListButton listButton = (ListButton)getComponent();
- if (!listButton.isRepeatable() || !getTriggerBounds().contains(x, y)) {
+ if (listButton.isRepeatable() && !getTriggerBounds().contains(x, y)) {
listButton.press();
}
@@ -357,7 +365,9 @@ public abstract class ListButtonSkin ext
pressed = false;
repaintComponent();
- listButton.press();
+ if (listButton.isRepeatable()) {
+ listButton.press();
+ }
} else {
consumed = super.keyReleased(component, keyCode, keyLocation);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java?rev=1004757&r1=1004756&r2=1004757&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java Tue Oct 5 18:24:16 2010
@@ -179,18 +179,6 @@ public abstract class MenuButtonSkin ext
return consumed;
}
- @Override
- public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
- MenuButton menuButton = (MenuButton)getComponent();
- menuButton.press();
-
- if (menuPopup.isShowing()) {
- menuPopup.requestFocus();
- }
-
- return true;
- }
-
/**
* {@link KeyCode#SPACE SPACE} Repaints the component to reflect the pressed
* state.