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); }
MSKContext *MSKContextNew() { MSKContext *G = Calloc(MSKContext, 1); if (G) { //ColorInit(G); SphereInit(G); // Map Settings SettingSet(G, cSetting_hash_max, 100); // Triangle Settings SettingSet(G, cSetting_triangle_max_passes, 5); SettingSet(G, cSetting_fit_tolerance, 0.0000001F); SettingSet(G, cSetting_fit_iterations, 1000); SettingSet(G, cSetting_fit_kabsch, 0); G->Ready = true; } return G; }
/*========================================================================*/ 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); }
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); }