svgui
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2006 Chris Cannam and QMUL. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #include "ViewManager.h" 00017 #include "base/AudioPlaySource.h" 00018 #include "base/RealTime.h" 00019 #include "data/model/Model.h" 00020 #include "widgets/CommandHistory.h" 00021 #include "View.h" 00022 #include "Overview.h" 00023 00024 #include <QSettings> 00025 #include <QApplication> 00026 00027 #include <iostream> 00028 00029 //#define DEBUG_VIEW_MANAGER 1 00030 00031 ViewManager::ViewManager() : 00032 m_playSource(0), 00033 m_globalCentreFrame(0), 00034 m_globalZoom(1024), 00035 m_playbackFrame(0), 00036 m_playbackModel(0), 00037 m_mainModelSampleRate(0), 00038 m_lastLeft(0), 00039 m_lastRight(0), 00040 m_inProgressExclusive(true), 00041 m_toolMode(NavigateMode), 00042 m_playLoopMode(false), 00043 m_playSelectionMode(false), 00044 m_playSoloMode(false), 00045 m_alignMode(false), 00046 m_overlayMode(StandardOverlays), 00047 m_zoomWheelsEnabled(true), 00048 m_showCentreLine(true), 00049 m_illuminateLocalFeatures(true), 00050 m_showWorkTitle(false), 00051 m_showDuration(true), 00052 m_lightPalette(QApplication::palette()), 00053 m_darkPalette(QApplication::palette()) 00054 { 00055 QSettings settings; 00056 settings.beginGroup("MainWindow"); 00057 m_overlayMode = OverlayMode 00058 (settings.value("overlay-mode", int(m_overlayMode)).toInt()); 00059 00060 if (m_overlayMode != NoOverlays && 00061 m_overlayMode != StandardOverlays && 00062 m_overlayMode != AllOverlays) { 00063 m_overlayMode = StandardOverlays; 00064 } 00065 00066 m_zoomWheelsEnabled = 00067 settings.value("zoom-wheels-enabled", m_zoomWheelsEnabled).toBool(); 00068 m_showCentreLine = 00069 settings.value("show-centre-line", m_showCentreLine).toBool(); 00070 settings.endGroup(); 00071 00072 if (getGlobalDarkBackground()) { 00073 /* 00074 cerr << "dark palette:" << endl; 00075 cerr << "window = " << QApplication::palette().color(QPalette::Window).name() << endl; 00076 cerr << "windowtext = " << QApplication::palette().color(QPalette::WindowText).name() << endl; 00077 cerr << "base = " << QApplication::palette().color(QPalette::Base).name() << endl; 00078 cerr << "alternatebase = " << QApplication::palette().color(QPalette::AlternateBase).name() << endl; 00079 cerr << "text = " << QApplication::palette().color(QPalette::Text).name() << endl; 00080 cerr << "button = " << QApplication::palette().color(QPalette::Button).name() << endl; 00081 cerr << "buttontext = " << QApplication::palette().color(QPalette::ButtonText).name() << endl; 00082 cerr << "brighttext = " << QApplication::palette().color(QPalette::BrightText).name() << endl; 00083 cerr << "light = " << QApplication::palette().color(QPalette::Light).name() << endl; 00084 cerr << "dark = " << QApplication::palette().color(QPalette::Dark).name() << endl; 00085 cerr << "mid = " << QApplication::palette().color(QPalette::Mid).name() << endl; 00086 */ 00087 m_lightPalette = QPalette(QColor("#000000"), // WindowText 00088 QColor("#dddfe4"), // Button 00089 QColor("#ffffff"), // Light 00090 QColor("#555555"), // Dark 00091 QColor("#c7c7c7"), // Mid 00092 QColor("#000000"), // Text 00093 QColor("#ffffff"), // BrightText 00094 QColor("#ffffff"), // Base 00095 QColor("#efefef")); // Window 00096 00097 00098 } else { 00099 /* 00100 cerr << "light palette:" << endl; 00101 cerr << "window = " << QApplication::palette().color(QPalette::Window).name() << endl; 00102 cerr << "windowtext = " << QApplication::palette().color(QPalette::WindowText).name() << endl; 00103 cerr << "base = " << QApplication::palette().color(QPalette::Base).name() << endl; 00104 cerr << "alternatebase = " << QApplication::palette().color(QPalette::AlternateBase).name() << endl; 00105 cerr << "text = " << QApplication::palette().color(QPalette::Text).name() << endl; 00106 cerr << "button = " << QApplication::palette().color(QPalette::Button).name() << endl; 00107 cerr << "buttontext = " << QApplication::palette().color(QPalette::ButtonText).name() << endl; 00108 cerr << "brighttext = " << QApplication::palette().color(QPalette::BrightText).name() << endl; 00109 cerr << "light = " << QApplication::palette().color(QPalette::Light).name() << endl; 00110 cerr << "dark = " << QApplication::palette().color(QPalette::Dark).name() << endl; 00111 cerr << "mid = " << QApplication::palette().color(QPalette::Mid).name() << endl; 00112 */ 00113 m_darkPalette = QPalette(QColor("#ffffff"), // WindowText 00114 QColor("#3e3e3e"), // Button 00115 QColor("#808080"), // Light 00116 QColor("#1e1e1e"), // Dark 00117 QColor("#404040"), // Mid 00118 QColor("#ffffff"), // Text 00119 QColor("#ffffff"), // BrightText 00120 QColor("#000000"), // Base 00121 QColor("#202020")); // Window 00122 } 00123 } 00124 00125 ViewManager::~ViewManager() 00126 { 00127 } 00128 00129 int 00130 ViewManager::getGlobalCentreFrame() const 00131 { 00132 #ifdef DEBUG_VIEW_MANAGER 00133 cerr << "ViewManager::getGlobalCentreFrame: returning " << m_globalCentreFrame << endl; 00134 #endif 00135 return m_globalCentreFrame; 00136 } 00137 00138 void 00139 ViewManager::setGlobalCentreFrame(int f) 00140 { 00141 #ifdef DEBUG_VIEW_MANAGER 00142 cerr << "ViewManager::setGlobalCentreFrame to " << f << endl; 00143 #endif 00144 m_globalCentreFrame = f; 00145 emit globalCentreFrameChanged(f); 00146 } 00147 00148 int 00149 ViewManager::getGlobalZoom() const 00150 { 00151 #ifdef DEBUG_VIEW_MANAGER 00152 cerr << "ViewManager::getGlobalZoom: returning " << m_globalZoom << endl; 00153 #endif 00154 return m_globalZoom; 00155 } 00156 00157 int 00158 ViewManager::getPlaybackFrame() const 00159 { 00160 if (m_playSource && m_playSource->isPlaying()) { 00161 m_playbackFrame = m_playSource->getCurrentPlayingFrame(); 00162 } 00163 return m_playbackFrame; 00164 } 00165 00166 void 00167 ViewManager::setPlaybackFrame(int f) 00168 { 00169 if (m_playbackFrame != f) { 00170 m_playbackFrame = f; 00171 emit playbackFrameChanged(f); 00172 if (m_playSource && m_playSource->isPlaying()) { 00173 m_playSource->play(f); 00174 } 00175 } 00176 } 00177 00178 Model * 00179 ViewManager::getPlaybackModel() const 00180 { 00181 return m_playbackModel; 00182 } 00183 00184 void 00185 ViewManager::setPlaybackModel(Model *model) 00186 { 00187 m_playbackModel = model; 00188 } 00189 00190 int 00191 ViewManager::alignPlaybackFrameToReference(int frame) const 00192 { 00193 #ifdef DEBUG_VIEW_MANAGER 00194 cerr << "ViewManager::alignPlaybackFrameToReference(" << frame << "): playback model is " << m_playbackModel << endl; 00195 #endif 00196 if (!m_playbackModel) { 00197 return frame; 00198 } else { 00199 int f = m_playbackModel->alignToReference(frame); 00200 #ifdef DEBUG_VIEW_MANAGER 00201 cerr << "aligned frame = " << f << endl; 00202 #endif 00203 return f; 00204 } 00205 } 00206 00207 int 00208 ViewManager::alignReferenceToPlaybackFrame(int frame) const 00209 { 00210 #ifdef DEBUG_VIEW_MANAGER 00211 cerr << "ViewManager::alignReferenceToPlaybackFrame(" << frame << "): playback model is " << m_playbackModel << endl; 00212 #endif 00213 if (!m_playbackModel) { 00214 return frame; 00215 } else { 00216 int f = m_playbackModel->alignFromReference(frame); 00217 #ifdef DEBUG_VIEW_MANAGER 00218 cerr << "aligned frame = " << f << endl; 00219 #endif 00220 return f; 00221 } 00222 } 00223 00224 bool 00225 ViewManager::haveInProgressSelection() const 00226 { 00227 return !m_inProgressSelection.isEmpty(); 00228 } 00229 00230 const Selection & 00231 ViewManager::getInProgressSelection(bool &exclusive) const 00232 { 00233 exclusive = m_inProgressExclusive; 00234 return m_inProgressSelection; 00235 } 00236 00237 void 00238 ViewManager::setInProgressSelection(const Selection &selection, bool exclusive) 00239 { 00240 m_inProgressExclusive = exclusive; 00241 m_inProgressSelection = selection; 00242 if (exclusive) clearSelections(); 00243 emit inProgressSelectionChanged(); 00244 } 00245 00246 void 00247 ViewManager::clearInProgressSelection() 00248 { 00249 m_inProgressSelection = Selection(); 00250 emit inProgressSelectionChanged(); 00251 } 00252 00253 const MultiSelection & 00254 ViewManager::getSelection() const 00255 { 00256 return m_selections; 00257 } 00258 00259 const MultiSelection::SelectionList & 00260 ViewManager::getSelections() const 00261 { 00262 return m_selections.getSelections(); 00263 } 00264 00265 void 00266 ViewManager::setSelection(const Selection &selection) 00267 { 00268 MultiSelection ms(m_selections); 00269 ms.setSelection(selection); 00270 setSelections(ms); 00271 } 00272 00273 void 00274 ViewManager::addSelection(const Selection &selection) 00275 { 00276 MultiSelection ms(m_selections); 00277 ms.addSelection(selection); 00278 setSelections(ms); 00279 } 00280 00281 void 00282 ViewManager::addSelectionQuietly(const Selection &selection) 00283 { 00284 MultiSelection ms(m_selections); 00285 ms.addSelection(selection); 00286 setSelections(ms, true); 00287 } 00288 00289 void 00290 ViewManager::removeSelection(const Selection &selection) 00291 { 00292 MultiSelection ms(m_selections); 00293 ms.removeSelection(selection); 00294 setSelections(ms); 00295 } 00296 00297 void 00298 ViewManager::clearSelections() 00299 { 00300 MultiSelection ms(m_selections); 00301 ms.clearSelections(); 00302 setSelections(ms); 00303 } 00304 00305 void 00306 ViewManager::setSelections(const MultiSelection &ms, bool quietly) 00307 { 00308 if (m_selections.getSelections() == ms.getSelections()) return; 00309 SetSelectionCommand *command = new SetSelectionCommand(this, ms); 00310 CommandHistory::getInstance()->addCommand(command); 00311 if (!quietly) { 00312 emit selectionChangedByUser(); 00313 } 00314 } 00315 00316 int 00317 ViewManager::constrainFrameToSelection(int frame) const 00318 { 00319 MultiSelection::SelectionList sl = getSelections(); 00320 if (sl.empty()) return frame; 00321 00322 for (MultiSelection::SelectionList::const_iterator i = sl.begin(); 00323 i != sl.end(); ++i) { 00324 00325 if (frame < i->getEndFrame()) { 00326 if (frame < i->getStartFrame()) { 00327 return i->getStartFrame(); 00328 } else { 00329 return frame; 00330 } 00331 } 00332 } 00333 00334 return sl.begin()->getStartFrame(); 00335 } 00336 00337 void 00338 ViewManager::signalSelectionChange() 00339 { 00340 emit selectionChanged(); 00341 } 00342 00343 ViewManager::SetSelectionCommand::SetSelectionCommand(ViewManager *vm, 00344 const MultiSelection &ms) : 00345 m_vm(vm), 00346 m_oldSelection(vm->m_selections), 00347 m_newSelection(ms) 00348 { 00349 } 00350 00351 ViewManager::SetSelectionCommand::~SetSelectionCommand() { } 00352 00353 void 00354 ViewManager::SetSelectionCommand::execute() 00355 { 00356 m_vm->m_selections = m_newSelection; 00357 m_vm->signalSelectionChange(); 00358 } 00359 00360 void 00361 ViewManager::SetSelectionCommand::unexecute() 00362 { 00363 m_vm->m_selections = m_oldSelection; 00364 m_vm->signalSelectionChange(); 00365 } 00366 00367 QString 00368 ViewManager::SetSelectionCommand::getName() const 00369 { 00370 if (m_newSelection.getSelections().empty()) return tr("Clear Selection"); 00371 if (m_newSelection.getSelections().size() > 1) return tr("Select Multiple Regions"); 00372 else return tr("Select Region"); 00373 } 00374 00375 Selection 00376 ViewManager::getContainingSelection(int frame, bool defaultToFollowing) const 00377 { 00378 return m_selections.getContainingSelection(frame, defaultToFollowing); 00379 } 00380 00381 void 00382 ViewManager::setToolMode(ToolMode mode) 00383 { 00384 m_toolMode = mode; 00385 00386 emit toolModeChanged(); 00387 00388 switch (mode) { 00389 case NavigateMode: emit activity(tr("Enter Navigate mode")); break; 00390 case SelectMode: emit activity(tr("Enter Select mode")); break; 00391 case EditMode: emit activity(tr("Enter Edit mode")); break; 00392 case DrawMode: emit activity(tr("Enter Draw mode")); break; 00393 case EraseMode: emit activity(tr("Enter Erase mode")); break; 00394 case MeasureMode: emit activity(tr("Enter Measure mode")); break; 00395 case NoteEditMode: emit activity(tr("Enter NoteEdit mode")); break; // GF: NoteEditMode activity (I'm not yet certain why we need to emit this.) 00396 }; 00397 } 00398 00399 ViewManager::ToolMode 00400 ViewManager::getToolModeFor(const View *v) const 00401 { 00402 if (m_toolModeOverrides.find(v) == m_toolModeOverrides.end()) { 00403 return getToolMode(); 00404 } else { 00405 return m_toolModeOverrides.find(v)->second; 00406 } 00407 } 00408 00409 void 00410 ViewManager::setToolModeFor(const View *v, ToolMode mode) 00411 { 00412 m_toolModeOverrides[v] = mode; 00413 } 00414 00415 void 00416 ViewManager::clearToolModeOverrides() 00417 { 00418 m_toolModeOverrides.clear(); 00419 } 00420 00421 void 00422 ViewManager::setPlayLoopMode(bool mode) 00423 { 00424 if (m_playLoopMode != mode) { 00425 00426 m_playLoopMode = mode; 00427 00428 emit playLoopModeChanged(); 00429 emit playLoopModeChanged(mode); 00430 00431 if (mode) emit activity(tr("Switch on Loop mode")); 00432 else emit activity(tr("Switch off Loop mode")); 00433 } 00434 } 00435 00436 void 00437 ViewManager::setPlaySelectionMode(bool mode) 00438 { 00439 if (m_playSelectionMode != mode) { 00440 00441 m_playSelectionMode = mode; 00442 00443 emit playSelectionModeChanged(); 00444 emit playSelectionModeChanged(mode); 00445 00446 if (mode) emit activity(tr("Switch on Play Selection mode")); 00447 else emit activity(tr("Switch off Play Selection mode")); 00448 } 00449 } 00450 00451 void 00452 ViewManager::setPlaySoloMode(bool mode) 00453 { 00454 if (m_playSoloMode != mode) { 00455 00456 m_playSoloMode = mode; 00457 00458 emit playSoloModeChanged(); 00459 emit playSoloModeChanged(mode); 00460 00461 if (mode) emit activity(tr("Switch on Play Solo mode")); 00462 else emit activity(tr("Switch off Play Solo mode")); 00463 } 00464 } 00465 00466 void 00467 ViewManager::setAlignMode(bool mode) 00468 { 00469 if (m_alignMode != mode) { 00470 00471 m_alignMode = mode; 00472 00473 emit alignModeChanged(); 00474 emit alignModeChanged(mode); 00475 00476 if (mode) emit activity(tr("Switch on Alignment mode")); 00477 else emit activity(tr("Switch off Alignment mode")); 00478 } 00479 } 00480 00481 int 00482 ViewManager::getPlaybackSampleRate() const 00483 { 00484 if (m_playSource) { 00485 return m_playSource->getSourceSampleRate(); 00486 } 00487 return 0; 00488 } 00489 00490 int 00491 ViewManager::getOutputSampleRate() const 00492 { 00493 if (m_playSource) { 00494 return m_playSource->getTargetSampleRate(); 00495 } 00496 return 0; 00497 } 00498 00499 void 00500 ViewManager::setAudioPlaySource(AudioPlaySource *source) 00501 { 00502 if (!m_playSource) { 00503 QTimer::singleShot(100, this, SLOT(checkPlayStatus())); 00504 } 00505 m_playSource = source; 00506 } 00507 00508 void 00509 ViewManager::playStatusChanged(bool /* playing */) 00510 { 00511 #ifdef DEBUG_VIEW_MANAGER 00512 cerr << "ViewManager::playStatusChanged" << endl; 00513 #endif 00514 checkPlayStatus(); 00515 } 00516 00517 void 00518 ViewManager::checkPlayStatus() 00519 { 00520 if (m_playSource && m_playSource->isPlaying()) { 00521 00522 float left = 0, right = 0; 00523 if (m_playSource->getOutputLevels(left, right)) { 00524 if (left != m_lastLeft || right != m_lastRight) { 00525 emit outputLevelsChanged(left, right); 00526 m_lastLeft = left; 00527 m_lastRight = right; 00528 } 00529 } 00530 00531 m_playbackFrame = m_playSource->getCurrentPlayingFrame(); 00532 00533 #ifdef DEBUG_VIEW_MANAGER 00534 cerr << "ViewManager::checkPlayStatus: Playing, frame " << m_playbackFrame << ", levels " << m_lastLeft << "," << m_lastRight << endl; 00535 #endif 00536 00537 emit playbackFrameChanged(m_playbackFrame); 00538 00539 QTimer::singleShot(20, this, SLOT(checkPlayStatus())); 00540 00541 } else { 00542 00543 if (m_lastLeft != 0.0 || m_lastRight != 0.0) { 00544 emit outputLevelsChanged(0.0, 0.0); 00545 m_lastLeft = 0.0; 00546 m_lastRight = 0.0; 00547 } 00548 00549 #ifdef DEBUG_VIEW_MANAGER 00550 cerr << "ViewManager::checkPlayStatus: Not playing" << endl; 00551 #endif 00552 } 00553 } 00554 00555 bool 00556 ViewManager::isPlaying() const 00557 { 00558 return m_playSource && m_playSource->isPlaying(); 00559 } 00560 00561 void 00562 ViewManager::viewCentreFrameChanged(int f, bool locked, 00563 PlaybackFollowMode mode) 00564 { 00565 View *v = dynamic_cast<View *>(sender()); 00566 00567 #ifdef DEBUG_VIEW_MANAGER 00568 cerr << "ViewManager::viewCentreFrameChanged(" << f << ", " << locked << ", " << mode << "), view is " << v << endl; 00569 #endif 00570 00571 if (locked) { 00572 m_globalCentreFrame = f; 00573 emit globalCentreFrameChanged(f); 00574 } else { 00575 if (v) emit viewCentreFrameChanged(v, f); 00576 } 00577 00578 if (!dynamic_cast<Overview *>(v) || (mode != PlaybackIgnore)) { 00579 if (m_mainModelSampleRate != 0) { 00580 emit activity(tr("Scroll to %1") 00581 .arg(RealTime::frame2RealTime 00582 (f, m_mainModelSampleRate).toText().c_str())); 00583 } 00584 } 00585 00586 if (mode == PlaybackScrollPageWithCentre || 00587 mode == PlaybackScrollContinuous) { 00588 seek(f); 00589 } 00590 } 00591 00592 void 00593 ViewManager::seek(int f) 00594 { 00595 #ifdef DEBUG_VIEW_MANAGER 00596 cerr << "ViewManager::seek(" << f << ")" << endl; 00597 #endif 00598 00599 if (m_playSource && m_playSource->isPlaying()) { 00600 int playFrame = m_playSource->getCurrentPlayingFrame(); 00601 int diff = std::max(f, playFrame) - std::min(f, playFrame); 00602 if (diff > 20000) { 00603 m_playbackFrame = f; 00604 m_playSource->play(f); 00605 #ifdef DEBUG_VIEW_MANAGER 00606 cerr << "ViewManager::considerSeek: reseeking from " << playFrame << " to " << f << endl; 00607 #endif 00608 emit playbackFrameChanged(f); 00609 } 00610 } else { 00611 if (m_playbackFrame != f) { 00612 m_playbackFrame = f; 00613 emit playbackFrameChanged(f); 00614 } 00615 } 00616 } 00617 00618 void 00619 ViewManager::viewZoomLevelChanged(int z, bool locked) 00620 { 00621 View *v = dynamic_cast<View *>(sender()); 00622 00623 if (!v) { 00624 SVDEBUG << "ViewManager::viewZoomLevelChanged: WARNING: sender is not a view" << endl; 00625 return; 00626 } 00627 00629 00630 if (locked) { 00631 m_globalZoom = z; 00632 } 00633 00634 #ifdef DEBUG_VIEW_MANAGER 00635 cerr << "ViewManager::viewZoomLevelChanged(" << v << ", " << z << ", " << locked << ")" << endl; 00636 #endif 00637 00638 emit viewZoomLevelChanged(v, z, locked); 00639 00640 if (!dynamic_cast<Overview *>(v)) { 00641 emit activity(tr("Zoom to %n sample(s) per pixel", "", z)); 00642 } 00643 } 00644 00645 void 00646 ViewManager::setOverlayMode(OverlayMode mode) 00647 { 00648 if (m_overlayMode != mode) { 00649 m_overlayMode = mode; 00650 emit overlayModeChanged(); 00651 emit activity(tr("Change overlay level")); 00652 } 00653 00654 QSettings settings; 00655 settings.beginGroup("MainWindow"); 00656 settings.setValue("overlay-mode", int(m_overlayMode)); 00657 settings.endGroup(); 00658 } 00659 00660 void 00661 ViewManager::setZoomWheelsEnabled(bool enabled) 00662 { 00663 if (m_zoomWheelsEnabled != enabled) { 00664 m_zoomWheelsEnabled = enabled; 00665 emit zoomWheelsEnabledChanged(); 00666 if (enabled) emit activity("Show zoom wheels"); 00667 else emit activity("Hide zoom wheels"); 00668 } 00669 00670 QSettings settings; 00671 settings.beginGroup("MainWindow"); 00672 settings.setValue("zoom-wheels-enabled", m_zoomWheelsEnabled); 00673 settings.endGroup(); 00674 } 00675 00676 void 00677 ViewManager::setShowCentreLine(bool show) 00678 { 00679 if (m_showCentreLine != show) { 00680 m_showCentreLine = show; 00681 emit showCentreLineChanged(); 00682 if (show) emit activity("Show centre line"); 00683 else emit activity("Hide centre line"); 00684 } 00685 00686 QSettings settings; 00687 settings.beginGroup("MainWindow"); 00688 settings.setValue("show-centre-line", int(m_showCentreLine)); 00689 settings.endGroup(); 00690 } 00691 00692 void 00693 ViewManager::setGlobalDarkBackground(bool dark) 00694 { 00695 // also save the current palette, in case the user has changed it 00696 // since construction 00697 if (getGlobalDarkBackground()) { 00698 m_darkPalette = QApplication::palette(); 00699 } else { 00700 m_lightPalette = QApplication::palette(); 00701 } 00702 00703 #ifndef Q_OS_MAC 00704 if (dark) { 00705 QApplication::setPalette(m_darkPalette); 00706 } else { 00707 QApplication::setPalette(m_lightPalette); 00708 } 00709 #endif 00710 } 00711 00712 bool 00713 ViewManager::getGlobalDarkBackground() const 00714 { 00715 bool dark = false; 00716 QColor windowBg = QApplication::palette().color(QPalette::Window); 00717 if (windowBg.red() + windowBg.green() + windowBg.blue() < 384) { 00718 dark = true; 00719 } 00720 return dark; 00721 } 00722