[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netPanzer-CVS] netpanzer/src/NetPanzer/View Button.cpp Choice....
From: |
Hankin Chick |
Subject: |
[netPanzer-CVS] netpanzer/src/NetPanzer/View Button.cpp Choice.... |
Date: |
Mon, 24 Nov 2003 08:11:42 -0500 |
CVSROOT: /cvsroot/netpanzer
Module name: netpanzer
Branch:
Changes by: Hankin Chick <address@hidden> 03/11/24 08:11:41
Modified files:
src/NetPanzer/View: Button.cpp Choice.cpp View.cpp
Log message:
fixed repeatitive mouse move/dragged messages even when mouse didn't
move
got Button class to depress when pressed
Patches:
Index: netpanzer/src/NetPanzer/View/Button.cpp
diff -u netpanzer/src/NetPanzer/View/Button.cpp:1.2
netpanzer/src/NetPanzer/View/Button.cpp:1.3
--- netpanzer/src/NetPanzer/View/Button.cpp:1.2 Mon Nov 24 07:03:34 2003
+++ netpanzer/src/NetPanzer/View/Button.cpp Mon Nov 24 08:11:41 2003
@@ -28,14 +28,14 @@
iRect bounds;
getBounds(bounds);
- if (highlighted) {
- dest.fillRect(bounds, componentBodyColor);
- dest.drawButtonBorder(bounds, topLeftBorderColor,
bottomRightBorderColor);
- dest.bltStringCenteredInRect(bounds, label.c_str(), Color::red);
- } else if (clicked) {
+ if (clicked) {
dest.fillRect(bounds, componentBodyColor);
dest.drawButtonBorder(bounds, bottomRightBorderColor,
topLeftBorderColor);
dest.bltStringCenteredInRect(bounds, label.c_str(), Color::yellow);
+ } else if (highlighted) {
+ dest.fillRect(bounds, componentBodyColor);
+ dest.drawButtonBorder(bounds, topLeftBorderColor,
bottomRightBorderColor);
+ dest.bltStringCenteredInRect(bounds, label.c_str(), Color::red);
} else {
dest.fillRect(bounds, componentBodyColor);
dest.drawButtonBorder(bounds, topLeftBorderColor,
bottomRightBorderColor);
@@ -50,15 +50,12 @@
{
if (me.getID() == mMouseEvent::MOUSE_EVENT_ENTERED) {
highlighted = true;
- }
-
- if (me.getID() == mMouseEvent::MOUSE_EVENT_EXITED) {
+ } else if (me.getID() == mMouseEvent::MOUSE_EVENT_EXITED) {
highlighted = false;
- }
-
- if (me.getID() == mMouseEvent::MOUSE_EVENT_CLICKED) {
+ clicked = false;
+ } else if (me.getID() == mMouseEvent::MOUSE_EVENT_PRESSED) {
clicked = true;
- } else {
+ } else if (me.getID() == mMouseEvent::MOUSE_EVENT_RELEASED) {
clicked = false;
}
Index: netpanzer/src/NetPanzer/View/Choice.cpp
diff -u netpanzer/src/NetPanzer/View/Choice.cpp:1.2
netpanzer/src/NetPanzer/View/Choice.cpp:1.3
--- netpanzer/src/NetPanzer/View/Choice.cpp:1.2 Mon Nov 24 07:03:34 2003
+++ netpanzer/src/NetPanzer/View/Choice.cpp Mon Nov 24 08:11:41 2003
@@ -109,6 +109,7 @@
} else if (me.getID() == mMouseEvent::MOUSE_EVENT_DRAGGED &&
(me.getModifiers() & InputEvent::BUTTON1_MASK)) {
isOpen = true;
+ size.y = choiceList.size() * ChoiceItemHeight;
iRect r(min.x, min.y, min.x + size.x, min.y + ChoiceItemHeight);
@@ -142,8 +143,7 @@
callback->stateChanged(this);
// Since an item was selected, find which item was selected.
- } else if ( me.getID() == mMouseEvent::MOUSE_EVENT_RELEASED &&
- (me.getModifiers() & InputEvent::BUTTON1_MASK)) {
+ } else if ( me.getID() == mMouseEvent::MOUSE_EVENT_EXITED) {
//assert(!isOpen);
isOpen = false;
@@ -155,12 +155,9 @@
adjustedY = 0;
// set new element
- if(mouseover == index)
- return;
-
- index = mouseover;
- if(callback)
- callback->stateChanged(this);
+// if(mouseover == index) return;
+// index = mouseover;
+// if(callback) callback->stateChanged(this);
}
}
Index: netpanzer/src/NetPanzer/View/View.cpp
diff -u netpanzer/src/NetPanzer/View/View.cpp:1.1
netpanzer/src/NetPanzer/View/View.cpp:1.2
--- netpanzer/src/NetPanzer/View/View.cpp:1.1 Sat Nov 22 10:43:43 2003
+++ netpanzer/src/NetPanzer/View/View.cpp Mon Nov 24 08:11:41 2003
@@ -681,19 +681,21 @@
for (int i = 0; i < componentsUsedCount; i++) {
assert(componentList[i] != 0);
- if (componentList[i]->contains(prevPos) &&
!componentList[i]->contains(newPos)) {
+ bool containsPrev=componentList[i]->contains(prevPos);
+ bool containsNew=componentList[i]->contains(newPos);
+ if (containsPrev && !containsNew) {
mMouseEvent me(componentList[i], mMouseEvent::MOUSE_EVENT_EXITED,
now(), 0, newPos.x, newPos.y, 0, false);
componentList[i]->actionPerformed(me);
actionPerformed(me);
- } else if (!componentList[i]->contains(prevPos) &&
componentList[i]->contains(newPos)) {
+ } else if (!containsPrev && containsNew) {
mMouseEvent me(componentList[i], mMouseEvent::MOUSE_EVENT_ENTERED,
now(), 0, newPos.x, newPos.y, 0, false);
componentList[i]->actionPerformed(me);
actionPerformed(me);
- } else if (componentList[i]->contains(newPos)) {
+ } else if (containsNew && newPos!=prevPos) {
mMouseEvent me(componentList[i], mMouseEvent::MOUSE_EVENT_MOVED,
now(), 0, newPos.x, newPos.y, 0, false);
componentList[i]->actionPerformed(me);
@@ -784,7 +786,7 @@
{for (int i = 0; i < componentsUsedCount; i++)
{
assert(componentList[i] != 0);
- if (!componentList[i]->contains(upPos)) {
+ if (componentList[i]->contains(upPos)) {
mMouseEvent me(componentList[i],
mMouseEvent::MOUSE_EVENT_RELEASED, now(), InputEvent::BUTTON1_MASK, upPos.x,
upPos.y, 0, false);
componentList[i]->actionPerformed(me);
@@ -809,7 +811,7 @@
// Check all components for a dragged event.
for (int i = 0; i < componentsUsedCount; i++) {
assert(componentList[i] != 0);
- if (componentList[i]->contains(newPos) &&
componentList[i]->contains(downPos)) {
+ if (componentList[i]->contains(newPos) &&
componentList[i]->contains(downPos) && newPos!=prevPos) {
mMouseEvent me(componentList[i], mMouseEvent::MOUSE_EVENT_DRAGGED,
now(), InputEvent::BUTTON1_MASK, newPos.x, newPos.y, 0, false);
componentList[i]->actionPerformed(me);
@@ -908,7 +910,7 @@
// Check all components for a moved event.
for (int i = 0; i < componentsUsedCount; i++) {
assert(componentList[i] != 0);
- if (componentList[i]->contains(newPos)) {
+ if (componentList[i]->contains(newPos) &&
componentList[i]->contains(downPos) && newPos!=prevPos) {
mMouseEvent me(componentList[i], mMouseEvent::MOUSE_EVENT_DRAGGED,
now(), InputEvent::BUTTON2_MASK, newPos.x, newPos.y, 0, false);
componentList[i]->actionPerformed(me);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [netPanzer-CVS] netpanzer/src/NetPanzer/View Button.cpp Choice....,
Hankin Chick <=