void build_democontent(int parent) { // some persistent variables for demonstration static float progress1 = 0.25f; static float progress2 = 0.75f; static int option1 = 1; static int option2 = 0; static int option3 = 0; int col = column(); uiInsert(parent, col); uiSetMargins(col, 10, 10, 10, 10); uiSetLayout(col, UI_TOP|UI_HFILL); column_append(col, button(BND_ICON_GHOST, "Item 1", demohandler)); if (option3) column_append(col, button(BND_ICON_GHOST, "Item 2", demohandler)); { int h = column_append(col, hbox()); hgroup_append(h, radio(BND_ICON_GHOST, "Item 3.0", &enum1)); if (option2) uiSetMargins(hgroup_append_fixed(h, radio(BND_ICON_REC, NULL, &enum1)), -1,0,0,0); uiSetMargins(hgroup_append_fixed(h, radio(BND_ICON_PLAY, NULL, &enum1)), -1,0,0,0); uiSetMargins(hgroup_append(h, radio(BND_ICON_GHOST, "Item 3.3", &enum1)), -1,0,0,0); } { int rows = column_append(col, row()); int coll = row_append(rows, vgroup()); vgroup_append(coll, label(-1, "Items 4.0:")); coll = vgroup_append(coll, vbox()); vgroup_append(coll, button(BND_ICON_GHOST, "Item 4.0.0", demohandler)); uiSetMargins(vgroup_append(coll, button(BND_ICON_GHOST, "Item 4.0.1", demohandler)),0,-2,0,0); int colr = row_append(rows, vgroup()); uiSetMargins(colr, 8, 0, 0, 0); uiSetFrozen(colr, option1); vgroup_append(colr, label(-1, "Items 4.1:")); colr = vgroup_append(colr, vbox()); vgroup_append(colr, slider("Item 4.1.0", &progress1)); uiSetMargins(vgroup_append(colr, slider("Item 4.1.1", &progress2)),0,-2,0,0); } column_append(col, button(BND_ICON_GHOST, "Item 5", NULL)); static char textbuffer[1024] = "The quick brown fox."; column_append(col, textbox(textbuffer, 1024)); column_append(col, check("Frozen", &option1)); column_append(col, check("Item 7", &option2)); column_append(col, check("Item 8", &option3)); }
int makeLayout(DisjointBoxLayout& a_dbl, const Box& a_domain) { ParmParse pp; int eekflag= 0; int ipieces; ipieces = Max(ipieces, 1); int maxsize; pp.get("maxboxsize",maxsize); Vector<Box> vbox(1, a_domain); domainSplit(a_domain, vbox, maxsize); if (eekflag != 0) { pout() << "problem in domainsplit" << endl; return eekflag; } Vector<int> procAssign; eekflag = LoadBalance(procAssign,vbox); if (eekflag != 0) { pout() << "problem in loadbalance" << endl; return eekflag; } a_dbl.define(vbox, procAssign); return eekflag; }
PolyGlyph* LayoutKit::vbox( Glyph* g1, Glyph* g2, Glyph* g3, Glyph* g4, Glyph* g5, Glyph* g6, Glyph* g7, Glyph* g8, Glyph* g9, Glyph* g10 ) const { return LayoutKitImpl::add( vbox(10), g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 ); }
void System::setInstrumentNames(bool longName) { // // remark: add/remove instrument names is not undo/redoable // as add/remove of systems is not undoable // if (vbox()) // ignore vbox return; if (!score()->showInstrumentNames() || (score()->styleB(StyleIdx::hideInstrumentNameIfOneInstrument) && score()->parts().size() == 1)) { for (SysStaff* staff : _staves) { foreach (InstrumentName* t, staff->instrumentNames) score()->removeElement(t); } return; } // TODO: ml is normally empty here, so we are unable to retrieve tick // thus, staff name does not reflect current instrument int tick = ml.empty() ? 0 : ml.front()->tick(); int staffIdx = 0; for (SysStaff* staff : _staves) { Staff* s = score()->staff(staffIdx); if (!s->isTop() || !s->show()) { foreach (InstrumentName* t, staff->instrumentNames) score()->removeElement(t); ++staffIdx; continue; } Part* part = s->part(); const QList<StaffName>& names = longName? part->longNames(tick) : part->shortNames(tick); int idx = 0; foreach (const StaffName& sn, names) { InstrumentName* iname = staff->instrumentNames.value(idx); if (iname == 0) { iname = new InstrumentName(score()); // iname->setGenerated(true); iname->setParent(this); iname->setTrack(staffIdx * VOICES); iname->setInstrumentNameType(longName ? InstrumentNameType::LONG : InstrumentNameType::SHORT); score()->addElement(iname); } iname->setXmlText(sn.name()); iname->setLayoutPos(sn.pos()); ++idx; } for (; idx < staff->instrumentNames.size(); ++idx) score()->removeElement(staff->instrumentNames[idx]); ++staffIdx; }
void CodEditMsgDialog::exec(ColDiagramView * view, ColMsgList & msgs) { QDialog d(0, "Communication diagram message dialog", TRUE, 0); d.setCaption(TR("Communication diagram message dialog")); QVBoxLayout vbox(&d); vbox.addWidget(new ColMsgTable(&d, view, msgs)); static QSize previous_size; UmlDesktop::limitsize_center(&d, previous_size, 0.8, 0.8); d.exec(); previous_size = d.size(); }
bool myg_ask_string(Gtk::Window &parent, const Glib::ustring &title, const Glib::ustring &msg, Glib::ustring &input, bool password) { Gtk::Dialog dlg(title, parent, true, true); Gtk::Button *okbtn; dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); okbtn= dlg.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); Gtk::VBox vbox(false, 20); Gtk::Entry entry; Gtk::Label label("", 0.0, 0.5); label.set_line_wrap(true); label.set_use_markup(true); label.set_markup(msg); dlg.get_vbox()->pack_start(vbox); if (password) entry.set_visibility(false); entry.signal_activate().connect(sigc::mem_fun(*okbtn,&Gtk::Button::clicked)); vbox.set_border_width(20); vbox.pack_start(label); vbox.pack_start(entry); vbox.show(); label.show(); entry.show(); dlg.set_size_request(350, -1); if (dlg.run() == Gtk::RESPONSE_OK) { input= entry.get_text(); return true; } return false; }
int checkCoarseAssortment(const Box& a_domain) { int retval = 0; const EBIndexSpace* const ebisPtr = Chombo_EBIS::instance(); CH_assert(ebisPtr->isDefined()); Box fineDomain = a_domain; int numLevels = ebisPtr->numLevels(); for (int ilev = 1; ilev < numLevels; ilev++) { CH_assert(!fineDomain.isEmpty()); Vector<Box> vbox(1, fineDomain); Vector<int> proc(1, 0); DisjointBoxLayout fineDBL(vbox, proc); EBISLayout fineEBISL; int nghost = 4; ebisPtr->fillEBISLayout(fineEBISL, fineDBL, fineDomain, nghost); Box coarDomain = coarsen(fineDomain, 2); DisjointBoxLayout coarDBL; coarsen(coarDBL, fineDBL, 2); EBISLayout coarEBISL; ebisPtr->fillEBISLayout(coarEBISL, coarDBL, coarDomain, nghost); for (DataIterator dit = fineDBL.dataIterator(); dit.ok(); ++dit) { retval = checkEBISBox(coarDBL.get(dit()), coarEBISL[dit()], fineEBISL[dit()]); if (retval != 0) { pout() << "problem in coarsening " << fineDomain << " to " << coarDomain << endl; return retval; } } fineDomain.coarsen(2); } return retval; }
void System::layout2() { VBox* b = vbox(); if (b) { b->layout(); setbbox(b->bbox()); return; } setPos(0.0, 0.0); QList<std::pair<int,SysStaff*>> visibleStaves; int firstStaffIdx = -1; int lastStaffIdx = 0; int firstStaffInitialIdx = -1; int lastStaffInitialIdx = 0; Measure* fm = firstMeasure(); for (int i = 0; i < _staves.size(); ++i) { Staff* s = score()->staff(i); SysStaff* ss = _staves[i]; if (s->show() && ss->show()) { visibleStaves.append(std::pair<int,SysStaff*>(i, ss)); if (firstStaffIdx == -1) firstStaffIdx = i; if (i > lastStaffIdx) lastStaffIdx = i; if (fm && fm->visible(i)) { if (firstStaffInitialIdx == -1) firstStaffInitialIdx = i; lastStaffInitialIdx = i; } } else { ss->setbbox(QRectF()); // already done in layout() ? } } if (firstStaffIdx == -1) firstStaffIdx = 0; if (firstStaffInitialIdx == -1) firstStaffInitialIdx = 0; qreal _spatium = spatium(); qreal y = 0.0; qreal minVerticalDistance = score()->styleP(StyleIdx::minVerticalDistance); qreal staffDistance = score()->styleP(StyleIdx::staffDistance); qreal akkoladeDistance = score()->styleP(StyleIdx::akkoladeDistance); if (visibleStaves.empty()) { qDebug("====no visible staves, staves %d, score staves %d", _staves.size(), score()->nstaves()); } for (auto i = visibleStaves.begin();; ++i) { SysStaff* ss = i->second; int si1 = i->first; Staff* staff = score()->staff(si1); auto ni = i + 1; qreal h = staff->height(); if (ni == visibleStaves.end()) { ss->setYOff(staff->lines() == 1 ? _spatium * staff->mag() : 0.0); ss->bbox().setRect(_leftMargin, y, width() - _leftMargin, h); break; } int si2 = ni->first; qreal dist = h; switch (staff->innerBracket()) { case BracketType::BRACE: dist += akkoladeDistance; break; case BracketType::NORMAL: case BracketType::SQUARE: case BracketType::LINE: case BracketType::NO_BRACKET: dist += staffDistance; break; } dist += score()->staff(si2)->userDist(); for (MeasureBase* mb : ml) { if (!mb->isMeasure()) continue; Measure* m = toMeasure(mb); Shape& s1 = m->staffShape(si1); Shape& s2 = m->staffShape(si2); qreal d = s1.minVerticalDistance(s2) + minVerticalDistance; dist = qMax(dist, d); Spacer* sp = m->mstaff(si1)->_vspacerDown; if (sp) { if (sp->spacerType() == SpacerType::FIXED) { dist = staff->height() + sp->gap(); break; } else dist = qMax(dist, staff->height() + sp->gap()); } sp = m->mstaff(si2)->_vspacerUp; if (sp) dist = qMax(dist, sp->gap()); } ss->setYOff(staff->lines() == 1 ? _spatium * staff->mag() : 0.0); ss->bbox().setRect(_leftMargin, y, width() - _leftMargin, h); y += dist; } qreal systemHeight = staff(lastStaffIdx)->bbox().bottom(); setHeight(systemHeight); for (MeasureBase* m : ml) { if (m->isMeasure()) { // note that the factor 2 * _spatium must be corrected for when exporting // system distance in MusicXML (issue #24733) m->bbox().setRect(0.0, -_spatium, m->width(), systemHeight + 2.0 * _spatium); } else if (m->isHBox()) { m->bbox().setRect(0.0, 0.0, m->width(), systemHeight); toHBox(m)->layout2(); } else if (m->isTBox()) { // m->bbox().setRect(0.0, 0.0, m->width(), systemHeight); toTBox(m)->layout(); } else qDebug("unhandled measure type %s", m->name()); } if (fm) { Segment* s = fm->first(); BarLine* _barLine = s->isBeginBarLineType() ? toBarLine(s->element(0)) : 0; if (_barLine) { _barLine->setTrack(firstStaffInitialIdx * VOICES); _barLine->setSpan(lastStaffInitialIdx - firstStaffInitialIdx + 1); if (score()->staff(firstStaffInitialIdx)->lines() == 1) _barLine->setSpanFrom(BARLINE_SPAN_1LINESTAFF_FROM); else _barLine->setSpanFrom(0); int llines = score()->staff(lastStaffInitialIdx)->lines(); int spanTo = llines == 1 ? BARLINE_SPAN_1LINESTAFF_TO : (llines - 1) * 2; _barLine->setSpanTo(spanTo); _barLine->layout(); } } //--------------------------------------------------- // layout brackets vertical position //--------------------------------------------------- for (Bracket* b : _brackets) { int staffIdx1 = b->firstStaff(); int staffIdx2 = b->lastStaff(); qreal sy = 0; // assume bracket not visible qreal ey = 0; // if start staff not visible, try next staff while (staffIdx1 <= staffIdx2 && !_staves[staffIdx1]->show()) ++staffIdx1; // if end staff not visible, try prev staff while (staffIdx1 <= staffIdx2 && !_staves[staffIdx2]->show()) --staffIdx2; // the bracket will be shown IF: // it spans at least 2 visible staves (staffIdx1 < staffIdx2) OR // it spans just one visible staff (staffIdx1 == staffIdx2) but it is required to do so // (the second case happens at least when the bracket is initially dropped) bool notHidden = (staffIdx1 < staffIdx2) || (b->span() == 1 && staffIdx1 == staffIdx2); if (notHidden) { // set vert. pos. and height to visible spanned staves sy = _staves[staffIdx1]->bbox().top(); ey = _staves[staffIdx2]->bbox().bottom(); } b->rypos() = sy; // if (score()->staff(firstStaffInitialIdx)->lines() == 1) // bbox of one line staff bad? // b->rypos() -= _spatium; b->setHeight(ey - sy); b->layout(); } //--------------------------------------------------- // layout instrument names //--------------------------------------------------- int staffIdx = 0; for (Part* p : score()->parts()) { SysStaff* s = staff(staffIdx); SysStaff* s2; int nstaves = p->nstaves(); if (s->show()) { for (InstrumentName* t : s->instrumentNames) { // // override Text->layout() // qreal y1, y2; switch (t->layoutPos()) { default: case 0: // center at part y1 = s->bbox().top(); s2 = staff(staffIdx); for (int i = staffIdx + nstaves - 1; i > 0; --i) { SysStaff* s = staff(i); if (s->show()) { s2 = s; break; } } y2 = s2->bbox().bottom(); break; case 1: // center at first staff y1 = s->bbox().top(); y2 = s->bbox().bottom(); break; // TODO: // sort out invisible staves case 2: // center between first and second staff y1 = s->bbox().top(); y2 = staff(staffIdx + 1)->bbox().bottom(); break; case 3: // center at second staff y1 = staff(staffIdx + 1)->bbox().top(); y2 = staff(staffIdx + 1)->bbox().bottom(); break; case 4: // center between first and second staff y1 = staff(staffIdx + 1)->bbox().top(); y2 = staff(staffIdx + 2)->bbox().bottom(); break; case 5: // center at third staff y1 = staff(staffIdx + 2)->bbox().top(); y2 = staff(staffIdx + 2)->bbox().bottom(); break; } t->rypos() = y1 + (y2 - y1) * .5 + t->textStyle().offset(t->spatium()).y(); } } staffIdx += nstaves; } }
int main() { // Create the main SFML window sf::RenderWindow app_window( sf::VideoMode( 800, 600 ), "SFGUI Combo Box Example", sf::Style::Titlebar | sf::Style::Close ); // Construct our SFML guard // See http://sfgui.sfml-dev.de/forum/topic52-crash-on-close.html for more info. sfg::SFGUI sfgui; // Create our main SFGUI window sfg::Window::Ptr window; window = sfg::Window::Create(); window->SetTitle( "Title" ); // Create the combo box itself. combo_box = sfg::ComboBox::Create(); // Set the entries of the combo box. combo_box->AppendItem( "Bar" ); combo_box->PrependItem( "Foo" ); sel_label = sfg::Label::Create( L"Please select an item!" ); sfg::Button::Ptr button( sfg::Button::Create( L"Add item" ) ); sfg::Box::Ptr hbox( sfg::Box::Create( sfg::Box::HORIZONTAL, 5 ) ); hbox->Pack( combo_box ); hbox->Pack( button, false ); sfg::Box::Ptr vbox( sfg::Box::Create( sfg::Box::VERTICAL, 5 ) ); vbox->Pack( hbox, false ); vbox->Pack( sel_label, true ); // Add the combo box to the window window->Add( vbox ); // So that our combo box has a meaningful purpose (besides just looking // awesome :P) we need to tell it to connect to a callback of our choosing to // notify us when it is clicked. combo_box->OnSelect.Connect( &OnComboSelect ); button->OnClick.Connect( &OnAddItemClick ); // If attempting to connect to a class method you need to provide // a pointer to it as the second parameter after the function address. // Start the game loop while ( app_window.isOpen() ) { // Process events sf::Event event; while ( app_window.pollEvent( event ) ) { // Handle events window->HandleEvent( event ); // Close window : exit if ( event.type == sf::Event::Closed ) { app_window.close(); } } // Update the GUI, note that you shouldn't normally // pass 0 seconds to the update method. window->Update( 0.f ); // Clear screen app_window.clear(); // Draw the GUI sfg::Renderer::Get().Display( app_window ); // Update the window app_window.display(); } // If you have any global or static widgets, // you need to reset their pointers before your // application exits. combo_box.reset(); sel_label.reset(); return EXIT_SUCCESS; }