1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
/*
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
D* -------------------------------------------------------------------
E* It is unlawful to modify or remove this copyright notice.
F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information.
H* -------------------------------------------------------------------
I* Additional authors of this source file include:
-*
-*
-*
Z* -------------------------------------------------------------------
*/
#include"os_std.h"
#include"os_predef.h"
#include"Base.h"
#include"Ortho.h"
#include"Pop.h"
#include"MemoryDebug.h"
#define cPopMargin 3
struct CPop : public Block {
CPop(PyMOLGlobals * G) : Block(G){}
void reshape(int width, int height) override;
};
/*========================================================================*/
void CPop::reshape(int width, int height)
{
rect.top = height;
rect.right = width;
}
/*========================================================================*/
Block *PopGetBlock(PyMOLGlobals * G)
{
CPop *I = G->Pop;
{
return (I);
}
}
/*========================================================================*/
void PopFree(PyMOLGlobals * G)
{
DeleteP(G->Pop);
}
/*========================================================================*/
int PopInit(PyMOLGlobals * G)
{
CPop *I = NULL;
if((I = (G->Pop = new CPop(G)))) {
I->active = false;
I->rect.top = 10;
I->rect.bottom = 14;
I->rect.left = 0;
I->rect.right = 10;
OrthoAttach(G, I, cOrthoHidden);
return 1;
} else
return 0;
}
/*========================================================================*/
void PopFitBlock(Block * block)
{
CPop *I = block->m_G->Pop; // TODO: Three indirections for a 'this' lol
int delta;
if((block->rect.bottom - cPopMargin) < (I->rect.bottom)) {
delta = (I->rect.bottom - block->rect.bottom) + cPopMargin;
block->rect.top += delta;
block->rect.bottom += delta;
}
if((block->rect.right + cPopMargin) > (I->rect.right)) {
delta = (block->rect.right - (I->rect.right)) + cPopMargin;
block->rect.left -= delta;
block->rect.right -= delta;
}
if((block->rect.left - cPopMargin) < (I->rect.left)) {
delta = (I->rect.left - block->rect.left) + cPopMargin;
block->rect.right += delta;
block->rect.left += delta;
}
if((block->rect.top + cPopMargin) > (I->rect.top)) {
delta = (block->rect.top - (I->rect.top)) + cPopMargin;
block->rect.top -= delta;
block->rect.bottom -= delta;
}
}
/*========================================================================*/
int PopPlaceChild(Block * block, int left_x, int right_x, int row_y, int affinity)
{
int width = block->rect.right - block->rect.left;
int height = block->rect.top - block->rect.bottom;
int target_x;
block->rect.top = row_y;
block->rect.bottom = row_y - height;
if(affinity >= 0) {
affinity = 1;
target_x = right_x - 2;
block->rect.left = target_x;
block->rect.right = target_x + width;
} else {
affinity = -1;
target_x = left_x - width + 2;
block->rect.left = target_x;
block->rect.right = target_x + width;
}
PopFitBlock(block);
if(affinity >= 0) {
if(block->rect.left != target_x) {
affinity = -1;
target_x = left_x - width + 2;
block->rect.left = target_x;
block->rect.right = target_x + width;
PopFitBlock(block);
}
} else {
if(block->rect.left != target_x) {
affinity = 1;
target_x = right_x - 2;
block->rect.left = target_x;
block->rect.right = target_x + width;
PopFitBlock(block);
}
}
return affinity;
}
|