/* insert a duplicate note and tie to it */ void tie_notes_key (GtkAction* action, DenemoScriptParam *param) { DenemoObject *curObj = (DenemoObject *) (Denemo.project->movement->currentobject ? Denemo.project->movement->currentobject->data : NULL); /* Equals - toggle whether this note is tied */ if (curObj && curObj->type == CHORD && ((chord *) curObj->object)->notes) { if (Denemo.project->movement->cursor_appending) { DenemoMovement *si = Denemo.project->movement; gint tickspermeasure = WHOLE_NUMTICKS * ((DenemoMeasure*)si->currentmeasure->data)->timesig->time1 / ((DenemoMeasure*)si->currentmeasure->data)->timesig->time2; si->cursoroffend = (curObj->starttickofnextnote >= tickspermeasure); insertion_point (Denemo.project->movement); object_insert (Denemo.project, dnm_clone_object (curObj)); movecursorleft (NULL, NULL); movecursorleft (NULL, NULL); toggle_tie (NULL, NULL); movecursorright (NULL, NULL); movecursorright (NULL, NULL); } else { object_insert (Denemo.project, dnm_clone_object (curObj)); movecursorleft (NULL, NULL); ((chord *) ((DenemoObject *)Denemo.project->movement->currentobject->data)->object)->is_tied = 1; movecursorright (NULL, NULL); movecursorright (NULL, NULL); } } }
void Box::ReorderChild( const Widget::Ptr& widget, std::size_t position ) { ChildrenCont::iterator iter( std::find( m_children.begin(), m_children.end(), widget ) ); if( iter == m_children.end() ) { return; } position = std::min( position, m_children.size() - 1 ); ChildrenCont::iterator insertion_point( m_children.begin() ); std::advance( insertion_point, position ); m_children.insert( insertion_point, *iter ); m_children.erase( iter ); Refresh(); AllocateChildren(); }
QStandardItem* mail_item_model::insert_msg_sorted(mail_msg* msg, QStandardItem* parent, int column, Qt::SortOrder order) { DBG_PRINTF(4, "insert_msg_sorted order=%d column=%d", (int)order, column); QList<QStandardItem*> items; create_row(msg, items); QStandardItem* item = items[0]; int row = insertion_point(items, parent, column, order); DBG_PRINTF(4, "insertion point=%d", row); if (parent) { parent->insertRow(row, items); } else { insertRow(row, items); } items_map.insert(msg->get_id(), item); return item; }
void triplet_start (GtkAction* action, DenemoScriptParam *param) { insertion_point (Denemo.project->movement); object_insert (Denemo.project, tuplet_open_new (2, 3)); }
/** * TODO items for text: * 1) Test multi-line text rendering * 2) Accept color codes during text rendering in the form of \Cx (x is the index color) * 3) Font selection * For testing there is a lua script * * We can increase performance if we pre-calculate some values and cache them so that we * don't have to keep calling text_extends and do some of the calculations * also we shouldn't draw text smaller then XX pixels when rendered on screen. */ void LCVText::draw(LcPainter& painter, const LcDrawOptions &options, const lc::geo::Area& rect) const { bool modified = false; painter.font_size(height()); painter.select_font_face("stick3.ttf"); TextExtends te = painter.text_extends(text_value().c_str()); double alignX = 0.0; double alignY = 0.0; // double alignX, alignY; // The idea of height() * .2 is just a average basline offset. Don't this value to seriously, // we could get it from font exists but that sounds over exaggerating for the moment. switch (valign()) { case lc::TextConst::VAMiddle: alignX += 0.0; alignY += -height() / 2. + (height() * .2); break; case lc::TextConst::VABottom: alignX += 0.0; alignY += -height() + (height() * .2); break; case lc::TextConst::VABaseline: alignX += 0.0; alignY += 0.0; break; case lc::TextConst::VATop: alignX += 0.0; alignY += 0.0 + (height() * .2); break; default: break; } // Horizontal Align: switch (halign()) { case lc::TextConst::HALeft: alignX += - te.width; alignY += 0.; break; case lc::TextConst::HACenter: alignX += - te.width / 2.0; alignY += 0.; break; case lc::TextConst::HAMiddle: alignX += - te.width / 2.0; alignY += 0.; break; case lc::TextConst::HARight: alignX += 0.; alignY += 0.; break; default: break; } painter.save(); painter.translate(insertion_point().x(), -insertion_point().y()); painter.rotate(-angle()); painter.translate(alignX, -alignY); painter.move_to(0., 0.); painter.text(text_value().c_str()); painter.stroke(); painter.restore(); if (modified) { painter.restore(); } }
void LCVText::draw(LcPainter* painter, LcDrawOptions* options, const lc::geo::Area& rect) const { bool modified = false; modified = true; painter->save(); if (this->selected()) { painter->source_rgba( options->selectedColor().red(), options->selectedColor().green(), options->selectedColor().blue(), options->selectedColor().alpha() ); } else { painter->source_rgba( layers().front()->color().red(), layers().front()->color().green(), layers().front()->color().blue(), layers().front()->color().alpha() ); } // double letterSpacing = 3.0; // double wordSpacing = 6.75; // double lineSpacingFactor = 1.0; // lc::geo::Coordinate letterPos = lc::geo::Coordinate(0.0, -9.0); // lc::geo::Coordinate letterSpace = lc::geo::Coordinate(letterSpacing, 0.0); // lc::geo::Coordinate space = lc::geo::Coordinate(wordSpacing, 0.0); lc::geo::Coordinate textSize(Text::boundingBox().maxP() - Text::boundingBox().minP()); // Vertical Align: double vSize = 9.0; double alignX = insertion_point().x(); double alignY = insertion_point().y(); // double alignX, alignY; switch (valign()) { case Text::VAMiddle: alignX += 0.0; alignY += vSize / 2.0; break; case Text::VABottom: alignX += 0.0; alignY += vSize + 3; break; case Text::VABaseline: alignX += 0.0; alignY += vSize; break; default: break; } // Horizontal Align: switch (halign()) { case Text::HAMiddle: alignX += (0. - textSize.x() / 2.0); alignY += (0. - (vSize + textSize.y() / 2.0 + Text::boundingBox().minP().y())); break; case Text::HACenter: alignX += (0. - textSize.x() / 2.0); alignY += alignY + (0.0); break; case Text::HARight: alignX += alignX + (0. - textSize.x()); alignY += alignY + (0.0); break; default: break; } double angle_; // Rotate: if (halign() == Text::HAAligned || halign() == Text::HAFit) { angle_ = insertion_point().angleTo(second_point()); } else { angle_ = angle(); } const char* str = text_value().c_str(); painter->text(alignX, alignY, str, angle_, height()); painter->stroke(); if (modified) { painter->restore(); } }