Procházet zdrojové kódy

Changed cmGr,cmGrPlot,cmGrPlotAudio to better handle events.

Rewrote cmGr.c::cmGrEvent()
Callback cmGrIsInsideObj() now must evaluate both if the mouse point is
inside the object and also if the object can handle the event. This
allows the actual plot object which can handle an event to be identified
by cmGrEvent().

_cmGrPlotObjEvent() still needs to be updated to account for these changes.
master
kevin před 12 roky
rodič
revize
9d6ac977aa
5 změnil soubory, kde provedl 295 přidání a 46 odebrání
  1. 248
    37
      cmGr.c
  2. 6
    3
      cmGr.h
  3. 39
    5
      cmGrPlot.c
  4. 1
    0
      cmGrPlot.h
  5. 1
    1
      cmGrPlotAudio.c

+ 248
- 37
cmGr.c Zobrazit soubor

@@ -684,7 +684,7 @@ void _cmGrObjCbVExt( cmGr_t* p, const cmGrObj_t* op, cmGrVExt_t* vext )
684 684
   }  
685 685
 }
686 686
 
687
-bool _cmGrObjCbIsInside( cmGr_t* p, const cmGrObj_t* op, int px, int py, cmGrV_t vx, cmGrV_t vy )
687
+bool _cmGrObjCbIsInside( cmGr_t* p, const cmGrObj_t* op, unsigned evtFlags, int px, int py, cmGrV_t vx, cmGrV_t vy )
688 688
 {
689 689
   bool fl = false;
690 690
   if( op->f.isInsideCbFunc != NULL )
@@ -692,7 +692,7 @@ bool _cmGrObjCbIsInside( cmGr_t* p, const cmGrObj_t* op, int px, int py, cmGrV_t
692 692
     cmGrObjFuncArgs_t a;
693 693
     _cmGrObjSetupFuncArgs(&a,p,(cmGrObj_t*)op);
694 694
     a.cbArg = op->f.isInsideCbArg;
695
-    fl = op->f.isInsideCbFunc(&a,px,py,vx,vy);
695
+    fl = op->f.isInsideCbFunc(&a,evtFlags,px,py,vx,vy);
696 696
   }  
697 697
   return fl;
698 698
 }
@@ -1751,7 +1751,7 @@ void     _cmGrObjRootVExt( cmGrObjFuncArgs_t* args, cmGrVExt_t* vext )
1751 1751
   cmGrObjWorldExt( args->objH, vext );
1752 1752
 }
1753 1753
 
