void View::DrawProportFigures(DeviceContext *dc, int x, int y, int num, int numBase, Staff *staff) { assert(dc); assert(staff); int ynum = 0, yden = 0; int textSize = PROPRT_SIZE_FACTOR * staff->m_drawingStaffSize; std::wstring wtext; if (numBase) { ynum = y - (m_doc->GetDrawingUnit(textSize) * 2); yden = ynum - (m_doc->GetDrawingDoubleUnit(textSize) * 2); } else ynum = y - (m_doc->GetDrawingUnit(textSize) * 4); if (numBase > 9 || num > 9) { x += m_doc->GetDrawingUnit(textSize) * 2; } dc->SetFont(m_doc->GetDrawingSmuflFont(textSize, false)); wtext = IntToTimeSigFigures(num); DrawSmuflString(dc, x, ynum, wtext, true, textSize); // true = center if (numBase) { wtext = IntToTimeSigFigures(numBase); DrawSmuflString(dc, x, yden, wtext, true, textSize); // true = center } dc->ResetFont(); return; }
void View::DrawTupletPostponed(DeviceContext *dc, Tuplet *tuplet, Layer *layer, Staff *staff) { assert(dc); assert(tuplet); assert(layer); assert(staff); if ((tuplet->GetBracketVisible() == BOOLEAN_false) && (tuplet->GetNumVisible() == BOOLEAN_false)) { tuplet->SetEmptyBB(); return; } tuplet->ResetList(tuplet); int txt_length = 0; int txt_height = 0; std::wstring notes; // dc->SetFont(m_doc->GetDrawingSmuflFont(staff->m_drawingStaffSize, tuplet->IsCueSize())); if (tuplet->GetNum() > 0) { notes = IntToTupletFigures((short int)tuplet->GetNum()); dc->GetSmuflTextExtent(notes, &txt_length, &txt_height); } Point start, end, center; data_STEMDIRECTION direction = GetTupletCoordinates(tuplet, layer, &start, &end, ¢er); // Calculate position for number 0x82 // since the number is slanted, move the center left // by 4 pixels so it seems more centered to the eye int txt_x = center.x - (txt_length / 2); // we need to move down the figure of half of it height, which is about an accid width; // also, cue size is not supported. Does it has to? int txt_y = center.y - m_doc->GetGlyphWidth(SMUFL_E262_accidentalSharp, staff->m_drawingStaffSize, tuplet->IsCueSize()); if (tuplet->GetNum() && (tuplet->GetNumVisible() != BOOLEAN_false)) { DrawSmuflString(dc, txt_x, txt_y, notes, false, staff->m_drawingStaffSize); } dc->ResetFont(); // Nothing to do if the bracket is not visible if (tuplet->GetBracketVisible() == BOOLEAN_false) { return; } int verticalLine = m_doc->GetDrawingUnit(100); dc->SetPen(m_currentColour, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize), AxSOLID); // Start is 0 when no line is necessary (i.e. beamed notes) if (start.x > 0) { // Draw the bracket, interrupt where the number is // get the slope double m = (double)(start.y - end.y) / (double)(start.x - end.x); // x = 10 pixels before the number int x = txt_x - 40; // xa = just after, the number is abundant so I do not add anything int xa = txt_x + txt_length + 20; // calculate the y coords in the slope double y1 = (double)start.y + m * (x - (double)start.x); double y2 = (double)start.y + m * (xa - (double)start.x); if (tuplet->GetNumVisible() == BOOLEAN_false) { // one single line dc->DrawLine(start.x, ToDeviceContextY(start.y), end.x, ToDeviceContextY((int)y1)); } else { // first line dc->DrawLine(start.x, ToDeviceContextY(start.y), (int)x, ToDeviceContextY((int)y1)); // second line after gap dc->DrawLine((int)xa, ToDeviceContextY((int)y2), end.x, ToDeviceContextY(end.y)); } // vertical bracket lines if (direction == STEMDIRECTION_up) { dc->DrawLine(start.x, ToDeviceContextY(start.y), start.x, ToDeviceContextY(start.y - verticalLine)); dc->DrawLine(end.x, ToDeviceContextY(end.y), end.x, ToDeviceContextY(end.y - verticalLine)); } else { dc->DrawLine(start.x, ToDeviceContextY(start.y), start.x, ToDeviceContextY(start.y + verticalLine)); dc->DrawLine(end.x, ToDeviceContextY(end.y), end.x, ToDeviceContextY(end.y + verticalLine)); } } dc->ResetPen(); }
void View::DrawTupletPostponed(DeviceContext *dc, Tuplet *tuplet, Layer *layer, Staff *staff) { assert(dc); assert(tuplet); assert(layer); assert(staff); if ((tuplet->GetBracketVisible() == BOOLEAN_false) && (tuplet->GetNumVisible() == BOOLEAN_false)) { tuplet->SetEmptyBB(); return; } tuplet->ResetList(tuplet); TextExtend extend; std::wstring notes; Point start, end, center; data_STEMDIRECTION direction = GetTupletCoordinates(tuplet, layer, &start, &end, ¢er); int x1 = center.x, x2 = center.x; // draw tuplet numerator if ((tuplet->GetNum() > 0) && (tuplet->GetNumVisible() != BOOLEAN_false)) { bool drawingCueSize = tuplet->GetDrawingCueSize(); dc->SetFont(m_doc->GetDrawingSmuflFont(staff->m_drawingStaffSize, drawingCueSize)); notes = IntToTupletFigures((short int)tuplet->GetNum()); if (tuplet->GetNumFormat() == tupletVis_NUMFORMAT_ratio) { notes.push_back(SMUFL_E88A_tupletColon); notes = notes + IntToTupletFigures((short int)tuplet->GetNumbase()); } dc->GetSmuflTextExtent(notes, &extend); // Calculate position for number 0x82 // since the number is slanted, move the center left int txtX = x1 - (extend.m_width / 2); // and move it further, when it is under the stave if (direction == STEMDIRECTION_down) { txtX -= staff->m_drawingStaffSize; } // we need to move down the figure of half of it height, which is about an accid width; // also, cue size is not supported. Does it has to? int txt_y = center.y - m_doc->GetGlyphWidth(SMUFL_E262_accidentalSharp, staff->m_drawingStaffSize, drawingCueSize); DrawSmuflString(dc, txtX, txt_y, notes, false, staff->m_drawingStaffSize); // x1 = 10 pixels before the number x1 = ((txtX - 40) > start.x) ? txtX - 40 : start.x; // x2 = just after, the number is abundant so I do not add anything x2 = txtX + extend.m_width + 20; dc->ResetFont(); } // Nothing to do if the bracket is not visible if (tuplet->GetBracketVisible() == BOOLEAN_false) { return; } // If all tuplets beamed draw no bracket by default if (OneBeamInTuplet(tuplet) && !(tuplet->GetBracketVisible() == BOOLEAN_true)) { return; } int verticalLine = m_doc->GetDrawingUnit(100); dc->SetPen(m_currentColour, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize), AxSOLID); // Draw the bracket, interrupt where the number is // get the slope double m = (double)(start.y - end.y) / (double)(start.x - end.x); // calculate the y coords in the slope double y1 = (double)start.y + m * (x1 - (double)start.x); double y2 = (double)start.y + m * (x2 - (double)start.x); if (tuplet->GetNumVisible() == BOOLEAN_false) { // one single line dc->DrawLine(start.x, ToDeviceContextY(start.y), end.x, ToDeviceContextY(end.y)); } else { // first line dc->DrawLine(start.x, ToDeviceContextY(start.y), (int)x1, ToDeviceContextY((int)y1)); // second line after gap dc->DrawLine((int)x2, ToDeviceContextY((int)y2), end.x, ToDeviceContextY(end.y)); } // vertical bracket lines if (direction == STEMDIRECTION_up) { dc->DrawLine(start.x + m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(start.y), start.x + m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(start.y - verticalLine)); dc->DrawLine(end.x - m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(end.y), end.x - m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(end.y - verticalLine)); } else { dc->DrawLine(start.x + m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(start.y), start.x + m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(start.y + verticalLine)); dc->DrawLine(end.x - m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(end.y), end.x - m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(end.y + verticalLine)); } dc->ResetPen(); }