* @brief DopeSheetViewPrivate::drawScale * * Draws the dope sheet's grid and time indicators. */
| 877 | * Draws the dope sheet's grid and time indicators. |
| 878 | */ |
| 879 | void |
| 880 | DopeSheetViewPrivate::drawScale() const |
| 881 | { |
| 882 | running_in_main_thread_and_context(q_ptr); |
| 883 | |
| 884 | QPointF bottomLeft = zoomContext.toZoomCoordinates(0, q_ptr->height() - 1); |
| 885 | QPointF topRight = zoomContext.toZoomCoordinates(q_ptr->width() - 1, 0); |
| 886 | |
| 887 | // Don't attempt to draw a scale on a widget with an invalid height |
| 888 | if (q_ptr->height() <= 1) { |
| 889 | return; |
| 890 | } |
| 891 | |
| 892 | QFontMetrics fm(*_textFont); |
| 893 | const double smallestTickSizePixel = 5.; // tick size (in pixels) for alpha = 0. |
| 894 | const double largestTickSizePixel = 1000.; // tick size (in pixels) for alpha = 1. |
| 895 | |
| 896 | // Retrieve the appropriate settings for drawing |
| 897 | SettingsPtr settings = appPTR->getCurrentSettings(); |
| 898 | double scaleR, scaleG, scaleB; |
| 899 | settings->getDopeSheetEditorScaleColor(&scaleR, &scaleG, &scaleB); |
| 900 | |
| 901 | QColor scaleColor; |
| 902 | scaleColor.setRgbF( Image::clamp(scaleR, 0., 1.), |
| 903 | Image::clamp(scaleG, 0., 1.), |
| 904 | Image::clamp(scaleB, 0., 1.) ); |
| 905 | |
| 906 | // Perform drawing |
| 907 | { |
| 908 | GLProtectAttrib a(GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT); |
| 909 | |
| 910 | glEnable(GL_BLEND); |
| 911 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 912 | |
| 913 | const double rangePixel = q_ptr->width(); |
| 914 | const double range_min = bottomLeft.x(); |
| 915 | const double range_max = topRight.x(); |
| 916 | const double range = range_max - range_min; |
| 917 | double smallTickSize; |
| 918 | bool half_tick; |
| 919 | |
| 920 | ticks_size(range_min, range_max, rangePixel, smallestTickSizePixel, &smallTickSize, &half_tick); |
| 921 | // nothing happens in the dopesheet at a scale smaller than 1 frame |
| 922 | if (smallTickSize < 1.) { |
| 923 | smallTickSize = 1; |
| 924 | half_tick = false; |
| 925 | } |
| 926 | int m1, m2; |
| 927 | const int ticks_max = 1000; |
| 928 | double offset; |
| 929 | |
| 930 | ticks_bounds(range_min, range_max, smallTickSize, half_tick, ticks_max, &offset, &m1, &m2); |
| 931 | std::vector<int> ticks; |
| 932 | ticks_fill(half_tick, ticks_max, m1, m2, &ticks); |
| 933 | |
| 934 | const double smallestTickSize = range * smallestTickSizePixel / rangePixel; |
| 935 | const double largestTickSize = range * largestTickSizePixel / rangePixel; |
| 936 | #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) |
no test coverage detected