comparison view/Pane.cpp @ 137:10a82b2bbb8b

* experiment with finer zoom level changes when using h thumbwheel
author Chris Cannam
date Tue, 22 Aug 2006 14:18:28 +0000
parents a859b87162ca
children 4d132a06db9b
comparison
equal deleted inserted replaced
136:a859b87162ca 137:10a82b2bbb8b
108 108
109 int count = 0; 109 int count = 0;
110 int current = 0; 110 int current = 0;
111 int level = 1; 111 int level = 1;
112 112
113 while (true) { 113 //!!! pull out into function (presumably in View)
114 if (getZoomLevel() == level) current = count; 114 bool haveConstraint = false;
115 int newLevel = getZoomConstraintBlockSize(level + 1, 115 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end();
116 ZoomConstraint::RoundUp); 116 ++i) {
117 if (newLevel == level) break; 117 if ((*i)->getZoomConstraint() && !(*i)->supportsOtherZoomLevels()) {
118 level = newLevel; 118 haveConstraint = true;
119 if (++count == 50) break; 119 break;
120 }
121 }
122
123 if (haveConstraint) {
124 while (true) {
125 if (getZoomLevel() == level) current = count;
126 int newLevel = getZoomConstraintBlockSize(level + 1,
127 ZoomConstraint::RoundUp);
128 if (newLevel == level) break;
129 level = newLevel;
130 if (++count == 50) break;
131 }
132 } else {
133 // if we have no particular constraints, we can really spread out
134 while (true) {
135 if (getZoomLevel() >= level) current = count;
136 int step = level / 10;
137 int pwr = 0;
138 while (step > 0) {
139 ++pwr;
140 step /= 2;
141 }
142 step = 1;
143 while (pwr > 0) {
144 step *= 2;
145 --pwr;
146 }
147 std::cerr << level << std::endl;
148 level += step;
149 if (++count == 100 || level > 262144) break;
150 }
120 } 151 }
121 152
122 // std::cerr << "Have " << count << " zoom levels" << std::endl; 153 // std::cerr << "Have " << count << " zoom levels" << std::endl;
123 154
124 m_hthumb->setMinimumValue(0); 155 m_hthumb->setMinimumValue(0);
1173 } 1204 }
1174 1205
1175 void 1206 void
1176 Pane::horizontalThumbwheelMoved(int value) 1207 Pane::horizontalThumbwheelMoved(int value)
1177 { 1208 {
1209 //!!! dupe with updateHeadsUpDisplay
1210
1178 int count = 0; 1211 int count = 0;
1179 int level = 1; 1212 int level = 1;
1180 while (true) { 1213
1181 if (m_hthumb->getMaximumValue() - value == count) break; 1214
1182 int newLevel = getZoomConstraintBlockSize(level + 1, 1215 //!!! pull out into function (presumably in View)
1183 ZoomConstraint::RoundUp); 1216 bool haveConstraint = false;
1184 if (newLevel == level) break; 1217 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end();
1185 level = newLevel; 1218 ++i) {
1186 ++count; 1219 if ((*i)->getZoomConstraint() && !(*i)->supportsOtherZoomLevels()) {
1187 } 1220 haveConstraint = true;
1188 1221 break;
1189 // std::cerr << "new level is " << level << std::endl; 1222 }
1223 }
1224
1225 if (haveConstraint) {
1226 while (true) {
1227 if (m_hthumb->getMaximumValue() - value == count) break;
1228 int newLevel = getZoomConstraintBlockSize(level + 1,
1229 ZoomConstraint::RoundUp);
1230 if (newLevel == level) break;
1231 level = newLevel;
1232 if (++count == 50) break;
1233 }
1234 } else {
1235 while (true) {
1236 if (m_hthumb->getMaximumValue() - value == count) break;
1237 int step = level / 10;
1238 int pwr = 0;
1239 while (step > 0) {
1240 ++pwr;
1241 step /= 2;
1242 }
1243 step = 1;
1244 while (pwr > 0) {
1245 step *= 2;
1246 --pwr;
1247 }
1248 // std::cerr << level << std::endl;
1249 level += step;
1250 if (++count == 100 || level > 262144) break;
1251 }
1252 }
1253
1254 std::cerr << "new level is " << level << std::endl;
1190 setZoomLevel(level); 1255 setZoomLevel(level);
1191 } 1256 }
1192 1257
1193 void 1258 void
1194 Pane::verticalThumbwheelMoved(int value) 1259 Pane::verticalThumbwheelMoved(int value)