本文整理汇总了C++中SpinBox类的典型用法代码示例。如果您正苦于以下问题:C++ SpinBox类的具体用法?C++ SpinBox怎么用?C++ SpinBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpinBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSpinBox
void
KnobGuiColor::onDimensionsMadeVisible(bool visible)
{
KnobColorPtr knob = _knob.lock();
if (!knob) {
return;
}
int nDims = knob->getNDimensions();
QColor colors[4];
colors[0].setRgbF(0.851643, 0.196936, 0.196936);
colors[1].setRgbF(0, 0.654707, 0);
colors[2].setRgbF(0.345293, 0.345293, 1);
colors[3].setRgbF(0.398979, 0.398979, 0.398979);
for (int i = 0; i < nDims; ++i) {
SpinBox* sb = 0;
getSpinBox(DimIdx(i), &sb);
assert(sb);
if (!visible) {
sb->setAdditionalDecorationTypeEnabled(LineEdit::eAdditionalDecorationColoredUnderlinedText, false);
} else {
sb->setAdditionalDecorationTypeEnabled(LineEdit::eAdditionalDecorationColoredUnderlinedText, true, colors[i]);
}
}
}
示例2: main
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
SpinBox window;
window.resize(250, 150);
window.setWindowTitle("QSpinBox");
window.show();
return app.exec();
}
示例3: getSpinBox
void
KnobGuiColor::onDimensionsFolded()
{
KnobColorPtr knob = _knob.lock();
int nDims = knob->getDimension();
for (int i = 0; i < nDims; ++i) {
SpinBox* sb = 0;
getSpinBox(i, &sb);
assert(sb);
sb->setUseLineColor(false, Qt::red);
}
Q_EMIT dimensionSwitchToggled(false);
}
示例4: switch
void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting)
{
SpinBox *sb = 0;
switch (setting->type())
{
case CSMSettings::Type_SpinBox:
sb = new SpinBox (this);
if (!setting->declaredValues().isEmpty())
sb->setValueList (setting->declaredValues());
mRangeWidget = sb;
connect (mRangeWidget, SIGNAL (valueChanged (int)),
this, SLOT (slotUpdateView (int)));
break;
case CSMSettings::Type_DoubleSpinBox:
mRangeWidget = new QDoubleSpinBox (this);
connect (mRangeWidget, SIGNAL (valueChanged (double)),
this, SLOT (slotUpdateView (double)));
break;
default:
return;
}
//min / max values are set automatically in AlphaSpinBox
if (setting->declaredValues().isEmpty())
{
mRangeWidget->setProperty ("minimum", setting->minimum());
mRangeWidget->setProperty ("maximum", setting->maximum());
mRangeWidget->setProperty ("singleStep", setting->singleStep());
}
mRangeWidget->setProperty ("prefix", setting->prefix());
mRangeWidget->setProperty ("suffix", setting->suffix());
mRangeWidget->setProperty ("wrapping", setting->wrapping());
dynamic_cast<QAbstractSpinBox *> (mRangeWidget)->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
if(setting->type() == CSMSettings::Type_SpinBox && setting->declaredValues().isEmpty())
dynamic_cast<QSpinBox *> (mRangeWidget)->setValue (setting->defaultValues().at(0).toInt());
}
示例5: init
virtual void init() {
SceneTree::init();
Panel *frame = memnew(Panel);
frame->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END);
frame->set_anchor(MARGIN_BOTTOM, Control::ANCHOR_END);
frame->set_end(Point2(0, 0));
Ref<Theme> t = memnew(Theme);
frame->set_theme(t);
get_root()->add_child(frame);
Label *label = memnew(Label);
label->set_position(Point2(80, 90));
label->set_size(Point2(170, 80));
label->set_align(Label::ALIGN_FILL);
label->set_text("There was once upon a time a beautiful unicorn that loved to play with little girls...");
frame->add_child(label);
Button *button = memnew(Button);
button->set_position(Point2(20, 20));
button->set_size(Point2(1, 1));
button->set_text("This is a biggie button");
frame->add_child(button);
Tree *tree = memnew(Tree);
tree->set_columns(2);
tree->set_position(Point2(230, 210));
tree->set_size(Point2(150, 250));
TreeItem *item = tree->create_item();
item->set_editable(0, true);
item->set_text(0, "root");
item = tree->create_item(tree->get_root());
item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
item->set_editable(0, true);
item->set_text(0, "check");
item->set_cell_mode(1, TreeItem::CELL_MODE_CHECK);
item->set_editable(1, true);
item->set_text(1, "check2");
item = tree->create_item(tree->get_root());
item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE);
item->set_editable(0, true);
item->set_range_config(0, 0, 20, 0.1);
item->set_range(0, 2);
item->add_button(0, Theme::get_default()->get_icon("folder", "FileDialog"));
item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
item->set_editable(1, true);
item->set_range_config(1, 0, 20, 0.1);
item->set_range(1, 3);
item = tree->create_item(tree->get_root());
item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE);
item->set_editable(0, true);
item->set_text(0, "Have,Many,Several,Options!");
item->set_range(0, 2);
item = tree->create_item(item);
item->set_editable(0, true);
item->set_text(0, "Gershwin!");
frame->add_child(tree);
LineEdit *line_edit = memnew(LineEdit);
line_edit->set_position(Point2(30, 190));
line_edit->set_size(Point2(180, 1));
frame->add_child(line_edit);
HScrollBar *hscroll = memnew(HScrollBar);
hscroll->set_position(Point2(30, 290));
hscroll->set_size(Point2(180, 1));
hscroll->set_max(10);
hscroll->set_page(4);
frame->add_child(hscroll);
SpinBox *spin = memnew(SpinBox);
spin->set_position(Point2(30, 260));
spin->set_size(Point2(120, 1));
frame->add_child(spin);
hscroll->share(spin);
ProgressBar *progress = memnew(ProgressBar);
progress->set_position(Point2(30, 330));
progress->set_size(Point2(120, 1));
frame->add_child(progress);
//.........这里部分代码省略.........
示例6: connectKnobSignalSlots
void
KnobGuiValue::createWidget(QHBoxLayout* layout)
{
connectKnobSignalSlots();
_imp->container = new QWidget(layout->parentWidget());
QHBoxLayout *containerLayout = new QHBoxLayout(_imp->container);
layout->addWidget(_imp->container);
containerLayout->setContentsMargins(0, 0, 0, 0);
containerLayout->setSpacing(3);
if (getKnobsCountOnSameLine() > 1) {
disableSlider();
}
if (!isSliderDisabled()) {
layout->parentWidget()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
}
KnobPtr knob = _imp->getKnob();
const int nDims = knob->getDimension();
std::vector<double> increments, displayMins, displayMaxs, mins, maxs;
std::vector<int> decimals;
boost::shared_ptr<Knob<double> > doubleKnob = _imp->getKnobAsDouble();
boost::shared_ptr<Knob<int> > intKnob = _imp->getKnobAsInt();
if (doubleKnob) {
displayMins = doubleKnob->getDisplayMinimums();
displayMaxs = doubleKnob->getDisplayMaximums();
mins = doubleKnob->getMinimums();
maxs = doubleKnob->getMaximums();
} else {
const std::vector<int>& intDmins = intKnob->getDisplayMinimums();
const std::vector<int>& intDMaxs = intKnob->getDisplayMaximums();
const std::vector<int>& intMins = intKnob->getMinimums();
const std::vector<int>& intMaxs = intKnob->getMaximums();
assert(intDMaxs.size() == intDmins.size() && intDmins.size() == intMins.size() && intMins.size() == intMaxs.size());
displayMins.resize(intDmins.size());
displayMaxs.resize(intDmins.size());
mins.resize(intDmins.size());
maxs.resize(intDmins.size());
for (std::size_t i = 0; i < intMins.size(); ++i) {
displayMins[i] = intDmins[i];
displayMaxs[i] = intDMaxs[i];
mins[i] = intMins[i];
maxs[i] = intMaxs[i];
}
}
getIncrements(&increments);
getDecimals(&decimals);
std::vector<std::string> dimensionLabels(nDims);
bool isRectangleParam = isRectangleType();
// This is a rectangle parameter
if (isRectangleParam) {
dimensionLabels[0] = "x";
dimensionLabels[1] = "y";
dimensionLabels[2] = "w";
dimensionLabels[3] = "h";
} else {
for (int i = 0; i < nDims; ++i) {
dimensionLabels[i] = knob->getDimensionName(i);
}
}
KnobGuiPtr thisShared = shared_from_this();
SpinBox::SpinBoxTypeEnum type;
if (doubleKnob) {
type = SpinBox::eSpinBoxTypeDouble;
} else {
type = SpinBox::eSpinBoxTypeInt;
}
int nItemsPerRow = nDims;
if (std::floor(nDims / 3. + 0.5) == nDims / 3.) {
nItemsPerRow = 3;
}
if (std::floor(nDims / 4. + 0.5) == nDims / 4.) {
nItemsPerRow = 4;
}
int nbRows = nDims / nItemsPerRow;
assert(nbRows >= 1);
QWidget* allSpinBoxesContainer = 0;
QGridLayout* spinBoxesGrid = 0;
if (nbRows == 1) {
allSpinBoxesContainer = _imp->container;
} else {
allSpinBoxesContainer = new QWidget(_imp->container);
spinBoxesGrid = new QGridLayout(allSpinBoxesContainer);
spinBoxesGrid->setContentsMargins(0, 0, 0, 0);
spinBoxesGrid->setVerticalSpacing(TO_DPIY(1));
spinBoxesGrid->setHorizontalSpacing(TO_DPIX(1));
//.........这里部分代码省略.........
示例7: getInstanceSpecificKnobs
void MultiInstancePanelPrivate::addTableRow(Node* node)
{
int newRowIndex = table->rowCount();
table->insertRow(newRowIndex);
std::list<boost::shared_ptr<KnobI> > instanceSpecificKnobs;
getInstanceSpecificKnobs(node, &instanceSpecificKnobs);
///first add the enabled column
{
QWidget* enabledContainer = createCheckBoxForTable(true);
table->setCellWidget(newRowIndex, 0, enabledContainer);
}
int columnIndex = 1;
for (std::list<boost::shared_ptr<KnobI> >::iterator it = instanceSpecificKnobs.begin();it!=instanceSpecificKnobs.end();++it) {
Int_Knob* isInt = dynamic_cast<Int_Knob*>(it->get());
Bool_Knob* isBool = dynamic_cast<Bool_Knob*>(it->get());
Double_Knob* isDouble = dynamic_cast<Double_Knob*>(it->get());
Color_Knob* isColor = dynamic_cast<Color_Knob*>(it->get());
String_Knob* isString = dynamic_cast<String_Knob*>(it->get());
if (!isInt || !isBool || !isDouble || !isColor || !isString) {
continue;
}
bool createCheckBox = false;
bool createSpinBox = false;
if (isBool) {
createCheckBox = true;
} else if (isInt || isDouble || isColor) {
createSpinBox = true;
}
for (int i = 0; i < (*it)->getDimension(); ++it) {
if (createCheckBox) {
assert(isBool);
bool checked = isBool->getValue();
QWidget* enabledContainer = createCheckBoxForTable(checked);
table->setCellWidget(newRowIndex, columnIndex, enabledContainer);
} else if (createSpinBox) {
double mini = INT_MIN,maxi = INT_MAX;
SpinBox::SPINBOX_TYPE type = SpinBox::DOUBLE_SPINBOX;
if (isInt) {
mini = isInt->getMinimums()[i];
maxi = isInt->getMaximums()[i];
type = SpinBox::INT_SPINBOX;
} else if (isDouble) {
mini = isDouble->getMinimums()[i];
maxi = isDouble->getMaximums()[i];
}
SpinBox* sb = new SpinBox(NULL,type);
sb->setMinimum(mini);
sb->setMaximum(maxi);
table->setCellWidget(newRowIndex, columnIndex, sb);
} else {
assert(isString);
std::string value = isString->getValue();
LineEdit* le = new LineEdit(NULL);
le->setText(value.c_str());
table->setCellWidget(newRowIndex, columnIndex, le);
}
++columnIndex;
}
}
}
示例8: switch
QWidget*
TableItemEditorFactory::createEditor(QVariant::Type type,
QWidget *parent) const
{
switch (type) {
case QVariant::UInt: {
SpinBox *sb = new SpinBox(parent, SpinBox::eSpinBoxTypeInt);
sb->setFrame(false);
sb->setMaximum(INT_MAX);
return sb;
}
case QVariant::Int: {
SpinBox *sb = new SpinBox(parent, SpinBox::eSpinBoxTypeInt);
sb->setFrame(false);
sb->setMinimum(INT_MIN);
sb->setMaximum(INT_MAX);
return sb;
}
case QVariant::Pixmap:
return new Label(parent);
case QVariant::Double: {
SpinBox *sb = new SpinBox(parent, SpinBox::eSpinBoxTypeDouble);
sb->setFrame(false);
sb->setMinimum(-DBL_MAX);
sb->setMaximum(DBL_MAX);
return sb;
}
case QVariant::String:
default: {
// the default editor is a lineedit
ExpandingLineEdit *le = new ExpandingLineEdit(parent);
le->setFrame( le->style()->styleHint(QStyle::SH_ItemView_DrawDelegateFrame, 0, le) );
if ( !le->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, le) ) {
le->setWidgetOwnsGeometry(true);
}
return le;
}
}
return 0;
}
示例9: init
//.........这里部分代码省略.........
item->set_editable(0,true);
item->set_text(0,"Have,Many,Several,Options!");
item->set_range(0,2);
item = tree->create_item( item );
item->set_editable(0,true);
item->set_text(0,"Gershwin!");
frame->add_child(tree);
//control = memnew( Control );
//root->add_child( control );
LineEdit *line_edit = memnew( LineEdit );
line_edit->set_pos( Point2( 30,190 ) );
line_edit->set_size( Point2( 180,1 ) );
frame->add_child(line_edit);
HScrollBar *hscroll = memnew( HScrollBar );
hscroll->set_pos( Point2( 30,290 ) );
hscroll->set_size( Point2( 180,1 ) );
hscroll->set_max(10);
hscroll->set_page(4);
frame->add_child(hscroll);
SpinBox *spin = memnew( SpinBox );
spin->set_pos( Point2( 30,260 ) );
spin->set_size( Point2( 120,1 ) );
frame->add_child(spin);
hscroll->share(spin);
ProgressBar *progress = memnew( ProgressBar );
progress->set_pos( Point2( 30,330 ) );
progress->set_size( Point2( 120,1 ) );
frame->add_child(progress);
hscroll->share(progress);
MenuButton *menu_button = memnew( MenuButton );
menu_button->set_text("I'm a menu!");
menu_button->set_pos( Point2( 30,380 ) );
menu_button->set_size( Point2( 1,1 ) );
frame->add_child(menu_button);
PopupMenu *popup = menu_button->get_popup();
popup->add_item("Hello, testing");
popup->add_item("My Dearest");
popup->add_separator();
popup->add_item("Popup");
popup->add_check_item("Check Popup");
popup->set_item_checked(4,true);
示例10: EditorFontImportDialog
EditorFontImportDialog(EditorFontImportPlugin *p_plugin) {
plugin=p_plugin;
VBoxContainer *vbc = memnew( VBoxContainer );
add_child(vbc);
set_child_rect(vbc);
HBoxContainer *hbc = memnew( HBoxContainer);
vbc->add_child(hbc);
VBoxContainer *vbl = memnew( VBoxContainer );
hbc->add_child(vbl);
hbc->set_v_size_flags(SIZE_EXPAND_FILL);
vbl->set_h_size_flags(SIZE_EXPAND_FILL);
VBoxContainer *vbr = memnew( VBoxContainer );
hbc->add_child(vbr);
vbr->set_h_size_flags(SIZE_EXPAND_FILL);
source = memnew( LineEditFileChooser );
source->get_file_dialog()->set_access(FileDialog::ACCESS_FILESYSTEM);
source->get_file_dialog()->set_mode(FileDialog::MODE_OPEN_FILE);
source->get_file_dialog()->add_filter("*.ttf;TrueType");
source->get_file_dialog()->add_filter("*.otf;OpenType");
source->get_line_edit()->connect("text_entered",this,"_src_changed");
vbl->add_margin_child("Source Font:",source);
font_size = memnew( SpinBox );
vbl->add_margin_child("Source Font Size:",font_size);
font_size->set_min(3);
font_size->set_max(256);
font_size->set_val(16);
font_size->connect("value_changed",this,"_font_size_changed");
dest = memnew( LineEditFileChooser );
//
List<String> fl;
Ref<Font> font= memnew(Font);
dest->get_file_dialog()->add_filter("*.fnt ; Font" );
//ResourceSaver::get_recognized_extensions(font,&fl);
//for(List<String>::Element *E=fl.front();E;E=E->next()) {
// dest->get_file_dialog()->add_filter("*."+E->get());
//}
vbl->add_margin_child("Dest Resource:",dest);
HBoxContainer *testhb = memnew( HBoxContainer );
test_string = memnew( LineEdit );
test_string->set_text("The quick brown fox jumps over the lazy dog.");
test_string->set_h_size_flags(SIZE_EXPAND_FILL);
test_string->set_stretch_ratio(5);
testhb->add_child(test_string);
test_color = memnew( ColorPickerButton );
test_color->set_color(get_color("font_color","Label"));
test_color->set_h_size_flags(SIZE_EXPAND_FILL);
test_color->set_stretch_ratio(1);
test_color->connect("color_changed",this,"_update_text3");
testhb->add_child(test_color);
vbl->add_spacer();
vbl->add_margin_child("Test: ",testhb);
HBoxContainer *upd_hb = memnew( HBoxContainer );
// vbl->add_child(upd_hb);
upd_hb->add_spacer();
Button *update = memnew( Button);
upd_hb->add_child(update);
update->set_text("Update");
update->connect("pressed",this,"_update");
options = memnew( _EditorFontImportOptions );
prop_edit = memnew( PropertyEditor() );
vbr->add_margin_child("Options:",prop_edit,true);
options->connect("changed",this,"_prop_changed");
prop_edit->hide_top_label();
Panel *panel = memnew( Panel );
vbc->add_child(panel);
test_label = memnew( Label );
test_label->set_autowrap(true);
panel->add_child(test_label);
test_label->set_area_as_parent_rect();
panel->set_v_size_flags(SIZE_EXPAND_FILL);
test_string->connect("text_changed",this,"_update_text2");
set_title("Font Import");
timer = memnew( Timer );
add_child(timer);
timer->connect("timeout",this,"_update");
timer->set_wait_time(0.4);
timer->set_one_shot(true);
get_ok()->connect("pressed", this,"_import");
get_ok()->set_text("Import");
error_dialog = memnew ( ConfirmationDialog );
add_child(error_dialog);
error_dialog->get_ok()->set_text("Accept");
set_hide_on_ok(false);
}
示例11: dialog
void
KnobGuiColor::showColorDialog()
{
QColorDialog dialog( _colorLabel->parentWidget() );
dialog.setOption(QColorDialog::DontUseNativeDialog);
KnobColorPtr knob = _knob.lock();
if (!knob) {
return;
}
const int nDims = knob->getNDimensions();
ViewIdx view = getView();
double curR = knob->getValue(DimIdx(0), view, false /*clampToMinmax*/);
_lastColor.resize(nDims);
_lastColor[0] = curR;
double curG = curR;
double curB = curR;
double curA = 1.;
if (nDims > 1) {
curG = knob->getValue(DimIdx(1), view, false /*clampToMinmax*/);
_lastColor[1] = curG;
curB = knob->getValue(DimIdx(2), view, false /*clampToMinmax*/);
_lastColor[2] = curB;
}
if (nDims > 3) {
dialog.setOption(QColorDialog::ShowAlphaChannel);
curA = knob->getValue(DimIdx(3), view, false /*clampToMinmax*/);
_lastColor[3] = curA;
}
convertFromInternalToUIColorspace(&curR, &curG, &curB);
QColor curColor;
curColor.setRgbF( Image::clamp<qreal>(curR, 0., 1.),
Image::clamp<qreal>(curG, 0., 1.),
Image::clamp<qreal>(curB, 0., 1.),
Image::clamp<qreal>(curA, 0., 1.) );
dialog.setCurrentColor(curColor);
QObject::connect( &dialog, SIGNAL(currentColorChanged(QColor)), this, SLOT(onDialogCurrentColorChanged(QColor)) );
if ( !dialog.exec() ) {
knob->setValueAcrossDimensions(_lastColor, DimIdx(0), view, eValueChangedReasonUserEdited);
} else {
QColor userColor = dialog.currentColor();
std::vector<double> color(nDims);
color[0] = userColor.redF();
convertFromUIToInternalColorspace(&color[0]);
if (nDims > 1) {
color[1] = userColor.greenF();
convertFromUIToInternalColorspace(&color[1]);
}
if (nDims > 2) {
color[2] = userColor.blueF();
convertFromUIToInternalColorspace(&color[2]);
}
if (nDims > 3) {
color[3] = userColor.alphaF();
}
for (int i = 0; i < 3; ++i) {
SpinBox* sb = 0;
getSpinBox(DimIdx(i), &sb);
if (sb) {
sb->setValue(color[i]);
}
}
std::vector<double> oldColor(nDims);
for (int i = 0; i < nDims; ++i) {
oldColor[i] = _lastColor[i];
}
KnobGuiPtr knobUI = getKnobGui();
knobUI->pushUndoCommand( new KnobUndoCommand<double>(knob, oldColor, color, getView()) );
}
KnobGuiPtr knobUI = getKnobGui();
if ( knobUI->getGui() ) {
knobUI->getGui()->setDraftRenderEnabled(false);
}
} // showColorDialog
示例12: dialog
void
KnobGuiColor::showColorDialog()
{
QColorDialog dialog( _colorLabel->parentWidget() );
dialog.setOption(QColorDialog::DontUseNativeDialog);
KnobColorPtr knob = _knob.lock();
const int nDims = knob->getDimension();
double curR = knob->getValue(0);
_lastColor[0] = curR;
double curG = curR;
double curB = curR;
double curA = 1.;
if (nDims > 1) {
curG = knob->getValue(1);
_lastColor[1] = curG;
curB = knob->getValue(2);
_lastColor[2] = curB;
}
if (nDims > 3) {
dialog.setOption(QColorDialog::ShowAlphaChannel);
curA = knob->getValue(3);
_lastColor[3] = curA;
}
bool isSimple = _useSimplifiedUI;
QColor curColor;
curColor.setRgbF( Image::clamp<qreal>(isSimple ? curR : Color::to_func_srgb(curR), 0., 1.),
Image::clamp<qreal>(isSimple ? curG : Color::to_func_srgb(curG), 0., 1.),
Image::clamp<qreal>(isSimple ? curB : Color::to_func_srgb(curB), 0., 1.),
Image::clamp<qreal>(curA, 0., 1.) );
dialog.setCurrentColor(curColor);
QObject::connect( &dialog, SIGNAL(currentColorChanged(QColor)), this, SLOT(onDialogCurrentColorChanged(QColor)) );
if ( !dialog.exec() ) {
if (nDims == 3) {
knob->setValues(_lastColor[0], _lastColor[1], _lastColor[2], ViewSpec::all(), eValueChangedReasonNatronGuiEdited);
} else if (nDims == 4) {
knob->setValues(_lastColor[0], _lastColor[1], _lastColor[2], _lastColor[3], ViewSpec::all(), eValueChangedReasonNatronGuiEdited);
} else if (nDims == 1) {
knob->setValue(_lastColor[0], ViewSpec::all(), 0, eValueChangedReasonNatronGuiEdited);
}
} else {
QColor userColor = dialog.currentColor();
std::vector<double> color(4);
color[0] = isSimple ? userColor.redF() : Color::from_func_srgb( userColor.redF() );
color[1] = isSimple ? userColor.greenF() : Color::from_func_srgb( userColor.greenF() );
color[2] = isSimple ? userColor.blueF() : Color::from_func_srgb( userColor.blueF() );
color[3] = userColor.alphaF();
for (int i = 0; i < 3; ++i) {
SpinBox* sb = 0;
getSpinBox(i, &sb);
assert(sb);
sb->setValue(color[i]);
}
// Refresh the last value so that the undo command retrieves the value that was prior to opening the dialog
if (nDims == 3) {
knob->setValues(_lastColor[0], _lastColor[1], _lastColor[2], ViewSpec::all(), eValueChangedReasonUserEdited);
} else if (nDims == 4) {
knob->setValues(_lastColor[0], _lastColor[1], _lastColor[2], _lastColor[3], ViewSpec::all(), eValueChangedReasonUserEdited);
} else if (nDims == 1) {
knob->setValue(_lastColor[0], ViewSpec::all(), 0, eValueChangedReasonUserEdited);
}
onSpinBoxValueChanged();
}
if ( getGui() ) {
getGui()->setDraftRenderEnabled(false);
}
//knob->evaluateValueChange(0, knob->getCurrentTime(), ViewIdx(0), eValueChangedReasonNatronGuiEdited);
} // showColorDialog
示例13: ModalWindow
void GameEngine::openExchangeWindow()
{
if (exchangeWindow == NULL)
{
exchangeWindow = new ModalWindow("ExchangeMW", "Exchange", 400, 300);
//offer block
Label* tmpLbl = new Label("You offer:", "OfferLbl", 0, 0, 50, 15);
exchangeWindow->addUIElement(tmpLbl, 0.45, 0.01);
for (int i = 0; i < CT_DEVELOPMENT; ++i)
{
int resNumber = currentPlayer->getCardsOnHandCount(static_cast<eCardType> (i));
QString str = GameCard::cardTypeToStr(static_cast<eCardType> (i));
tmpLbl = new Label(str + " (" + QString::number(resNumber) + ")", "OfferLbl"+str, 0, 0, 50, 15);
exchangeWindow->addUIElement(tmpLbl, 0.05+0.2*i, 0.07);
SpinBox* tmpSB = new SpinBox("OfferSB"+str, 0, 0, 25, 50);
tmpSB->setMinValue(0);
tmpSB->setMaxValue(resNumber);
//tmpSB->setStep(currentPlayer->getExchangeRate(static_cast<eCardType> (i)));
exchangeWindow->addUIElement(tmpSB, 0.05+0.2*i, 0.15);
}
//offer for who - players or game bank
tmpLbl = new Label("Exchange whith:", "ExchangeWhithLbl", 0, 0, 50, 15);
exchangeWindow->addUIElement(tmpLbl, 0.45, 0.33);
RadioButtonBox* tmprbb = new RadioButtonBox("ExchangeTarget", 0, 0, 300, 15, RadioButtonBox::HORIZONTAL);
tmprbb->addRadioButton("Player", "Players", 75, 15);
tmprbb->addRadioButton("PC", "PC", 75, 15);
exchangeWindow->addUIElement(tmprbb, 0.25, 0.40);
//taking block
tmpLbl = new Label("You taking:", "OfferLbl", 0, 0, 50, 15);
exchangeWindow->addUIElement(tmpLbl, 0.45, 0.43);
for (int i = 0; i < CT_DEVELOPMENT; ++i)
{
QString str = GameCard::cardTypeToStr(static_cast<eCardType> (i));
tmpLbl = new Label(str, "TakingLbl"+str, 0, 0, 50, 15);
exchangeWindow->addUIElement(tmpLbl, 0.05+0.2*i, 0.50);
SpinBox* tmpSB = new SpinBox("TakingSB"+str, 0, 0, 25, 50);
tmpSB->setMinValue(0);
tmpSB->setMaxValue(MAX_CARD_COUNT);
exchangeWindow->addUIElement(tmpSB, 0.05+0.2*i, 0.60);
}
//bottom buttons
Command* mousePress = new GECcloseEW(this);
Button* tmpBtn = new Button("Cancel", "CancelBtn", 0, 0, 75, 25, mousePress);
exchangeWindow->addUIElement(tmpBtn, 0.55, 0.85);
mousePress = new GECsendExchangeOfferBtn(this);
tmpBtn = new Button("Exchange", "ExchangeBtn", 0, 0, 75, 25, mousePress);
exchangeWindow->addUIElement(tmpBtn, 0.30, 0.85);
mousePress = new GECcloseEW(this);
exchangeWindow->addKeyCommand(Qt::Key_Escape, mousePress);
exchangeWindow->show(true);
exchangeWindow->active(true);
}
}
示例14: memnew
EditorImportTextureOptions::EditorImportTextureOptions() {
updating=false;
format = memnew( OptionButton );
format->add_item("Uncompressed",EditorTextureImportPlugin::IMAGE_FORMAT_UNCOMPRESSED);
format->add_item("Compress Lossless (PNG)",EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS);
format->add_item("Compress Lossy (WebP)",EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY);
format->add_item("Compress (VRAM)",EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM);
add_margin_child("Texture Format",format);
quality_vb = memnew( VBoxContainer );
HBoxContainer *quality_hb = memnew(HBoxContainer);
HSlider *hs = memnew( HSlider );
hs->set_h_size_flags(SIZE_EXPAND_FILL);
hs->set_stretch_ratio(0.8);
quality_hb->add_child(hs);
quality_hb->set_h_size_flags(SIZE_EXPAND_FILL);
SpinBox *sb = memnew( SpinBox );
sb->set_h_size_flags(SIZE_EXPAND_FILL);
sb->set_stretch_ratio(0.2);
quality_hb->add_child(sb);
sb->share(hs);
hs->set_min(0);
hs->set_max(1.0);
hs->set_step(0.01);
hs->set_val(0.7);
quality=hs;
quality_vb->add_margin_child("Texture Compression Quality (WebP):",quality_hb);
add_child(quality_vb);
flags = memnew( Tree );
flags->set_hide_root(true);
TreeItem *root = flags->create_item();
const char ** fname=flag_names;
while( *fname ) {
TreeItem*ti = flags->create_item(root);
ti->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
ti->set_text(0,*fname);
ti->set_editable(0,true);
items.push_back(ti);
fname++;
}
add_margin_child("Texture Options",flags,true);
notice_for_2d = memnew( Label );
notice_for_2d->set_text("NOTICE: You are not forced to import textures for 2D projects. Just copy your .jpg or .png files to your project, and change export options later. Atlases can be generated on export too.");
notice_for_2d->set_custom_minimum_size(Size2(0,50));
notice_for_2d->set_autowrap(true);
add_child(notice_for_2d);
notice_for_2d->hide();
}
示例15: HandleEvent
void MyDialog::HandleEvent(Widget &obj, int msg, intptr_t arg1, intptr_t arg2) {
Dialog::HandleEvent(obj, msg, arg1, arg2);
switch (msg) {
case MSG_ACTIVATE:
if (obj == buttonPlay) {
buttonPlay.Disable();
MoveFocusTo(&map);
map.Play((int)eLevel.GetPosition());
eLevel.Disable();
Settings::showMouse = false;
}
else if (obj == bScores) {
ShowScores();
}
break;
case MSG_GAMEOVER: {
Settings::showMouse = true;
if (hsc->CanAdd(eScore.GetInt())) {
GetHiscoreName();
ShowScores();
}
else {
//TODO
#if 0
MessageBox dlg("Message", "Game over! You lose!", NULL, NULL, "OK", NULL, NULL);
dlg.Popup(this);
#endif
}
buttonPlay.Enable();
eLevel.Enable();
nextPiece.piece = NULL;
}
break;
case MSG_UPDATESCORE: {
eLines.SetNumber((int)arg1);
eScore.SetNumber((int)arg2);
}
break;
case MSG_INCREASELEVEL: {
eLevel.Increment();
}
break;
case MSG_NEWPIECE: {
nextPiece.piece = map.GetNextPiece();
}
break;
};
}