本文整理汇总了C++中Finger类的典型用法代码示例。如果您正苦于以下问题:C++ Finger类的具体用法?C++ Finger怎么用?C++ Finger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Finger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawFinger
//--------------------------------------------------------------
void LeapVisualizer::drawFinger (const Finger & finger,ofxLeapMotion & leap){
if (finger.isValid()){
// For every bone (i.e. phalange) in the finger,
for (int b=0; b<4; b++) {
// Get each bone;
Bone::Type boneType = static_cast<Bone::Type>(b);
Bone bone = finger.bone(boneType);
if (bone.isValid()){
// Don't consider zero-length bones, such as the Thumb's metacarpal.
if (bone.length() > 0){
drawBone (finger, bone,leap);
} // end if boneLength
} // end if bone isValid()
} // end for each bone
if (bDrawSimple){
// Draw the fingertip, which is an extra point within the last phalange.
ofSetColor(ofColor::white);
ofPoint fingerTipPt = leap.getofPoint ( finger.tipPosition() );
ofDrawSphere(fingerTipPt, finger.width() * 0.05);
}
}
}
示例2: switch
/* PRIVATE MEMBER FUNCTIONS */
void InterfaceManager::peek(const FingerEventArgs &e)
{
unsigned int eId = e.getId();
switch(e.getType())
{
case FingerEventArgs::FINGER_ADDED:
fingers[eId] = new Finger(e.getId(), e.getPosition(), e.getPosition());
break;
case FingerEventArgs::FINGER_UPDATED:
if(fingers.count(eId) > 0)
{
Finger *f = fingers[eId];
assert(f != NULL);
f->setLast(e.getPosition());
f->setPosition(e.getPosition());
}
break;
case FingerEventArgs::FINGER_REMOVED:
if(fingers[eId] != NULL)
{
delete fingers[e.getId()];
fingers[eId] = NULL;
}
fingers.erase(e.getId());
break;
}
}
示例3: ofDrawGrid
//--------------------------------------------------------------
void ofApp::draw(){
string touchStatus;
stringstream info;
cam.begin();
ofDrawGrid(500, 5, true);
light1.enable();
light2.enable();
ofSetColor(255, 215, 0);
Frame frame = controller.frame();
for (int i=0; i < frame.hands().count(); i++) {
Hand hand = frame.hands()[i];
for (int j = 0; j < hand.fingers().count(); j ++) {
if (j == 0) {
Finger finger = frame.fingers()[j];
ofSpherePrimitive sphere;
sphere.setPosition(finger.tipPosition().x, finger.tipPosition().y, finger.tipPosition().z);
sphere.draw();
info << "Finger position x : " << finger.tipPosition().x << " y : " << finger.tipPosition().y << " z : " << finger.tipPosition().z << endl;
}
}
}
cam.end();
PointableList pointables = controller.frame().pointables();
InteractionBox iBox = controller.frame().interactionBox();
for (int p = 0; p < pointables.count(); p++) {
Pointable pointable = pointables[p];
Vector normalizedPosition = iBox.normalizePoint(pointable.stabilizedTipPosition());
float x = normalizedPosition.x * ofGetWidth();
float y = ofGetHeight() - normalizedPosition.y * ofGetHeight();
if (pointable.touchDistance() > 0 && pointable.touchZone() != Leap::Pointable::ZONE_NONE) {
ofSetColor(0, 255, 0);
touchStatus = "Hover";
} else if (pointable.touchDistance() <= 0) {
ofSetColor(255, 0, 0);
touchStatus = "Touch";
} else {
ofSetColor(0, 0, 255);
touchStatus = "None";
}
ofCircle(x, y, 30);
info << "Point Number : " << p << endl;
info << "Touch distance : " << ofToString(pointable.touchDistance()) << endl;
info << "Circle x : " << x << " y : " << y << endl;
}
ofDrawBitmapString("Touch Status : " + touchStatus, 20, 20);
ofDrawBitmapString(info.str(), 20, 40);
}
示例4: sample
void AirwritingListener::sample(const Finger &finger, unsigned long long timestamp) {
if (finger.type() == FINGER_INDEX) {
if ((sampling) && (timestamp - lastTimestamp > GESTURE_TAP_MIN_TIMESTAMP_DELTA)) {
float x = finger.tipPosition().x;
float y = finger.tipPosition().y;
float z = finger.tipPosition().z;
if ((y > FINGER_Y_MIN) && (y < FINGER_Y_MAX)) {
if ((fabs(x) < FINGER_X_MAX) && (fabs(z) < FINGER_Z_MAX)) {
Canvas::getInstance()->setPixel(x / FINGER_X_MAX, z / FINGER_Z_MAX, y / 10);
}
}
}
}
}
示例5: getGesture
bool Detect::getGesture(std::string& ret)
{
if(false == LeapController->isConnected())
{
return false;
}
HandList HL = LeapController->frame().hands();
Hand hand = HL[0];
FingerList fingers = hand.fingers();
GestureModel * gm = new GestureModel;
Leap::Matrix handTransform = hand.basis();
handTransform.origin = hand.palmPosition();
handTransform = handTransform.rigidInverse();
//get gesture data
int i = 0;
for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
const Finger finger = *fl;
// Get finger bones
for (int b = 0; b < 4; ++b) {
Bone::Type boneType = static_cast<Bone::Type>(b);
Bone bone = finger.bone(boneType);
Leap::Vector ori = bone.prevJoint();
Leap::Vector tP = handTransform.transformPoint(ori);
gm->GestureData[i][b][0][0] = tP[0];
gm->GestureData[i][b][0][1] = tP[1];
gm->GestureData[i][b][0][2] = tP[2];
tP = handTransform.transformPoint(bone.nextJoint());
gm->GestureData[i][b][1][0] = tP[0];
gm->GestureData[i][b][1][1] = tP[1];
gm->GestureData[i][b][1][2] = tP[2];
tP = handTransform.transformPoint(bone.direction());
gm->GestureData[i][b][2][0] = gm->GestureData[i][b][1][0] - gm->GestureData[i][b][0][0];
gm->GestureData[i][b][2][1] = gm->GestureData[i][b][1][1] - gm->GestureData[i][b][0][1];
gm->GestureData[i][b][2][2] = gm->GestureData[i][b][1][2] - gm->GestureData[i][b][0][2];
}
i++;
}
//compare
for (int index = 0; index < GestureList.size(); index++)
{
if (true == compareGesture(GestureList[index], gm))
{
ret = GestureList[index]->GestureName;
return true;
}
}
ret = " ";
return false;
}
示例6: assert
/* PUBLIC MEMBER FUNCTIONS */
void InterfaceManager::renderInterface()
{
assert(interfaceRoot != NULL);
interfaceRoot->render();
for(std::map<unsigned int, Finger *>::iterator it = fingers.begin(); it != fingers.end(); it++)
{
Finger *f = (*it).second;
assert(f != NULL);
f->render();
}
reportFPS();
}
示例7: recordBoneXML
//--------------------------------------------------------------
void testApp::recordBoneXML (const Finger & finger, Bone & bone){
if (bRecordingThisFrame){
Finger::Type fingerType = finger.type();
Bone::Type boneType = bone.type();
// The Leap returns data in millimeters.
ofPoint bonePt0 = leap.getofPoint ( bone.prevJoint());
ofPoint bonePt1 = leap.getofPoint ( bone.nextJoint());
float boneThickness = bone.width();
int boneTagNum = XML.addTag("B");
if( XML.pushTag("B", boneTagNum) ){
XML.setValue("TYPE", (int)boneType, boneTagNum);
if ((boneType == 0) || ((fingerType == 0) && (boneType == 1))) {
// bone points are redundant, so only use the P point.
// except for bone 0, which gets both Q and P.
int p0TagNum = XML.addTag("Q");
XML.setValue("Q:X", bonePt0.x, p0TagNum);
XML.setValue("Q:Y", bonePt0.y, p0TagNum);
XML.setValue("Q:Z", bonePt0.z, p0TagNum);
}
int p1TagNum = XML.addTag("P");
XML.setValue("P:X", bonePt1.x, p1TagNum);
XML.setValue("P:Y", bonePt1.y, p1TagNum);
XML.setValue("P:Z", bonePt1.z, p1TagNum);
XML.popTag(); // pop B(ONE)
}
}
}
示例8: ofSetColor
//--------------------------------------------------------------
void LeapVisualizer::drawBone (const Finger & finger, Bone & bone,ofxLeapMotion & leap){
Finger::Type fingerType = finger.type();
Bone::Type boneType = bone.type();
// The Leap returns data in millimeters.
ofPoint bonePt0 = leap.getofPoint ( bone.prevJoint());
ofPoint bonePt1 = leap.getofPoint ( bone.nextJoint());
float boneThickness = bone.width();
// ofPoint bonePtC = leap.getofPoint ( bone.center()); // works, but:
ofPoint bonePtC = (bonePt0 + bonePt1)/2.0;
if (bDrawSimple){
// Draw a simple white skeleton.
ofSetColor(ofColor::white);
ofLine(bonePt0, bonePt1);
ofDrawSphere(bonePt0, boneThickness * 0.15);
ofDrawSphere(bonePt1, boneThickness * 0.15);
ofDrawSphere(bonePtC, boneThickness * 0.05);
} else {
// Draw a colored cylinder with double-sphere caps.
setColorByFinger (fingerType, boneType);
drawOrientedCylinder (bonePt0, bonePt1, boneThickness/2.0);
ofDrawSphere(bonePt0, boneThickness/2.0);
ofDrawSphere(bonePt1, boneThickness/2.0);
}
}
示例9: main
int main(int argc, char** argv) {
Controller controller;
Frame frame;
HandList hands;
Hand h1;
FingerList fingers;
Finger index;
Finger thumb;
PointableList pointables;
float x = 0, y = 0, z = 0;
float pitch = 0, yaw = 0, roll = 0;
_sleep(1000);
while (1)
{
while (controller.isConnected() == true)
{
frame = controller.frame();
hands = frame.hands();
h1 = hands[0];
fingers = frame.fingers();
thumb = fingers[0];
index = fingers[1];
pointables = frame.pointables();
x = h1.palmPosition().x;
y = h1.palmPosition().y;
z = h1.palmPosition().z;
pitch = h1.direction().pitch()*RAD_TO_DEG;
yaw = h1.direction().yaw()*RAD_TO_DEG;
roll = h1.direction().roll()*RAD_TO_DEG;
//std::cout << x << " " << y << " " << z << " " << pitch << " " << yaw << " "<< roll << std::endl;
std::cout << thumb.stabilizedTipPosition() << "\t" << index.stabilizedTipPosition() << std::endl;
_sleep(1000);
}
while (controller.isConnected() == false)
{
printf("No Connection ");
}
}
return 0;
}
示例10: recordFingerXML
//--------------------------------------------------------------
void testApp::recordFingerXML (const Finger & finger){
if (bRecordingThisFrame){
if (finger.isValid()){
Finger::Type fingerType = finger.type();
int fingerTagNum = XML.addTag("F");
if( XML.pushTag("F", fingerTagNum) ){
XML.setValue("TYPE", (int)fingerType, fingerTagNum);
XML.setValue("WIDTH", finger.width(), fingerTagNum);
// Add in the fingerTip point as its own point.
ofPoint fingerTipPt = leap.getofPoint ( finger.tipPosition() );
int tipTagNum = XML.addTag("T");
XML.setValue("T:X", fingerTipPt.x, tipTagNum);
XML.setValue("T:Y", fingerTipPt.y, tipTagNum);
XML.setValue("T:Z", fingerTipPt.z, tipTagNum);
// For every bone (i.e. phalange) in the finger,
for (int b=0; b<4; b++) {
// Get each bone;
Bone::Type boneType = static_cast<Bone::Type>(b);
Bone bone = finger.bone(boneType);
if (bone.isValid()){
// Don't consider zero-length bones, such as the Thumb's metacarpal.
if (bone.length() > 0){
recordBoneXML (finger, bone);
} // end if boneLength
} // end if bone isValid()
} // end for each bone
XML.popTag(); // pop F(INGER)
}
} //end if finger isValid()
}
}
示例11: updateCursorLocation
void LeapBrowser::updateCursorLocation()
{
bool is_index_found = false;
Frame frame = leap_controller.frame();
HandList hands = frame.hands();
for( int h=0; h < hands.count(); h++ )
{
Hand hand = hands[h];
FingerList fingers = hand.fingers();
for( int f=0; f < fingers.count(); f++ )
{
Finger finger = fingers[f];
if( finger.type() == Finger::Type::TYPE_INDEX )
{
is_index_found = true;
Vector position = finger.tipPosition();
cursor_location = math::position(position.x, position.y, position.z) * leap_transform;
break;
}
}
if( is_index_found )
{
break;
}
}
if( !is_index_found )
{
cursor_location = math::position(0,0,0);
is_cursor_located = false;
}
else
{
is_cursor_located = true;
}
}
示例12: onFrame
void LeapListener::onFrame(const Controller & controller) {
// Get the most recent frame and report some basic information
const Frame frame = controller.frame();
std::cout << "Frame id: " << frame.id()
<< ", timestamp: " << frame.timestamp()
<< ", hands: " << frame.hands().count()
<< ", extended fingers: " << frame.fingers().extended().count()
<< ", tools: " << frame.tools().count()
<< ", gestures: " << frame.gestures().count() << std::endl;
HandList hands = frame.hands();
for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
// Get the first hand
const Hand hand = *hl;
std::string handType = hand.isLeft() ? "Left hand" : "Right hand";
std::cout << std::string(2, ' ') << handType << ", id: " << hand.id()
<< ", palm position: " << hand.palmPosition() << std::endl;
// Get the hand's normal vector and direction
const Vector normal = hand.palmNormal();
const Vector direction = hand.direction();
// Calculate the hand's pitch, roll, and yaw angles
std::cout << std::string(2, ' ') << "pitch: " << direction.pitch() * RAD_TO_DEG << " degrees, "
<< "roll: " << normal.roll() * RAD_TO_DEG << " degrees, "
<< "yaw: " << direction.yaw() * RAD_TO_DEG << " degrees" << std::endl;
// Get the Arm bone
Arm arm = hand.arm();
std::cout << std::string(2, ' ') << "Arm direction: " << arm.direction()
<< " wrist position: " << arm.wristPosition()
<< " elbow position: " << arm.elbowPosition() << std::endl;
// Get fingers
const FingerList fingers = hand.fingers();
for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
const Finger finger = *fl;
std::cout << std::string(4, ' ') << fingerNames[finger.type()]
<< " finger, id: " << finger.id()
<< ", length: " << finger.length()
<< "mm, width: " << finger.width() << std::endl;
// Get finger bones
for (int b = 0; b < 4; ++b) {
Bone::Type boneType = static_cast<Bone::Type>(b);
Bone bone = finger.bone(boneType);
std::cout << std::string(6, ' ') << boneNames[boneType]
<< " bone, start: " << bone.prevJoint()
<< ", end: " << bone.nextJoint()
<< ", direction: " << bone.direction() << std::endl;
}
}
}
// Get tools
const ToolList tools = frame.tools();
for (ToolList::const_iterator tl = tools.begin(); tl != tools.end(); ++tl) {
const Tool tool = *tl;
std::cout << std::string(2, ' ') << "Tool, id: " << tool.id()
<< ", position: " << tool.tipPosition()
<< ", direction: " << tool.direction() << std::endl;
}
// Get gestures
const GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g) {
Gesture gesture = gestures[g];
switch (gesture.type()) {
case Gesture::TYPE_CIRCLE: {
CircleGesture circle = gesture;
std::string clockwiseness;
if (circle.pointable().direction().angleTo(circle.normal()) <= PI/2) {
clockwiseness = "clockwise";
} else {
clockwiseness = "counterclockwise";
}
// Calculate angle swept since last frame
float sweptAngle = 0;
if (circle.state() != Gesture::STATE_START) {
CircleGesture previousUpdate = CircleGesture(controller.frame(1).gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * PI;
}
std::cout << std::string(2, ' ')
<< "Circle id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", progress: " << circle.progress()
<< ", radius: " << circle.radius()
<< ", angle " << sweptAngle * RAD_TO_DEG
<< ", " << clockwiseness << std::endl;
break;
}
case Gesture::TYPE_SWIPE: {
SwipeGesture swipe = gesture;
std::cout << std::string(2, ' ')
<< "Swipe id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", direction: " << swipe.direction()
<< ", speed: " << swipe.speed() << std::endl;
//.........这里部分代码省略.........
示例13: Vector
//metodo en bucle que actualiza la informacion de frecuencia, volumen y handsGl
void leapMotion::onFrame(const Controller& controller) {
const Frame frame = controller.frame();
int j = 0;
float mejor = 1000;
float mejorVol = 1000;
int nada=-1000;
Vector vNada = Vector(nada,nada,nada);
Matrix mNada = Matrix(vNada,vNada,vNada);
HandList hands = frame.hands();
numManos = hands.count();
for(int i=0; i<numManos; i++){
palma[i] = hands[i].palmPosition();
//anchuraPalmas[i] = hands[i].palmWidth();
direccionMano[i] = hands[i].basis();
float distVol=palma[i].y;
if((palma[i].x/50)<-4 && (palma[i].x/50)>-7 && distVol<=mejorVol) mejorVol=distVol;
//if(distVol<=mejorVol) mejorVol=distVol;
for (int f = 0; f < hands[i].fingers().count(); f++) {
Finger finger = hands[i].fingers()[f];
for (int b = 0; b < 4; b++) {
Bone bone = finger.bone(static_cast<Leap::Bone::Type>(b));
handsGl[i*20+f*4+b]=bone.nextJoint();
float dist=sqrt(pow(4.125-(handsGl[i*20+f*4+b].x/50),2)+pow((-0.75)-(handsGl[i*20+f*4+b].z/50),2));
if(dist<=mejor) mejor=dist;
centroHuesos[i*20+f*4+b]=bone.nextJoint();
direccionHuesos[i*20+f*4+b]=bone.basis();
longitudHuesos[i*20+f*4+b]=bone.length();
anchuraHuesos[i*20+f*4+b]=bone.width()/2;
}
}
}
for(int i=numManos*20;i<40;i++) handsGl[i] = vNada;
for(int i=numManos; i<2; i++) palma[i] = vNada;
//for(int i=numManos; i<2; i++) anchuraPalmas[i] = 0;
for(int i=numManos; i<2; i++) direccionMano[i] = mNada;
for(int i=numManos*20; i<40; i++) direccionHuesos[i] = mNada;
for(int i=numManos*20; i<40; i++) centroHuesos[i] = vNada;
for(int i=numManos*20; i<40; i++) longitudHuesos[i] = 0;
for(int i=numManos*20; i<40; i++) anchuraHuesos[i] = 0;
if(mejor<=0.1) freq=7902.13; //se supone que al tocar la antena del theremin, se produce una frecuencia de sonido muy alta
else if(mejor<=5){
freq=4000*(1-mejor/5);
}
else freq=0;
if(mejorVol>=250 && mejorVol<=350) volumen=1*((mejorVol-250)/100);
else if(mejorVol<250) volumen=0;
else volumen=1;
}
示例14: if
void MangoListener::onFrame(const Controller& controller) {
const Frame frame = controller.frame();
HandList hands = frame.hands();
int extendedFingers = 0;
for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
const Hand hand = *hl;
for (int i = 0; i < hand.fingers().count(); i++)
{
Finger finger = hand.fingers()[i];
if(finger.isExtended()) extendedFingers++;
}
if (!onGesture && !frame.hands().isEmpty() && frame.hands().count() == 1 && extendedFingers == 0)
{
preGestureCounter++;
std::cout << preGestureCounter << std::endl;
if (preGestureCounter > MAX_PREGESTURE && frameCount == 0)
{
onGesture = true;
preGestureCounter = 0;
frameCount++;
note.show();
}
}
else if (preGestureCounter > 0)
{
preGestureCounter--;
}
}
if (onGesture && frameCount < MAX_FRAMECOUNT) {
switch (extendedFingers)
{
case 1:
{
std::string command = commands.getCommand("FING3");
std::cout << command << std::endl;
break;
}
case 2:
{
break;
}
case 3:
{
break;
}
default:
{
break;
}
}
frameCount++;
const GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g) {
Gesture gesture = gestures[g]; //need to move finger detection in here too
switch (gesture.type()) {
case Gesture::TYPE_CIRCLE:
{
CircleGesture circle = gesture;
std::string clockwiseness; //probably simplfy to a bool
if (circle.pointable().direction().angleTo(circle.normal()) <= PI/4)
{
clockwiseness = "clockwise";
std::cout << "CIRCLE CLOCKWISE" << std::endl;
}
else
{
clockwiseness = "counterclockwise";
std::cout << "CIRCLE COUNTERCLOCKWISE" << std::endl;
}
break;
}
case Gesture::TYPE_SWIPE:
{
SwipeGesture swipe = gesture;
std::cout << "SWIPE" << std::endl;
break;
}
case Gesture::TYPE_KEY_TAP:
{
KeyTapGesture tap = gesture;
std::cout << "KEY TAP" << std::endl;
break;
}
case Gesture::TYPE_SCREEN_TAP:
{
ScreenTapGesture screentap = gesture;
std::cout << "SCREEN TAP" << std::endl;
break;
}
default:
{
std::cout << std::string(2, ' ') << "Unknown gesture type." << std::endl;
break;
}
}
float seconds = gesture.durationSeconds();
//.........这里部分代码省略.........
示例15: ParangusGestureLogic
void QTVS_Leap::FingerLogic(handIndex hIndex)
{
if (ui.checkBox_gesturesParangus->isChecked())
ParangusGestureLogic();
if (ui.checkBox_gesturesLeap->isChecked())
LeapGestureLogic();
//DEBUG: Atm we cancel
// return;
// 0 -> 4 = left hand
// 5 -> 9 = right hand
// So lets use a shift and no redundant code
int iHandToFingerShift = 0;
if (hIndex == handRight)
iHandToFingerShift += 5;
for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
const Finger finger = *fl;
// std::cout << std::string(4, ' ') << fingerNames[finger.type()]
// << " finger, id: " << finger.id()
// << ", length: " << finger.length()
// << "mm, width: " << finger.width() << std::endl;
Leap::Vector position = finger.stabilizedTipPosition();
// Convert Leap::Vector position to Screen Coords
QPoint screenPosition = FingerCursorPosition(position);
// Lerp coords for smoothness if required
int xCoord = lerp(fingerTraces.at(finger.type() + iHandToFingerShift)->geometry().left(), screenPosition.x(), dMouseLerpValue);
int yCoord = lerp(fingerTraces.at(finger.type() + iHandToFingerShift)->geometry().top(), screenPosition.y(), dMouseLerpValue);
// Qt Doesn't allow different threads to overwride gui locations.
// Therefore, the usage of events are well, used.
// This updates visual finger representation to correct location
QMoveEvent *tEvent = new QMoveEvent(QPoint(xCoord, yCoord), fingerTraces.at(finger.type() + iHandToFingerShift)->pos());
QCoreApplication::postEvent(fingerTraces.at(finger.type() + iHandToFingerShift), tEvent);
// Z axis does NOT use stabilized position.
// Stabilized position is generally used for X/Y movement (2D display)
// Therefore Z is updated quite poorely. So we used unStabalized position instead
// Setup position limits (manual testing for values
position = finger.tipPosition();
float zFinger = position.z < 0 ? 0 : position.z > 200 ? 200 : position.z;
// Convert to percentages
// trim lowerend of percentages
zFinger /= 200;
if (zFinger < 0.1) zFinger = 0.1;
if (hIndex == handLeft)
{
if(ui.checkBox_FingerDragsWindows->isChecked())
{
// We're on index finger and its close to screen / center of Z-plane on leap motion
if (finger.type() == leapIndex && zFinger < 0.12)
{
POINT pt;
pt.x = screenPosition.x();
pt.y = screenPosition.y();
// if our rect was reset
// Therefore, we just started to drag
if (debugWindowDrag_Left.left == -1)
{
// Find window under point
// Find window's dimmensions
// Find difference between player's finger coords and window's coords
debugWindowHWND_Left = GetRealParent(WindowFromPoint(pt));
// Set it as active window if need be.
if(debugWindowHWND_Left != GetForegroundWindow() && ui.checkBox_DragSetsActive->isChecked())
{
SetForegroundWindow(debugWindowHWND_Left);
// Backup incase SetForegroundWindow fails
// TODO: Perhaps replace in future? since foreground window DOES faile occasionally.
// SetWindowPos(debugWindowHWND_Left,HWND_TOPMOST,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
}
// Restore window if maximized Section
WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
GetWindowPlacement(debugWindowHWND_Left, &wndpl);
// Determine if window is maximized to begin with
if (wndpl.showCmd == SW_MAXIMIZE)
{
// Setup the restore command and send it
wndpl.showCmd = SW_RESTORE;
SetWindowPlacement(debugWindowHWND_Left, &wndpl);
// Center restored window around player's fingers
int iTempWindowWidth = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left;
int iTempWindowHeight = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top;
MoveWindow(debugWindowHWND_Left, pt.x - iTempWindowWidth / 2, pt.y - iTempWindowHeight / 2,
iTempWindowWidth, iTempWindowHeight, true);
}
//.........这里部分代码省略.........