1754
-bool _cmGrObjRootIsInside( cmGrObjFuncArgs_t* args, int px, int py, cmGrV_t vx, cmGrV_t vy )
1754
+bool _cmGrObjRootIsInside( cmGrObjFuncArgs_t* args, unsigned evtFlags, int px, int py, cmGrV_t vx, cmGrV_t vy )
1755 1755
 {
1756 1756
   cmGrVExt_t vext;
1757 1757
   _cmGrObjRootVExt(args,&vext);
@@ -2154,8 +2154,38 @@ void  _cmGrSetSelectPoints(cmGr_t* p, const cmGrVPt_t* pt0, const cmGrVPt_t* pt1
2154 2154
   
2155 2155
 }
2156 2156
 
2157
+void      _cmGrScrollExtents( cmGr_t* p, cmGrPSz_t* tot, cmGrPSz_t* vis, cmGrPSz_t* max, cmGrPPt_t* pos )
2158
+{
2159
+
2160
+  assert( p->rootObj != NULL );
2161
+
2162
+  if( tot != NULL )
2163
+  {
2164
+    tot->w = round(p->rootObj->wext.sz.w * p->pext.sz.w / p->vext.sz.w);
2165
+    tot->h = round(p->rootObj->wext.sz.h * p->pext.sz.h / p->vext.sz.h);
2166
+  }
2167
+
2168
+  if( vis != NULL )
2169
+  {
2170
+    vis->w = round(p->vext.sz.w * p->pext.sz.w / p->vext.sz.w);
2171
+    vis->h = round(p->vext.sz.h * p->pext.sz.h / p->vext.sz.h);
2172
+  }
2173
+
2174
+  if( max != NULL )
2175
+  {
2176
+    max->w = tot->w - vis->w;
2177
+    max->h = tot->h - vis->h;
2178
+  }
2179
+
2180
+  if( pos != NULL )
2181
+  {
2182
+    pos->x = _cmGrScrollH(p);
2183
+    pos->y = _cmGrScrollV(p);
2184
+  }
2185
+}
2186
+
2157 2187
 // vx,vy are in the same coord's as op->vext
2158
-cmGrObj_t* _cmGrFindObjRec( cmGr_t* p, cmGrObj_t* op, int px, int py, cmGrV_t vx, cmGrV_t vy )
2188
+cmGrObj_t* _cmGrFindObjRec( cmGr_t* p, cmGrObj_t* op, unsigned evtFlags, int px, int py, cmGrV_t vx, cmGrV_t vy )
2159 2189
 {
2160 2190
   cmGrObj_t* rop = NULL;
2161 2191
   cmGrObj_t* top;
@@ -2165,27 +2195,234 @@ cmGrObj_t* _cmGrFindObjRec( cmGr_t* p, cmGrObj_t* op, int px, int py, cmGrV_t vx
2165 2195
   _cmGrObjCbVExt(p,op,&vext);
2166 2196
 
2167 2197
   // is vx,vy inside op - this is equiv to: cmGrVExtIsXyInside(&vext,vx,vy)
2168
-  if( _cmGrObjCbIsInside(p,op,px,py,vx,vy) )
2198
+  if( _cmGrObjCbIsInside(p,op,evtFlags,px,py,vx,vy) )
2169 2199
     rop = op;
2170 2200
 
2171 2201
   if( op->children != NULL )
2172 2202
   {
2173 2203
     cmGrVPt_t pt;
2174 2204
     if( _cmGrParentToLocal(p,op,vx,vy,&pt) )
2175
-      if((top = _cmGrFindObjRec(p,op->children,px,py,vx,vy)) != NULL )
2205
+      if((top = _cmGrFindObjRec(p,op->children,evtFlags,px,py,vx,vy)) != NULL )
2176 2206
         rop = top;
2177 2207
   }
2178 2208
 
2179 2209
   if( op->rsib != NULL )
2180
-    if((top = _cmGrFindObjRec(p,op->rsib,px,py,vx,vy)) != NULL )
2210
+    if((top = _cmGrFindObjRec(p,op->rsib,evtFlags,px,py,vx,vy)) != NULL )
2181 2211
       rop = top;
2182 2212
 
2183 2213
 
2184 2214
   return rop;
2185 2215
 }
2186 2216
 
2217
+cmGrObj_t*  _cmGrEventMsDown( cmGr_t* p, unsigned evtFlags, cmGrKeyCodeId_t key, int px, int py, cmGrV_t gx, cmGrV_t gy )
2218
+{
2219
+  // store the phys loc. of the ms dn event
2220
+  cmGrPPtSet(&p->msDnPPt,px,py);   
2187 2221
 
2188
-bool     cmGrEvent( cmGrH_t h, unsigned flags, cmGrKeyCodeId_t key, int px, int py )
2222
+  // get a pointer to an object 
2223
+  cmGrObj_t* op =  _cmGrFindObjRec(p, p->rootObj, evtFlags, px, py, gx, gy );
2224
+
2225
+  // if the mouse did not go down in an object that accepts mouse down events
2226
+  // or the object was a root object
2227
+  if( op == NULL || op->parent == NULL )
2228
+    return NULL;
2229
+
2230
+  // store the object and coord's where the mouse went down.
2231
+  cmGrVExt_t vext;
2232
+  p->msDnObj = op; // set the msDnObj
2233
+
2234
+  // convert the phys ms dn point to the virt point inside op->parent.wext
2235
+  _cmGrXY_PtoV(p, op->parent, px, py, &p->msDnVPt );
2236
+
2237
+  p->msVPt    = p->msDnVPt;    // set the current ms virt pt
2238
+  p->localPt  = p->msDnVPt;    // set the current local pt
2239
+
2240
+  // notifiy the app of the local coord's
2241
+  _cmGrCallback(p,kLocalPtCbGrId,0,kInvalidKeyCodeGrId);
2242
+
2243
+  // get the ms down obj virt extents
2244
+  _cmGrObjCbVExt(p,op,&vext);
2245
+
2246
+  // store the offset from the lower left to the ms dn point
2247
+  p->msDnVOffs.w = p->msDnVPt.x - vext.loc.x; 
2248
+  p->msDnVOffs.h = p->msDnVPt.y - vext.loc.y;
2249
+
2250
+  // notify the object that the mouse went down
2251
+  if(_cmGrObjCbEvent(p,op,evtFlags,key,px,py))
2252
+    return op;
2253
+  return NULL;
2254
+}
2255
+
2256
+cmGrObj_t* _cmGrEventMsUp( cmGr_t* p, unsigned evtFlags, cmGrKeyCodeId_t key, int px, int py, cmGrV_t gx, cmGrV_t gy )
2257
+{
2258
+  bool       fl = false;
2259
+  cmGrObj_t* op = NULL;
2260
+
2261
+  cmGrPPt_t upPPt;
2262
+  cmGrPPtSet(&upPPt,px,py);
2263
+  
2264
+  // if a click occured ...
2265
+  if( cmGrPPtIsEqual(&p->msDnPPt,&upPPt )  )
2266
+  {
2267
+    // ... and the click is in a non-root object which accepts click events ...
2268
+    if( p->msDnObj!= NULL && p->msDnObj->parent!=NULL && _cmGrObjCbIsInside(p,p->msDnObj,evtFlags | kMsClickGrFl, px, py, gx, gy) )
2269
+    {
2270
+      // ... then generate a click event
2271
+      unsigned newEvtFlags = cmClrFlag(evtFlags,kMsUpGrFl) | kMsClickGrFl;
2272
+      fl = _cmGrObjCbEvent(p,p->msDnObj,newEvtFlags,key,px,py);
2273
+      op = p->msDnObj;
2274
+    }
2275
+    else // ... else if the click occurred in the root object
2276
+      //if( p->msDnObj==NULL || p->msDnObj->parent==NULL)
2277
+      {
2278
+        cmGrVPt_t pt;
2279
+        cmGrVPtSet(&pt,gx,gy);
2280
+
2281
+        bool shFl = cmIsFlag(evtFlags,kShiftKeyGrFl);
2282
+        _cmGrSetSelectPoints( p, shFl ? NULL : &pt, shFl ? &pt : NULL );
2283
+
2284
+      }
2285
+  }
2286
+
2287
+  // if op is NULL then there was no-mouse down object to match with 
2288
+  // this mouse-up event - find an object to match with the mouse-up event
2289
+  if( op == NULL )
2290
+    op = _cmGrFindObjRec(p, p->rootObj, evtFlags, px, py, gx, gy );
2291
+
2292
+  // if a mouse-up object was found then
2293
+  if( op != NULL && op->parent != NULL)
2294
+  {
2295
+    
2296
+    // notify the object under the mouse that the mouse went up
2297
+    if( _cmGrObjCbEvent(p,op,evtFlags,key,px,py) )
2298
+      fl = true;
2299
+
2300
+    // convert the phys ms dn point to the virt point inside op->parent.wext
2301
+    _cmGrXY_PtoV(p, op->parent, px, py, &p->msVPt );
2302
+
2303
+  }
2304
+
2305
+  _cmGrCallback(p,kFocusCbGrId,0,kInvalidKeyCodeGrId);
2306
+
2307
+  p->msDnObj = NULL;
2308
+
2309
+  return fl ? op : NULL;
2310
+}
2311
+
2312
+cmGrObj_t*  _cmGrEventMsMove( cmGr_t* p, unsigned evtFlags, cmGrKeyCodeId_t key, int px, int py, cmGrV_t gx, cmGrV_t gy )
2313
+{
2314
+  bool       fl = false;
2315
+  cmGrObj_t* op = _cmGrFindObjRec(p, p->rootObj, evtFlags, px, py, gx, gy );
2316
+
2317
+  if( op != NULL && op->parent != NULL )
2318
+  {
2319
+    
2320
+    fl = _cmGrObjCbEvent(p,op,evtFlags,key,px,py);
2321
+  }
2322
+
2323
+  return fl ? op : NULL;
2324
+}
2325
+
2326
+cmGrObj_t*  _cmGrEventMsDrag( cmGr_t* p, unsigned evtFlags, cmGrKeyCodeId_t key, int px, int py, cmGrV_t gx, cmGrV_t gy )
2327
+{
2328
+  bool       fl = false;
2329
+  cmGrObj_t* op = _cmGrFindObjRec(p, p->rootObj, evtFlags, px, py, gx, gy );
2330
+
2331
+  if( op != NULL && op->parent != NULL )
2332
+  {
2333
+    // set the current virtual point
2334
+    _cmGrXY_PtoV(p, p->msDnObj->parent, px, py, &p->msVPt );
2335
+
2336
+    // callback the dragged object
2337
+    fl = _cmGrObjCbEvent(p,p->msDnObj,evtFlags,key,px,py);
2338
+
2339
+    // if the px,py is outside the root phys extents then scroll
2340
+    if( !cmGrPExtIsXyInside(&p->pext,px,py) )
2341
+    {
2342
+      bool      hFl = false, vFl=false;
2343
+      cmGrPSz_t tot,vis,max;
2344
+      cmGrPPt_t pos;
2345
+      _cmGrScrollExtents(p, &tot, &vis, &max, &pos );
2346
+
2347
+      if( px < cmGrPExtL(&p->pext) )
2348
+        hFl = _cmGrSetScrollH(p,   cmMax(0,     _cmGrScrollH(p) - (cmGrPExtL(&p->pext) - px)));
2349
+      else
2350
+        if( px > cmGrPExtR(&p->pext) )
2351
+          hFl = _cmGrSetScrollH(p, cmMin(max.w, _cmGrScrollH(p) + (px - cmGrPExtR(&p->pext))));            
2352
+
2353
+      if( py < cmGrPExtT(&p->pext) )
2354
+        vFl = _cmGrSetScrollV(p,   cmMax(0,     _cmGrScrollV(p) - (cmGrPExtT(&p->pext) - py)));
2355
+      else
2356
+        if( py > cmGrPExtB(&p->pext) )
2357
+          vFl = _cmGrSetScrollV(p, cmMin(max.h, _cmGrScrollV(p) + (py - cmGrPExtB(&p->pext))));            
2358
+              
2359
+
2360
+      fl = fl || vFl || hFl;
2361
+    }
2362
+  }
2363
+  return fl ? op : NULL;
2364
+}
2365
+
2366
+bool     cmGrEvent( cmGrH_t h, unsigned evtFlags, cmGrKeyCodeId_t key, int px, int py )
2367
+{
2368
+  bool              fl = false;
2369
+  cmGrObj_t*        op = NULL;
2370
+  cmGr_t*           p = _cmGrHandleToPtr(h);
2371
+  cmGrVPtSet(&p->localPt,0,0);
2372
+
2373
+  // convert the phys points to points in the root coord system
2374
+  cmGrV_t gx = _cmGr_X_PtoV(p,px);
2375
+  cmGrV_t gy = _cmGr_Y_PtoV(p,py);
2376
+
2377
+  // set the global point
2378
+  cmGrVPtSet(&p->globalPt,gx,gy);
2379
+
2380
+  // inform the app of the possibly new global point
2381
+  _cmGrCallback(p,kGlobalPtCbGrId,0,kInvalidKeyCodeGrId);
2382
+  
2383
+  switch( evtFlags & kEvtMask)
2384
+  {
2385
+    case kKeyUpGrFl:
2386
+      _cmGrCallback(p,kKeyUpCbGrId,evtFlags,key);
2387
+      break;
2388
+
2389
+    case kKeyDnGrFl:
2390
+      _cmGrCallback(p,kKeyDnCbGrId,evtFlags,key);
2391
+      break;
2392
+
2393
+    case kMsDownGrFl:      
2394
+      op = _cmGrEventMsDown(p,evtFlags,key,px,py,gx,gy);
2395
+      break;
2396
+
2397
+    case kMsUpGrFl: // handle mouse-up, mouse-click, and focus events
2398
+      op = _cmGrEventMsUp(p,evtFlags,key,px,py,gx,gy);
2399
+      break;
2400
+
2401
+    case kMsMoveGrFl:
2402
+      op = _cmGrEventMsMove(p,evtFlags,key,px,py,gx,gy);
2403
+      break;
2404
+
2405
+    case kMsDragGrFl:
2406
+      op = _cmGrEventMsDrag(p,evtFlags,key,px,py,gx,gy);
2407
+      break;
2408
+
2409
+  }
2410
+
2411
+  if( op != NULL )
2412
+  {
2413
+    // convert gx,gy to be inside op->wext
2414
+    cmGrVPtSet(&p->localPt,gx,gy);
2415
+    _cmGrXY_GlobalToLocal(p,op,&p->localPt);
2416
+
2417
+    _cmGrCallback(p,kLocalPtCbGrId,0,kInvalidKeyCodeGrId);
2418
+
2419
+    fl = true;
2420
+  }
2421
+
2422
+  return fl;
2423
+}
2424
+
2425
+bool     cmGrEvent1( cmGrH_t h, unsigned flags, cmGrKeyCodeId_t key, int px, int py )
2189 2426
 {
2190 2427
   bool              fl = false;
2191 2428
   cmGr_t*           p = _cmGrHandleToPtr(h);
@@ -2201,7 +2438,7 @@ bool     cmGrEvent( cmGrH_t h, unsigned flags, cmGrKeyCodeId_t key, int px, int
2201 2438
   _cmGrCallback(p,kGlobalPtCbGrId,0,kInvalidKeyCodeGrId);
2202 2439
 
2203 2440
   // find the obj under the mouse
2204
-  if((op = _cmGrFindObjRec(p,p->rootObj,px,py,gx,gy)) != NULL )
2441
+  if((op = _cmGrFindObjRec(p,p->rootObj,flags&kEvtMask,px,py,gx,gy)) != NULL )
2205 2442
   {          
2206 2443
     // convert gx,gy to be inside op->wext
2207 2444
     cmGrVPtSet(&p->localPt,gx,gy);
@@ -2414,39 +2651,13 @@ void     cmGrPhysExtents( cmGrH_t h, cmGrPExt_t* exts )
2414 2651
   cmGr_t* p = _cmGrHandleToPtr(h);
2415 2652
   *exts = p->pext;
2416 2653
 }
2417
-
2418
-
2419 2654
 void      cmGrScrollExtents( cmGrH_t h, cmGrPSz_t* tot, cmGrPSz_t* vis, cmGrPSz_t* max, cmGrPPt_t* pos )
2420 2655
 {
2421 2656
   cmGr_t* p = _cmGrHandleToPtr(h);
2422
-
2423
-  assert( p->rootObj != NULL );
2424
-
2425
-  if( tot != NULL )
2426
-  {
2427
-    tot->w = round(p->rootObj->wext.sz.w * p->pext.sz.w / p->vext.sz.w);
2428
-    tot->h = round(p->rootObj->wext.sz.h * p->pext.sz.h / p->vext.sz.h);
2429
-  }
2430
-
2431
-  if( vis != NULL )
2432
-  {
2433
-    vis->w = round(p->vext.sz.w * p->pext.sz.w / p->vext.sz.w);
2434
-    vis->h = round(p->vext.sz.h * p->pext.sz.h / p->vext.sz.h);
2435
-  }
2436
-
2437
-  if( max != NULL )
2438
-  {
2439
-    max->w = tot->w - vis->w;
2440
-    max->h = tot->h - vis->h;
2441
-  }
2442
-
2443
-  if( pos != NULL )
2444
-  {
2445
-    pos->x = _cmGrScrollH(p);
2446
-    pos->y = _cmGrScrollV(p);
2447
-  }
2657
+  _cmGrScrollExtents(p,tot,vis,max,pos);
2448 2658
 }
2449 2659
 
2660
+
2450 2661
 bool      cmGrSetScrollH( cmGrH_t h, int x )
2451 2662
 { return _cmGrSetScrollH( _cmGrHandleToPtr(h), x ); }
2452 2663
 

+ 6
- 3
cmGr.h Zobrazit soubor

@@ -595,7 +595,7 @@ extern "C" {
595 595
   typedef int      (*cmGrDistanceObjCb_t)( cmGrObjFuncArgs_t* args, int x, int y );
596 596
   typedef bool     (*cmGrEventObjCb_t)(    cmGrObjFuncArgs_t* args, unsigned flags, unsigned key, int px, int py  );  
597 597
   typedef void     (*cmGrVExtObjCb_t)(     cmGrObjFuncArgs_t* args, cmGrVExt_t* vext );
598
-  typedef bool     (*cmGrIsInsideObjCb_t)( cmGrObjFuncArgs_t* args, int px, int py, cmGrV_t vx, cmGrV_t vy );
598
+  typedef bool     (*cmGrIsInsideObjCb_t)( cmGrObjFuncArgs_t* args, unsigned evtFlags, int px, int py, cmGrV_t vx, cmGrV_t vy );
599 599
 
600 600
   typedef struct cmGrObjFunc_str
601 601
   {
@@ -625,9 +625,12 @@ extern "C" {
625 625
     cmGrVExtObjCb_t     vextCbFunc;
626 626
     void*               vextCbArg;
627 627
 
628
-    // Return true if the point is inside this obj.  vx,vy is in the the same coord's as op->vext (i.e. vx,vy is inside op->parent->wext)
628
+    // Called to determine which object is under the mouse and whether the event can
629
+    // handle the event as described by the 'evtFlags' args.
630
+    // Return true if the point is inside this obj.  vx,vy is in the the same coord's 
631
+    // as op->vext (i.e. vx,vy is inside op->parent->wext) and the object will accept
632
+    // the event implied by the 'evtFlags' argument.  
629 633
     // The simple answer to this call is cmGrVExtIsXyInside( *vext, vx, vy ).
630
-    // Called to determine which object is under the mouse.
631 634
     cmGrIsInsideObjCb_t isInsideCbFunc;
632 635
     void*               isInsideCbArg;
633 636
   } cmGrObjFunc_t;

+ 39
- 5
cmGrPlot.c Zobrazit soubor

@@ -678,13 +678,43 @@ bool _cmGrPlotObjEvent( cmGrObjFuncArgs_t* args, unsigned flags, unsigned key, i
678 678
   return fl;
679 679
 }
680 680
 
681
+bool _cmGrPlotObjIsBorderClick( const cmGrPExt_t* pext, int px, int py )
682
+{
683
+  int dist = 3;
684
+
685
+  if( cmVOR_PtToLineDistance(cmGrPExtL(pext),cmGrPExtT(pext),cmGrPExtL(pext),cmGrPExtB(pext),px,py) < dist )
686
+    return true;
687
+
688
+  if(cmVOR_PtToLineDistance(cmGrPExtR(pext),cmGrPExtT(pext),cmGrPExtR(pext),cmGrPExtB(pext),px,py) < dist )
689
+    return true;
690
+
691
+  if( cmVOR_PtToLineDistance(cmGrPExtL(pext),cmGrPExtT(pext),cmGrPExtR(pext),cmGrPExtT(pext),px,py) < dist )
692
+    return true;
693
+
694
+  if(cmVOR_PtToLineDistance(cmGrPExtL(pext),cmGrPExtB(pext),cmGrPExtR(pext),cmGrPExtB(pext),px,py) < dist )
695
+    return true;
696
+  
697
+  return false;
698
+}
681 699
 
682
-bool _cmGrPlotObjIsInside( cmGrObjFuncArgs_t* args, int px, int py, cmGrV_t vx, cmGrV_t vy )
700
+bool _cmGrPlotObjIsInside( cmGrObjFuncArgs_t* args, unsigned evtFlags, int px, int py, cmGrV_t vx, cmGrV_t vy )
683 701
 {
684 702
   cmGrVExt_t vext;
685 703
   cmGrPExt_t pext;
686 704
   cmGrPlotObj_t* op = args->cbArg;
687 705
 
706
+  // no matter the type of event the object must be visible and enabled to respond to it 
707
+  if(!_cmGrPlotObjIsVisible(op)|| !_cmGrPlotObjIsEnabled(op) )
708
+    return false;
709
+
710
+  // objects that are not selectable are also not clickable
711
+  if( cmIsFlag(evtFlags,kMsClickGrFl) && cmIsFlag(op->cfgFlags,kNoSelectGrPlFl) )
712
+    return false;
713
+
714
+  // non-draggable objects can't be dragged.
715
+  if( cmIsFlag(evtFlags,kMsDragGrFl) && cmIsFlag(op->cfgFlags,kNoDragGrPlFl) )
716
+    return false;
717
+
688 718
   // get the virtual extents of this object
689 719
   _cmGrPlotObjVExt( args, &vext );
690 720
 
@@ -698,6 +728,10 @@ bool _cmGrPlotObjIsInside( cmGrObjFuncArgs_t* args, int px, int py, cmGrV_t vx,
698 728
     if( cmVOR_PtToLineDistance(cmGrPExtL(&pext),cmGrPExtT(&pext),cmGrPExtR(&pext),cmGrPExtB(&pext),px,py) < 3 )
699 729
       return true;
700 730
 
731
+  // if this is a click event and this is a border selectable object
732
+  if( cmIsFlag(evtFlags,kMsClickGrFl) && cmIsFlag(op->cfgFlags,kBorderSelGrPlFl) )
733
+    return _cmGrPlotObjIsBorderClick(&pext,px,py);
734
+
701 735
   // check if the px,py is inside pext
702 736
   return cmGrPExtIsXyInside(&pext,px,py);
703 737
 }
@@ -791,11 +825,11 @@ cmGrPlRC_t cmGrPlotObjCreate(
791 825
 
792 826
 
793 827
   // set the default colors
794
-  op->drawColors[kFocusPlGrId] =   0xcd853f;
795
-  op->fillColors[kFocusPlGrId] =   0xdeb887; 
828
+  op->drawColors[kSelectPlGrId] =   0xcd853f;
829
+  op->fillColors[kSelectPlGrId] =   0xdeb887; 
796 830
 
797
-  op->drawColors[kSelectPlGrId] =  0x483d8b;
798
-  op->fillColors[kSelectPlGrId] =  0x8470ff; 
831
+  op->drawColors[kFocusPlGrId] =  0x483d8b;
832
+  op->fillColors[kFocusPlGrId] =  0x8470ff; 
799 833
 
800 834
   op->drawColors[kEnablePlGrId] =  0x000000;
801 835
   op->fillColors[kEnablePlGrId] =  0x009ff7; 

+ 1
- 0
cmGrPlot.h Zobrazit soubor

@@ -43,6 +43,7 @@ extern "C" {
43 43
     kNoFillGrPlFl   = 0x0020,  // Do not draw the fill area of this object
44 44
     kNoBorderGrPlFl = 0x0040,  // Do not draw the border of this object
45 45
     kNoLabelGrPlFl  = 0x0080,  // Do not draw the label for this object
46
+    kBorderSelGrPlFl= 0x0100,  // This object is selected by clicking near it's border
46 47
   };
47 48
 
48 49
   // object state flags

+ 1
- 1
cmGrPlotAudio.c Zobrazit soubor

@@ -131,7 +131,7 @@ bool _cmGrPlObjAfRender(   cmGrObjFuncArgs_t* args, cmGrDcH_t dcH )
131 131
   return true;
132 132
 }
133 133
 
134
-bool  _cmGrPlObjAfIsInside( cmGrObjFuncArgs_t* args, int px, int py, cmGrV_t vx, cmGrV_t vy )
134
+bool  _cmGrPlObjAfIsInside( cmGrObjFuncArgs_t* args, unsigned evtFlags, int px, int py, cmGrV_t vx, cmGrV_t vy )
135 135
 {
136 136
   cmGrPlObjAf_t* op = (cmGrPlObjAf_t*)args->cbArg;
137 137
 

Načítá se…
Zrušit
Uložit