Wizard.cpp (pymol-open-source-2.2.0) | : | Wizard.cpp (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 61 | skipping to change at line 61 | |||
#define cWizEventDirty 128 | #define cWizEventDirty 128 | |||
#define cWizEventView 256 | #define cWizEventView 256 | |||
#define cWizEventPosition 512 | #define cWizEventPosition 512 | |||
typedef struct { | typedef struct { | |||
int type; | int type; | |||
WordType text; | WordType text; | |||
OrthoLineType code; | OrthoLineType code; | |||
} WizardLine; | } WizardLine; | |||
struct _CWizard { | struct CWizard : public Block { | |||
::Block *Block; | PyObject **Wiz {}; | |||
PyObject **Wiz; | WizardLine *Line {}; | |||
WizardLine *Line; | ov_size NLine { 0 }; | |||
ov_size NLine; | ov_diff Stack { -1 }; | |||
ov_diff Stack; | int Pressed { -1 }; | |||
int Pressed; | int EventMask { 0 }; | |||
int EventMask; | int Dirty {}; | |||
int Dirty; | int LastUpdatedState { -1 }; | |||
int LastUpdatedState; | int LastUpdatedFrame { -1 }; | |||
int LastUpdatedFrame; | float LastUpdatedPosition[3] {}; | |||
float LastUpdatedPosition[3]; | SceneViewType LastUpdatedView {}; | |||
SceneViewType LastUpdatedView; | ||||
CWizard(PyMOLGlobals * G) : Block(G) {}; | ||||
int click(int button, int x, int y, int mod) override; | ||||
int drag(int x, int y, int mod) override; | ||||
void draw(CGO* orthoCGO) override; | ||||
int release(int button, int x, int y, int mod) override; | ||||
}; | }; | |||
#define cWizardLeftMargin DIP2PIXEL(3) | #define cWizardLeftMargin DIP2PIXEL(3) | |||
#define cWizardTopMargin 0 | #define cWizardTopMargin 0 | |||
#define cWizardClickOffset DIP2PIXEL(2) | #define cWizardClickOffset DIP2PIXEL(2) | |||
void WizardDirty(PyMOLGlobals * G) | void WizardDirty(PyMOLGlobals * G) | |||
{ | { | |||
CWizard *I = G->Wizard; | CWizard *I = G->Wizard; | |||
I->Dirty = true; | I->Dirty = true; | |||
skipping to change at line 319 | skipping to change at line 325 | |||
if(I->Stack < 0) | if(I->Stack < 0) | |||
return false; | return false; | |||
return (I->Wiz[I->Stack] && 1); | return (I->Wiz[I->Stack] && 1); | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
Block *WizardGetBlock(PyMOLGlobals * G) | Block *WizardGetBlock(PyMOLGlobals * G) | |||
{ | { | |||
CWizard *I = G->Wizard; | CWizard *I = G->Wizard; | |||
{ | { | |||
return (I->Block); | return (I); | |||
} | } | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
int WizardDoPick(PyMOLGlobals * G, int bondFlag, int state) | int WizardDoPick(PyMOLGlobals * G, int bondFlag, int state) | |||
{ | { | |||
/** | /** | |||
* Run when user picks something | * Run when user picks something | |||
*/ | */ | |||
#ifdef _PYMOL_NOPY | #ifdef _PYMOL_NOPY | |||
skipping to change at line 606 | skipping to change at line 612 | |||
PyErr_Print(); | PyErr_Print(); | |||
} | } | |||
} | } | |||
PUnblock(G); | PUnblock(G); | |||
} | } | |||
return result; | return result; | |||
#endif | #endif | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
static int WizardClick(Block * block, int button, int x, int y, int mod) | int CWizard::click(int button, int x, int y, int mod) | |||
{ | { | |||
#ifdef _PYMOL_NOPY | #ifdef _PYMOL_NOPY | |||
return 0; | return 0; | |||
#else | #else | |||
PyMOLGlobals *G = block->G; | PyMOLGlobals *G = m_G; | |||
CWizard *I = G->Wizard; | CWizard *I = G->Wizard; | |||
int a; | int a; | |||
PyObject *menuList = NULL; | PyObject *menuList = NULL; | |||
int LineHeight = DIP2PIXEL(SettingGetGlobal_i(G, cSetting_internal_gui_control _size)); | int LineHeight = DIP2PIXEL(SettingGetGlobal_i(G, cSetting_internal_gui_control _size)); | |||
a = ((I->Block->rect.top - (y + cWizardClickOffset)) - cWizardTopMargin) / Lin eHeight; | a = ((rect.top - (y + cWizardClickOffset)) - cWizardTopMargin) / LineHeight; | |||
if((a >= 0) && ((ov_size) a < I->NLine)) { | if((a >= 0) && ((ov_size) a < I->NLine)) { | |||
switch (I->Line[a].type) { | switch (I->Line[a].type) { | |||
case cWizTypeButton: | case cWizTypeButton: | |||
OrthoGrab(G, I->Block); | OrthoGrab(G, this); | |||
I->Pressed = (int) a; | I->Pressed = (int) a; | |||
OrthoDirty(G); | OrthoDirty(G); | |||
break; | break; | |||
case cWizTypePopUp: | case cWizTypePopUp: | |||
PBlock(G); | PBlock(G); | |||
if(I->Stack >= 0) | if(I->Stack >= 0) | |||
if(I->Wiz[I->Stack]) { | if(I->Wiz[I->Stack]) { | |||
if(PyObject_HasAttrString(I->Wiz[I->Stack], "get_menu")) { | if(PyObject_HasAttrString(I->Wiz[I->Stack], "get_menu")) { | |||
menuList = | menuList = | |||
PYOBJECT_CALLMETHOD(I->Wiz[I->Stack], "get_menu", "s", I->Line[a]. code); | PYOBJECT_CALLMETHOD(I->Wiz[I->Stack], "get_menu", "s", I->Line[a]. code); | |||
if(PyErr_Occurred()) | if(PyErr_Occurred()) | |||
PyErr_Print(); | PyErr_Print(); | |||
} | } | |||
} | } | |||
if(PyErr_Occurred()) | if(PyErr_Occurred()) | |||
PyErr_Print(); | PyErr_Print(); | |||
if(menuList && (menuList != Py_None)) { | if(menuList && (menuList != Py_None)) { | |||
int my = I->Block->rect.top - (cWizardTopMargin + a * LineHeight) - 2; | int my = rect.top - (cWizardTopMargin + a * LineHeight) - 2; | |||
PopUpNew(G, x, my, x, y, false, menuList, NULL); | PopUpNew(G, x, my, x, y, false, menuList, NULL); | |||
} | } | |||
Py_XDECREF(menuList); | Py_XDECREF(menuList); | |||
PUnblock(G); | PUnblock(G); | |||
break; | break; | |||
} | } | |||
} | } | |||
return (1); | return (1); | |||
#endif | #endif | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
static int WizardDrag(Block * block, int x, int y, int mod) | int CWizard::drag(int x, int y, int mod) | |||
{ | { | |||
#ifdef _PYMOL_NOPY | #ifdef _PYMOL_NOPY | |||
return 0; | return 0; | |||
#else | #else | |||
PyMOLGlobals *G = block->G; | PyMOLGlobals *G = m_G; | |||
CWizard *I = G->Wizard; | CWizard *I = G->Wizard; | |||
int LineHeight = DIP2PIXEL(SettingGetGlobal_i(G, cSetting_internal_gui_control _size)); | int LineHeight = DIP2PIXEL(SettingGetGlobal_i(G, cSetting_internal_gui_control _size)); | |||
int a; | int a; | |||
a = ((I->Block->rect.top - (y + cWizardClickOffset)) - cWizardTopMargin) / Lin eHeight; | a = ((rect.top - (y + cWizardClickOffset)) - cWizardTopMargin) / LineHeight; | |||
if((x < I->Block->rect.left) || (x > I->Block->rect.right)) | if((x < rect.left) || (x > rect.right)) | |||
a = -1; | a = -1; | |||
if(I->Pressed != a) { | if(I->Pressed != a) { | |||
I->Pressed = -1; | I->Pressed = -1; | |||
OrthoDirty(G); | OrthoDirty(G); | |||
} | } | |||
if((a >= 0) && ((ov_size) a < I->NLine)) { | if((a >= 0) && ((ov_size) a < I->NLine)) { | |||
switch (I->Line[a].type) { | switch (I->Line[a].type) { | |||
case cWizTypeButton: | case cWizTypeButton: | |||
skipping to change at line 691 | skipping to change at line 697 | |||
OrthoDirty(G); | OrthoDirty(G); | |||
} | } | |||
break; | break; | |||
} | } | |||
} | } | |||
return (1); | return (1); | |||
#endif | #endif | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
static int WizardRelease(Block * block, int button, int x, int y, int mod) | int CWizard::release(int button, int x, int y, int mod) | |||
{ | { | |||
PyMOLGlobals *G = block->G; | PyMOLGlobals *G = m_G; | |||
CWizard *I = G->Wizard; | CWizard *I = this; // TODO: Remove during Wizard Refactor | |||
int LineHeight = DIP2PIXEL(SettingGetGlobal_i(G, cSetting_internal_gui_control _size)); | int LineHeight = DIP2PIXEL(SettingGetGlobal_i(G, cSetting_internal_gui_control _size)); | |||
int a; | int a; | |||
a = ((I->Block->rect.top - (y + cWizardClickOffset)) - cWizardTopMargin) / Lin eHeight; | a = ((rect.top - (y + cWizardClickOffset)) - cWizardTopMargin) / LineHeight; | |||
if(I->Pressed) | if(I->Pressed) | |||
I->Pressed = -1; | I->Pressed = -1; | |||
OrthoDirty(G); | OrthoDirty(G); | |||
OrthoUngrab(G); | OrthoUngrab(G); | |||
if((a >= 0) && ((ov_size) a < I->NLine)) { | if((a >= 0) && ((ov_size) a < I->NLine)) { | |||
switch (I->Line[a].type) { | switch (I->Line[a].type) { | |||
case cWizTypeButton: | case cWizTypeButton: | |||
skipping to change at line 822 | skipping to change at line 828 | |||
if(TextSetColorFromCode(G, c, color)) { | if(TextSetColorFromCode(G, c, color)) { | |||
c += 4; | c += 4; | |||
} | } | |||
TextSetPos2i(G, xx, yy); | TextSetPos2i(G, xx, yy); | |||
TextDrawChar(G, *(c++) ORTHOCGOARGVAR); | TextDrawChar(G, *(c++) ORTHOCGOARGVAR); | |||
xx = xx + DIP2PIXEL(8); | xx = xx + DIP2PIXEL(8); | |||
} | } | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
static void WizardDraw(Block * block ORTHOCGOARG) | void CWizard::draw(CGO* orthoCGO) | |||
{ | { | |||
PyMOLGlobals *G = block->G; | PyMOLGlobals *G = m_G; | |||
CWizard *I = G->Wizard; | CWizard *I = G->Wizard; | |||
int x, y; | int x, y; | |||
int a; | int a; | |||
float buttonTextColor[3] = { 1.0, 1.0, 1.0 }; | float buttonTextColor[3] = { 1.0, 1.0, 1.0 }; | |||
float buttonActiveColor[3] = { 0.8F, 0.8F, 0.8F }; | float buttonActiveColor[3] = { 0.8F, 0.8F, 0.8F }; | |||
float dimColor[3] = { 0.45F, 0.45F, 0.45F }; | float dimColor[3] = { 0.45F, 0.45F, 0.45F }; | |||
skipping to change at line 846 | skipping to change at line 852 | |||
float dimDarkEdge[3] = { 0.25F, 0.25F, 0.25F }; | float dimDarkEdge[3] = { 0.25F, 0.25F, 0.25F }; | |||
float menuBGColor[3] = { 0.5F, 0.5F, 1.0 }; | float menuBGColor[3] = { 0.5F, 0.5F, 1.0 }; | |||
float menuLightEdge[3] = { 0.7F, 0.7F, 0.9F }; | float menuLightEdge[3] = { 0.7F, 0.7F, 0.9F }; | |||
float menuDarkEdge[3] = { 0.3F, 0.3F, 0.5F }; | float menuDarkEdge[3] = { 0.3F, 0.3F, 0.5F }; | |||
float black_color[3] = { 0.0F, 0.0F, 0.0F }; | float black_color[3] = { 0.0F, 0.0F, 0.0F }; | |||
float menuColor[3] = { 0.0, 0.0, 0.0 }; | float menuColor[3] = { 0.0, 0.0, 0.0 }; | |||
int LineHeight = DIP2PIXEL(SettingGetGlobal_i(G, cSetting_internal_gui_control _size)); | int LineHeight = DIP2PIXEL(SettingGetGlobal_i(G, cSetting_internal_gui_control _size)); | |||
int text_lift = (LineHeight / 2) - DIP2PIXEL(5); | int text_lift = (LineHeight / 2) - DIP2PIXEL(5); | |||
float *text_color, *text_color2 = I->Block->TextColor; | float *text_color, *text_color2 = TextColor; | |||
text_color = menuColor; | text_color = menuColor; | |||
if(G->HaveGUI && G->ValidContext && ((block->rect.right - block->rect.left) > 6)) { | if(G->HaveGUI && G->ValidContext && ((rect.right - rect.left) > 6)) { | |||
if(SettingGetGlobal_b(G, cSetting_internal_gui_mode) == 0) { | if(SettingGetGlobal_b(G, cSetting_internal_gui_mode) == 0) { | |||
if (orthoCGO) | if (orthoCGO) | |||
CGOColorv(orthoCGO, I->Block->BackColor); | CGOColorv(orthoCGO, BackColor); | |||
#ifndef PURE_OPENGL_ES_2 | ||||
else | else | |||
glColor3fv(I->Block->BackColor); | glColor3fv(BackColor); | |||
BlockFill(I->Block ORTHOCGOARGVAR); | #endif | |||
BlockDrawLeftEdge(I->Block ORTHOCGOARGVAR); | fill(orthoCGO); | |||
drawLeftEdge(orthoCGO); | ||||
} else { | } else { | |||
BlockDrawLeftEdge(I->Block ORTHOCGOARGVAR); | drawLeftEdge(orthoCGO); | |||
if (orthoCGO) | if (orthoCGO) | |||
CGOColor(orthoCGO, .5f, .5f, .5f); | CGOColor(orthoCGO, .5f, .5f, .5f); | |||
else | else | |||
glColor3f(0.5, 0.5, 0.5); | glColor3f(0.5, 0.5, 0.5); | |||
BlockDrawTopEdge(I->Block); | drawTopEdge(); | |||
text_color2 = OrthoGetOverlayColor(G); | text_color2 = OrthoGetOverlayColor(G); | |||
} | } | |||
if (orthoCGO) | if (orthoCGO) | |||
CGOColorv(orthoCGO, I->Block->TextColor); | CGOColorv(orthoCGO, TextColor); | |||
#ifndef PURE_OPENGL_ES_2 | ||||
else | else | |||
glColor3fv(I->Block->TextColor); | glColor3fv(TextColor); | |||
x = I->Block->rect.left + cWizardLeftMargin; | #endif | |||
y = (I->Block->rect.top - LineHeight) - cWizardTopMargin; | x = rect.left + cWizardLeftMargin; | |||
y = (rect.top - LineHeight) - cWizardTopMargin; | ||||
for(a = 0; (ov_size) a < I->NLine; a++) { | for(a = 0; (ov_size) a < I->NLine; a++) { | |||
if(I->Pressed == a) { | if(I->Pressed == a) { | |||
draw_button(I->Block->rect.left + 1, y, | draw_button(rect.left + 1, y, | |||
(I->Block->rect.right - I->Block->rect.left) - 1, | (rect.right - rect.left) - 1, | |||
LineHeight - 1, dimLightEdge, dimDarkEdge, buttonActiveColor ORTHOCGOARGVAR); | LineHeight - 1, dimLightEdge, dimDarkEdge, buttonActiveColor ORTHOCGOARGVAR); | |||
/* glColor3f(0.0,0.0,0.0); */ | /* glColor3f(0.0,0.0,0.0); */ | |||
text_color = black_color; | text_color = black_color; | |||
} else { | } else { | |||
switch (I->Line[a].type) { | switch (I->Line[a].type) { | |||
case cWizTypeText: | case cWizTypeText: | |||
text_color = text_color2; | text_color = text_color2; | |||
glColor3fv(text_color2); | glColor3fv(text_color2); | |||
break; | break; | |||
case cWizTypeButton: | case cWizTypeButton: | |||
draw_button(I->Block->rect.left + 1, y, | draw_button(rect.left + 1, y, | |||
(I->Block->rect.right - I->Block->rect.left) - 1, | (rect.right - rect.left) - 1, | |||
LineHeight - 1, dimLightEdge, dimDarkEdge, dimColor ORTHOC GOARGVAR); | LineHeight - 1, dimLightEdge, dimDarkEdge, dimColor ORTHOC GOARGVAR); | |||
/* glColor3fv(buttonTextColor); */ | /* glColor3fv(buttonTextColor); */ | |||
text_color = buttonTextColor; | text_color = buttonTextColor; | |||
break; | break; | |||
case cWizTypePopUp: | case cWizTypePopUp: | |||
draw_button(I->Block->rect.left + 1, y, | draw_button(rect.left + 1, y, | |||
(I->Block->rect.right - I->Block->rect.left) - 1, | (rect.right - rect.left) - 1, | |||
LineHeight - 1, menuLightEdge, menuDarkEdge, menuBGColor O RTHOCGOARGVAR); | LineHeight - 1, menuLightEdge, menuDarkEdge, menuBGColor O RTHOCGOARGVAR); | |||
/* glColor3fv(menuColor); */ | /* glColor3fv(menuColor); */ | |||
text_color = menuColor; | text_color = menuColor; | |||
break; | break; | |||
default: | default: | |||
break; | break; | |||
} | } | |||
} | } | |||
draw_text(G, I->Line[a].text, x, y + text_lift, text_color ORTHOCGOARGVAR) ; | draw_text(G, I->Line[a].text, x, y + text_lift, text_color ORTHOCGOARGVAR) ; | |||
/*GrapDrawStr(I->Line[a].text,x+1,y+text_lift); */ | /*GrapDrawStr(I->Line[a].text,x+1,y+text_lift); */ | |||
skipping to change at line 987 | skipping to change at line 997 | |||
OrthoDirty(G); | OrthoDirty(G); | |||
} | } | |||
return (ok); | return (ok); | |||
#endif | #endif | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
int WizardInit(PyMOLGlobals * G) | int WizardInit(PyMOLGlobals * G) | |||
{ | { | |||
CWizard *I = NULL; | CWizard *I = NULL; | |||
if((I = (G->Wizard = Calloc(CWizard, 1)))) { | if((I = (G->Wizard = new CWizard(G)))) { | |||
I->Block = OrthoNewBlock(G, NULL); | I->active = true; | |||
I->Block->fClick = WizardClick; | I->TextColor[0] = 0.2F; | |||
I->Block->fDrag = WizardDrag; | I->TextColor[1] = 1.0F; | |||
I->Block->fDraw = WizardDraw; | I->TextColor[2] = 0.2F; | |||
I->Block->fReshape = BlockReshape; | ||||
I->Block->fRelease = WizardRelease; | ||||
I->Block->active = true; | ||||
I->Block->TextColor[0] = 0.2F; | ||||
I->Block->TextColor[1] = 1.0F; | ||||
I->Block->TextColor[2] = 0.2F; | ||||
I->LastUpdatedState = -1; | OrthoAttach(G, I, cOrthoTool); | |||
I->LastUpdatedFrame = -1; | ||||
OrthoAttach(G, I->Block, cOrthoTool); | ||||
I->Line = VLAlloc(WizardLine, 1); | I->Line = VLAlloc(WizardLine, 1); | |||
I->NLine = 0; | ||||
I->Pressed = -1; | ||||
I->EventMask = 0; | ||||
I->Stack = -1; | ||||
I->Wiz = VLAlloc(PyObject *, 10); | I->Wiz = VLAlloc(PyObject *, 10); | |||
return 1; | return 1; | |||
} else | } else | |||
return 0; | return 0; | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
void WizardFree(PyMOLGlobals * G) | void WizardFree(PyMOLGlobals * G) | |||
{ | { | |||
CWizard *I = G->Wizard; | CWizard *I = G->Wizard; | |||
WizardPurgeStack(G); | WizardPurgeStack(G); | |||
OrthoFreeBlock(G, I->Block); | ||||
VLAFreeP(I->Line); | VLAFreeP(I->Line); | |||
VLAFreeP(I->Wiz); | VLAFreeP(I->Wiz); | |||
FreeP(G->Wizard); | DeleteP(G->Wizard); | |||
} | } | |||
End of changes. 34 change blocks. | ||||
69 lines changed or deleted | 64 lines changed or added |