예제 #1
0
파일: Control.c 프로젝트: aghozlane/pymol
static int ControlDrag(Block * block, int x, int y, int mod)
{
  int width;
  int delta;
  int gui_width;
  PyMOLGlobals *G = block->G;
  register CControl *I = G->Control;
  if(!I->SkipRelease) {
    delta = x - I->LastPos;
    if(I->DragFlag) {
      if(delta) {
        gui_width = (int) SettingGet(G, cSetting_internal_gui_width) - delta;
        if(gui_width < cControlMinWidth)
          gui_width = cControlMinWidth;
        delta = (int) SettingGet(G, cSetting_internal_gui_width) - gui_width;
        width = OrthoGetWidth(G) + delta;
        I->LastPos = x;
        I->SaveWidth = 0;
        SettingSet(G, cSetting_internal_gui_width, (float) gui_width);
        OrthoReshape(G, -1, -1, false);
      }
    } else {
      I->Active = which_button(I, x, y);
      if(I->Active != I->Pressed)
        I->Active = -1;
      OrthoDirty(G);
    }
  }
  return (1);
}
예제 #2
0
파일: Control.c 프로젝트: aghozlane/pymol
/*========================================================================*/
static int ControlClick(Block * block, int button, int x, int y, int mod)
{
  PyMOLGlobals *G = block->G;
  register CControl *I = G->Control;
  I->SkipRelease = false;
  if(x < (I->Block->rect.left + cControlLeftMargin)) {
    y -= I->Block->rect.top - cControlTopMargin;
    if((y <= 0) && (y > (-cControlBoxSize))) {
      double now = UtilGetSeconds(block->G);
      if((now - I->LastClickTime) < 0.35) {
        if(I->SaveWidth) {
          SettingSet(G, cSetting_internal_gui_width, (float) I->SaveWidth);
          OrthoReshape(G, -1, -1, false);
          I->SaveWidth = 0;
        } else {
          I->SaveWidth = (int) SettingGet(G, cSetting_internal_gui_width);
          SettingSet(G, cSetting_internal_gui_width, (float) cControlMinWidth);
          OrthoReshape(G, -1, -1, false);
        }
        I->SkipRelease = true;
      } else {
        I->LastPos = x;
        OrthoGrab(G, block);
        I->DragFlag = true;
        I->LastClickTime = UtilGetSeconds(G);
      }
    }
  } else {
    I->Pressed = which_button(I, x, y);
    I->Active = I->Pressed;
    if(I->Pressed)
      OrthoGrab(G, block);
    OrthoDirty(G);
  }
  return (1);
}
예제 #3
0
파일: Control.c 프로젝트: aghozlane/pymol
static int ControlRelease(Block * block, int button, int x, int y, int mod)
{
  PyMOLGlobals *G = block->G;
  register CControl *I = G->Control;

  int sel = 0;

  I->LastPos = x;
  sel = which_button(I, x, y);
  if(!I->SkipRelease) {
    switch (sel) {
    case 0:
      SceneSetFrame(G, 4, 0);
      PLog(G, "cmd.rewind()", cPLog_pym);
      break;
    case 1:
      SceneSetFrame(G, 5, -1);
      PLog(G, "cmd.back()", cPLog_pym);
      break;
    case 2:
      MoviePlay(G, cMovieStop);
      if(SettingGet(G, cSetting_sculpting))
        SettingSet(G, cSetting_sculpting, 0);
      if(SettingGetGlobal_b(G, cSetting_rock))
        SettingSetGlobal_b(G, cSetting_rock, false);
      ExecutiveDrawNow(G);
      OrthoDirty(G);
      PLog(G, "cmd.mstop()", cPLog_pym);
      break;
    case 3:
      if(!MoviePlaying(G)) {
        if(mod & cOrthoCTRL) {
          PLog(G, "cmd.rewind()", cPLog_pym);
          PLog(G, "cmd.mplay()", cPLog_pym);
          SceneSetFrame(G, 4, 0);
          MoviePlay(G, cMoviePlay);
        } else {
          PLog(G, "cmd.mplay()", cPLog_pym);
          MoviePlay(G, cMoviePlay);
        }
      } else {
        MoviePlay(G, cMovieStop);
        ExecutiveDrawNow(G);
        OrthoDirty(G);
        PLog(G, "cmd.mstop()", cPLog_pym);
      }
      break;
    case 4:
      SceneSetFrame(G, 5, 1);
      PLog(G, "cmd.forward()", cPLog_pym);
      break;
    case 5:
      if(mod & cOrthoCTRL) {
        SceneSetFrame(G, 3, 0);
        PLog(G, "cmd.middle()", cPLog_pym);
      } else {
        SceneSetFrame(G, 6, 0);
        PLog(G, "cmd.ending()", cPLog_pym);
      }
      break;
    case 6:
      if(SettingGetGlobal_b(G, cSetting_seq_view)) {
        SettingSetGlobal_b(G, cSetting_seq_view, 0);
        SeqChanged(G);
        PLog(G, "cmd.set('seq_view',0)", cPLog_pym);
      } else {
        SettingSetGlobal_b(G, cSetting_seq_view, 1);
        SeqChanged(G);
        PLog(G, "cmd.set('seq_view',1)", cPLog_pym);
      }
      OrthoDirty(G);
      break;
    case 7:
      SettingSetGlobal_b(G, cSetting_rock, !SettingGetGlobal_b(G, cSetting_rock));
      if(SettingGetGlobal_b(G, cSetting_rock)) {
        SceneRestartSweepTimer(G);
        PLog(G, "cmd.rock(1)", cPLog_pym);
      } else
        PLog(G, "cmd.rock(0)", cPLog_pym);
      SceneRestartFrameTimer(G);
      OrthoDirty(G);
      break;
    case 8:
      PLog(G, "cmd.fullscreen()", cPLog_pym);
      ExecutiveFullScreen(G, -1);
      break;
    }
    OrthoDirty(G);
    OrthoUngrab(G);
    I->LastClickTime = UtilGetSeconds(G);
    I->DragFlag = false;
    I->Active = -1;
    I->Pressed = -1;
  }
  return (1);
}
예제 #4
0
void event_loop (void (*act_on_button) (float x, float y), 
    void (*drawscreen) (void)) {

/* The program's main event loop.  Must be passed a user routine        *
 * drawscreen which redraws the screen.  It handles all window resizing *
 * zooming etc. itself.  If the user clicks a button in the graphics    *
 * (toplevel) area, the act_on_button routine passed in is called.      */

 XEvent report;
 int bnum;
 float x, y;

#define OFF 1
#define ON 0

 turn_on_off (ON);
 while (1) {
    XNextEvent (display, &report);
    switch (report.type) {  
    case Expose:
#ifdef VERBOSE 
       printf("Got an expose event.\n");
       printf("Count is: %d.\n",report.xexpose.count);
       printf("Window ID is: %d.\n",report.xexpose.window);
#endif
       if (report.xexpose.count != 0)
           break;
       if (report.xexpose.window == menu)
          drawmenu(); 
       else if (report.xexpose.window == toplevel)
          drawscreen();
       else if (report.xexpose.window == textarea)
          draw_message();
       break;
    case ConfigureNotify:
       top_width = report.xconfigure.width;
       top_height = report.xconfigure.height;
       update_transform();
#ifdef VERBOSE 
       printf("Got a ConfigureNotify.\n");
       printf("New width: %d  New height: %d.\n",top_width,top_height);
#endif
       break; 
    case ButtonPress:
#ifdef VERBOSE 
       printf("Got a buttonpress.\n");
       printf("Window ID is: %d.\n",report.xbutton.window);
#endif
       if (report.xbutton.window == toplevel) {
          x = XTOWORLD(report.xbutton.x);
          y = YTOWORLD(report.xbutton.y); 
          act_on_button (x, y);
       } 
       else {  /* A menu button was pressed. */
          bnum = which_button(report.xbutton.window);
#ifdef VERBOSE 
       printf("Button number is %d\n",bnum);
#endif
          button[bnum].ispressed = 1;
          drawbut(bnum);
          XFlush(display);  /* Flash the button */
          button[bnum].fcn(bnum, drawscreen);
          button[bnum].ispressed = 0;
          drawbut(bnum);
          if (button[bnum].fcn == proceed) {
             turn_on_off(OFF);
             flushinput ();
             return;  /* Rather clumsy way of returning *
                       * control to the simulator       */
          }
       }
       break;
    }
 }
}