LCOV - code coverage report
Current view: top level - src/palette/internal - palettecelliconengine.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 35 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : #include "palettecelliconengine.h"
      23              : 
      24              : #include <QPainter>
      25              : 
      26              : #include "draw/painter.h"
      27              : #include "draw/types/geometry.h"
      28              : 
      29              : #include "engraving/dom/engravingitem.h"
      30              : 
      31              : #include "notationscene/utilities/engravingitempreviewpainter.h"
      32              : 
      33              : using namespace mu::palette;
      34              : using namespace muse::draw;
      35              : using namespace mu::engraving;
      36              : 
      37            0 : PaletteCellIconEngine::PaletteCellIconEngine(PaletteCellConstPtr cell, qreal extraMag)
      38            0 :     : QIconEngine(), m_cell(cell), m_extraMag(extraMag)
      39              : {
      40            0 : }
      41              : 
      42            0 : QIconEngine* PaletteCellIconEngine::clone() const
      43              : {
      44            0 :     return new PaletteCellIconEngine(m_cell, m_extraMag);
      45              : }
      46              : 
      47            0 : void PaletteCellIconEngine::paint(QPainter* qp, const QRect& rect, QIcon::Mode mode, QIcon::State state)
      48              : {
      49            0 :     Painter p(qp, "palettecell");
      50            0 :     p.save();
      51            0 :     p.setAntialiasing(true);
      52            0 :     paintCell(p, RectF::fromQRectF(rect), mode == QIcon::Selected, state == QIcon::On);
      53            0 :     p.restore();
      54            0 : }
      55              : 
      56            0 : void PaletteCellIconEngine::paintCell(Painter& painter, const RectF& rect, bool selected, bool current) const
      57              : {
      58            0 :     paintBackground(painter, rect, selected, current);
      59              : 
      60            0 :     if (!m_cell) {
      61            0 :         return;
      62              :     }
      63              : 
      64            0 :     EngravingItem* element = m_cell->element.get();
      65            0 :     if (!element) {
      66            0 :         return;
      67              :     }
      68              : 
      69            0 :     notation::EngravingItemPreviewPainter::PaintParams params;
      70            0 :     params.painter = &painter;
      71              : 
      72            0 :     params.color = configuration()->elementsColor();
      73              : 
      74            0 :     params.mag = m_extraMag * m_cell->mag;
      75            0 :     params.xoffset = m_cell->xoffset;
      76            0 :     params.yoffset = m_cell->yoffset;
      77              : 
      78            0 :     params.rect = rect;
      79            0 :     params.spatium = configuration()->paletteSpatium() * params.mag;
      80              : 
      81              :     //! NOTE: Slight hack - we can now specify exactly now many staff lines we want...
      82            0 :     params.numStaffLines = m_cell->drawStaff ? 5 : 0;
      83              : 
      84            0 :     notation::EngravingItemPreviewPainter::paintPreview(engravingRender(), element, params);
      85              : }
      86              : 
      87            0 : void PaletteCellIconEngine::paintBackground(Painter& painter, const RectF& rect, bool selected, bool current) const
      88              : {
      89            0 :     if (current || selected) {
      90            0 :         QColor c(configuration()->accentColor());
      91            0 :         c.setAlpha(selected ? 100 : 60);
      92            0 :         painter.fillRect(rect, c);
      93              :     }
      94            0 : }
        

Generated by: LCOV version 2.0-1