19 QIcon* VuoInputEditorAnchor::renderIconWithLineSegments(
const float* points,
const unsigned int length)
30 for(
int i = 0; i < length; i += 4)
32 path.moveTo(points[i+0], points[i+1]);
33 path.lineTo(points[i+2], points[i+3]);
36 p.strokePath(path, QPen(Qt::black, 1));
40 QIcon* VuoInputEditorAnchor::iconForAnchorIndex(
const int anchor)
42 const float left_top[8] = { 1.f, 1.f, 1.f, 15.f, 1.f, 1.f, 15.f, 1.f };
43 const float center_top[4] = { 1.f, 1.f, 15.f, 1.f };
44 const float right_top[8] = { 1.f, 1.f, 15.f, 1.f, 15.f, 1.f, 15.f, 15.f};
46 const float left_center[4] = { 1.f, 1.f, 1.f, 15.f };
47 const float center_center[8] = { 8.f, 1.f, 8.f, 15.f, 1.f, 8.f, 15.f, 8.f };
48 const float right_center[4] = { 15.f, 1.f, 15.f, 15.f };
50 const float left_bottom[8] = { 1.f, 15.f, 1.f, 1.f, 1.f, 15.f, 15.f, 15.f };
51 const float center_bottom[4] = { 1.f, 15.f, 15.f, 15.f };
52 const float right_bottom[8] = { 1.f, 15.f, 15.f, 15.f, 15.f, 15.f, 15.f, 1.f };
58 return renderIconWithLineSegments( left_top, 8 );
62 return renderIconWithLineSegments( center_top, 4 );
66 return renderIconWithLineSegments( right_top, 8 );
70 return renderIconWithLineSegments( left_center, 4 );
74 return renderIconWithLineSegments( center_center, 8 );
78 return renderIconWithLineSegments( right_center, 4 );
82 return renderIconWithLineSegments( left_bottom, 8 );
85 return renderIconWithLineSegments( center_bottom, 8 );
89 return renderIconWithLineSegments( right_bottom, 8 );
92 return renderIconWithLineSegments( left_top, 8 );
104 int VuoInputEditorAnchor::VuoAnchorToIndex(
const VuoAnchor anchor)
118 int curIndex = VuoAnchorToIndex(curAnchor);
121 QGridLayout* layout =
new QGridLayout;
122 layout->setContentsMargins(4, 4, 12, 4);
123 layout->setSpacing(0);
125 QSettings* settings =
new QSettings();
126 bool isDark = settings->value(
"darkInterface").toBool();
132 for(
int r = 0; r < 3; r++)
134 for(
int c = 0; c < 3; c++)
136 int index = r * 3 + c;
138 QIcon* icon = iconForAnchorIndex(index);
139 matrix[index] =
new QPushButton(*icon,
"");
141 matrix[index]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
142 matrix[index]->setCheckable(
true);
143 matrix[index]->setChecked(
false);
144 matrix[index]->setAutoExclusive(
true);
145 matrix[index]->setFocusPolicy(Qt::NoFocus);
146 matrix[index]->setDown(
false);
147 matrix[index]->setFlat(
true);
148 matrix[index]->setContentsMargins(0,0,0,0);
149 matrix[index]->setMaximumWidth(24);
150 matrix[index]->setMaximumHeight(24);
151 matrix[index]->setMinimumWidth(24);
152 matrix[index]->setMinimumHeight(24);
154 matrix[index]->setStyleSheet(
"QPushButton:checked { background: #8c8c8c; border: none; outline: none; } QPushButton:pressed { background: #9c9c9c; border: none; outline: none; }" );
156 matrix[index]->setStyleSheet(
"QPushButton:checked { background: #c0c0c0; border: none; outline: none; } QPushButton:pressed { background: #b0b0b0; border: none; outline: none; }" );
157 connect(matrix[index], &QPushButton::released,
this, &VuoInputEditorAnchor::onSetAnchor);
158 layout->addWidget(matrix[index], r, c);
162 matrix[curIndex]->setChecked(
true);
164 dialog.setFocusPolicy(Qt::NoFocus);
165 dialog.setLayout(layout);
168 void VuoInputEditorAnchor::onSetAnchor()
171 for (
int i = 0; i < 9; ++i)
172 if (matrix[i] == sender())
178 matrix[anchor]->setChecked(
true);