Exemplo n.º 1
0
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]);
        }
    }


}
Exemplo n.º 2
0
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;
	};
}
Exemplo n.º 3
0
int main(int argc, char *argv[]) {
	QApplication app(argc, argv);

	SpinBox window;

	window.resize(250, 150);
	window.setWindowTitle("QSpinBox");
	window.show();

	return app.exec();
}
Exemplo n.º 4
0
    KinematicsBarSetupDialog() {

        setWindowTitle(_("Kinematics Operation Setup"));
        
        QVBoxLayout* vbox = new QVBoxLayout();
        setLayout(vbox);
        
        QHBoxLayout* hbox = new QHBoxLayout();
        hbox->addWidget(new QLabel(_("Snap thresholds:")));
        hbox->addSpacing(10);
        
        hbox->addWidget(new QLabel(_("distance")));
        snapDistanceSpin.setAlignment(Qt::AlignCenter);
        snapDistanceSpin.setDecimals(3);
        snapDistanceSpin.setRange(0.0, 0.999);
        snapDistanceSpin.setSingleStep(0.001);
        snapDistanceSpin.setValue(0.025);
        hbox->addWidget(&snapDistanceSpin);
        hbox->addWidget(new QLabel(_("[m]")));

        hbox->addSpacing(5);
        hbox->addWidget(new QLabel(_("angle")));
        snapAngleSpin.setAlignment(Qt::AlignCenter);
        snapAngleSpin.setRange(0, 90);
        snapAngleSpin.setValue(30);
        hbox->addWidget(&snapAngleSpin);
        hbox->addWidget(new QLabel(_("[deg]")));
        vbox->addLayout(hbox);

        hbox = new QHBoxLayout();
        hbox->addWidget(new QLabel(_("Penetration block depth")));
        penetrationBlockDepthSpin.setAlignment(Qt::AlignCenter);
        penetrationBlockDepthSpin.setDecimals(4);
        penetrationBlockDepthSpin.setRange(0.0, 0.0099);
        penetrationBlockDepthSpin.setSingleStep(0.0001);
        penetrationBlockDepthSpin.setValue(0.0005);
        hbox->addWidget(&penetrationBlockDepthSpin);
        hbox->addWidget(new QLabel(_("[m]")));
        vbox->addLayout(hbox);

        hbox = new QHBoxLayout();
        lazyCollisionDetectionModeCheck.setText(_("Lazy collision detection mode"));
        lazyCollisionDetectionModeCheck.setChecked(true);
        hbox->addWidget(&lazyCollisionDetectionModeCheck);
        vbox->addLayout(hbox);

        hbox = new QHBoxLayout();
        okButton.setText(_("OK"));
        okButton.setDefault(true);
        hbox->addWidget(&okButton);
        vbox->addLayout(hbox);
    }
Exemplo n.º 5
0
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);
}
	void popup_import(const String& p_path) {

		popup_centered(Size2(600,500));

		if (p_path!="") {

			Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_path);
			ERR_FAIL_COND(!rimd.is_valid());

			dest->get_line_edit()->set_text(p_path);
			List<String> opts;
			rimd->get_options(&opts);
			for(List<String>::Element *E=opts.front();E;E=E->next()) {

				options->_set(E->get(),rimd->get_option(E->get()));
			}

			String src = "";
			for(int i=0;i<rimd->get_source_count();i++) {
				if (i>0)
					src+=",";
				src+=EditorImportPlugin::expand_source_path(rimd->get_source_path(i));
			}
			source->get_line_edit()->set_text(src);

			font_size->set_val(rimd->get_option("font/size"));
		}
	}
Exemplo n.º 7
0
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());
}
Exemplo n.º 8
0
void
KnobGuiColor::onDimensionsExpanded()
{
    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);

    KnobColorPtr knob = _knob.lock();
    int nDims = knob->getDimension();
    for (int i = 0; i < nDims; ++i) {
        SpinBox* sb = 0;
        Label* label = 0;
        getSpinBox(i, &sb, &label);
        assert(sb);
        sb->setUseLineColor(true, colors[i]);
    }
    Q_EMIT dimensionSwitchToggled(true);
}
	Ref<ResourceImportMetadata> get_rimd() {

		Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
		List<PropertyInfo> pl;
		options->_get_property_list(&pl);
		for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) {

			Variant v;
			String opt=E->get().name;
			options->_get(opt,v);
			if (opt=="color/image" || opt=="character_set/custom") {
				v = EditorImportPlugin::validate_source_path(v);
			}
			imd->set_option(opt,v);
		}

		imd->add_source(EditorImportPlugin::validate_source_path(source->get_line_edit()->get_text()));
		imd->set_option("font/size",font_size->get_val());

		return imd;

	}
Exemplo n.º 10
0
	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);
		hscroll->share(progress);

		MenuButton *menu_button = memnew(MenuButton);

		menu_button->set_text("I'm a menu!");
		menu_button->set_position(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);
		popup->add_separator();
		popup->add_radio_check_item("Option A");
		popup->set_item_checked(6, true);
		popup->add_radio_check_item("Option B");

		OptionButton *options = memnew(OptionButton);

		options->add_item("Hello, testing");
		options->add_item("My Dearest");

		options->set_position(Point2(230, 180));
		options->set_size(Point2(1, 1));

		frame->add_child(options);

		RichTextLabel *richtext = memnew(RichTextLabel);

		richtext->set_position(Point2(600, 210));
		richtext->set_size(Point2(180, 250));
		richtext->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -20);

		frame->add_child(richtext);

		richtext->add_text("Hello, My Friends!\n\nWelcome to the amazing world of ");

		richtext->add_newline();
		richtext->add_newline();

		richtext->push_color(Color(1, 0.5, 0.5));
		richtext->add_text("leprechauns");
		richtext->pop();

		richtext->add_text(" and ");
		richtext->push_color(Color(0, 1.0, 0.5));
		richtext->add_text("faeries.\n");
		richtext->pop();
		richtext->add_text("In this new episode, we will attempt to ");
		richtext->push_font(richtext->get_font("mono_font", "Fonts"));
		richtext->push_color(Color(0.7, 0.5, 1.0));
		richtext->add_text("deliver something nice");
		richtext->pop();
		richtext->pop();
		richtext->add_text(" to all the viewers! Unfortunately, I need to ");
		richtext->push_underline();
		richtext->add_text("keep writing a lot of text");
		richtext->pop();
		richtext->add_text(" so the label control overflows and the scrollbar appears.\n");
		richtext->push_meta("http://www.scrollingcapabilities.xz");
		richtext->add_text("This allows to test for the scrolling capabilities ");
		richtext->pop();
		richtext->add_text("of the rich text label for huge text (not like this text will really be huge but, you know).\nAs long as it is so long that it will work nicely for a test/demo, then it's welcomed in my book...\nChanging subject, the day is cloudy today and I'm wondering if I'll get che chance to travel somewhere nice. Sometimes, watching the clouds from satellite images may give a nice insight about how pressure zones in our planet work, although it also makes it pretty obvious to see why most weather forecasts get it wrong so often.\nClouds are so difficult to predict!\nBut it's pretty cool how our civilization has adapted to having water falling from the sky each time it rains...");

		TabContainer *tabc = memnew(TabContainer);

		Control *ctl = memnew(Control);
		ctl->set_name("tab 1");
		tabc->add_child(ctl);

		ctl = memnew(Control);
		ctl->set_name("tab 2");
		tabc->add_child(ctl);
		label = memnew(Label);
		label->set_text("Some Label");
		label->set_position(Point2(20, 20));
		ctl->add_child(label);

		ctl = memnew(Control);
		ctl->set_name("tab 3");
		button = memnew(Button);
		button->set_text("Some Button");
		button->set_position(Point2(30, 50));
		ctl->add_child(button);

		tabc->add_child(ctl);

		frame->add_child(tabc);

		tabc->set_position(Point2(400, 210));
		tabc->set_size(Point2(180, 250));
	}
Exemplo n.º 11
0
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));
    }
    
    _imp->spinBoxes.resize(nDims);
    
    int rowIndex = 0;
    int columnIndex = 0;
    for (std::size_t i = 0; i < _imp->spinBoxes.size(); ++i) {
        
        QWidget *boxContainer = new QWidget(allSpinBoxesContainer);
        boxContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        
        QHBoxLayout *boxContainerLayout = 0;
        boxContainerLayout = new QHBoxLayout(boxContainer);
        boxContainerLayout->setContentsMargins(0, 0, 0, 0);
        boxContainerLayout->setSpacing(3);
        
        
        Label *subDesc = 0;
        if (nDims != 1 && nbRows == 1) {
            subDesc = new Label(QString::fromUtf8(dimensionLabels[i].c_str()), boxContainer);
            boxContainerLayout->addWidget(subDesc);
        }
        
        SpinBox *box = new KnobSpinBox(layout->parentWidget(), type, thisShared , i);
        NumericKnobValidator* validator = new NumericKnobValidator(box,thisShared);
        box->setValidator(validator);
        QObject::connect( box, SIGNAL(valueChanged(double)), this, SLOT(onSpinBoxValueChanged()) );
        
        // Set the copy/link actions in the right click menu of the SpinBox
        enableRightClickMenu(box,i);
        
#ifdef SPINBOX_TAKE_PLUGIN_RANGE_INTO_ACCOUNT
        double min = mins[i];
        double max = maxs[i];
        valueAccordingToType(false, i, &min);
        valueAccordingToType(false, i, &max);
        box->setMaximum(max);
        box->setMinimum(min);
#endif
        
        
        
        if (type == SpinBox::eSpinBoxTypeDouble) {
            // Set the number of digits after the decimal point
            if (i < decimals.size()) {
                box->decimals(decimals[i]);
            }
        }
        
        if (i < increments.size()) {    
            double incr = 1;
            incr = increments[i];
            valueAccordingToType(false, i, &incr);
            box->setIncrement(incr);
        }
        boxContainerLayout->addWidget(box);
        if (!spinBoxesGrid) {
            containerLayout->addWidget(boxContainer);
        } else {
            spinBoxesGrid->addWidget(boxContainer, rowIndex, columnIndex);
        }
        _imp->spinBoxes[i] = std::make_pair(box, subDesc);
        
        ++columnIndex;
        if (columnIndex >= nItemsPerRow) {
            columnIndex = 0;
            ++rowIndex;
        }
    }
    
    if (spinBoxesGrid) {
        containerLayout->addWidget(allSpinBoxesContainer);
    }
    
    bool sliderVisible = false;
    if (!isSliderDisabled() && !isRectangleParam) {
        double dispmin = displayMins[0];
        double dispmax = displayMaxs[0];
        if (dispmin == -DBL_MAX) {
            dispmin = mins[0];
        }
        if (dispmax == DBL_MAX) {
            dispmax = maxs[0];
        }
        
        // denormalize if necessary
        double dispminGui = dispmin;
        double dispmaxGui = dispmax;
        valueAccordingToType(false, 0, &dispminGui);
        valueAccordingToType(false, 0, &dispmaxGui);
        
        bool spatial = isSpatialType();
        Format f;
        if (spatial) {
            getKnob()->getHolder()->getApp()->getProject()->getProjectDefaultFormat(&f);
        }
        if (dispminGui < -SLIDER_MAX_RANGE) {
            if (spatial) {
                dispminGui = -f.width();
            } else {
                dispminGui = -SLIDER_MAX_RANGE;
            }
        }
        if (dispmaxGui > SLIDER_MAX_RANGE) {
            if (spatial) {
                dispmaxGui = f.width();
            } else {
                dispmaxGui = SLIDER_MAX_RANGE;
            }
        }
        
        double value0 = _imp->getKnobValue(0);

        ScaleSliderQWidget::DataTypeEnum sliderType;
        if (doubleKnob) {
            sliderType = ScaleSliderQWidget::eDataTypeDouble;
        } else {
            sliderType = ScaleSliderQWidget::eDataTypeInt;
        }

        
        _imp->slider = new ScaleSliderQWidget(dispminGui, dispmaxGui, value0,knob->getEvaluateOnChange(),
                                         sliderType,getGui(), eScaleTypeLinear, layout->parentWidget());
        _imp->slider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
        if (hasToolTip()) {
            _imp->slider->setToolTip( toolTip() );
        }
        QObject::connect(_imp->slider, SIGNAL(positionChanged(double)), this, SLOT(onSliderValueChanged(double)));
        QObject::connect(_imp->slider, SIGNAL(editingFinished(bool)), this, SLOT(onSliderEditingFinished(bool)));
        containerLayout->addWidget(_imp->slider);
        
        sliderVisible = shouldSliderBeVisible(dispminGui, dispmaxGui);
        
        // onDisplayMinMaxChanged takes original (maybe normalized) values
        onDisplayMinMaxChanged(dispmin, dispmax);
    }
Exemplo n.º 12
0
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;
        }
        
    }
}
Exemplo n.º 13
0
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;
}
Exemplo n.º 14
0
	virtual void init() {
	
		SceneMainLoop::init();


#if 0


		Viewport *vp = memnew( Viewport );
		vp->set_world( Ref<World>( memnew( World )));
		get_root()->add_child(vp);

		vp->set_rect(Rect2(0,0,256,256));
		vp->set_as_render_target(true);
		vp->set_render_target_update_mode(Viewport::RENDER_TARGET_UPDATE_ALWAYS);


		Camera *camera = memnew( Camera );
		vp->add_child(camera);
		camera->make_current();

		TestCube *testcube = memnew( TestCube );
		vp->add_child(testcube);
		testcube->set_transform(Transform( Matrix3().rotated(Vector3(0,1,0),Math_PI*0.25), Vector3(0,0,-8)));

		Sprite *sp = memnew( Sprite );
		sp->set_texture( vp->get_render_target_texture() );
//		sp->set_texture( ResourceLoader::load("res://ball.png") );
		sp->set_pos(Point2(300,300));
		get_root()->add_child(sp);


		return;
#endif

		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) );
		
		get_root()->add_child( frame );

		Label *label = memnew( Label );

		label->set_pos( Point2( 80,90 ) );
		label->set_size( Point2( 170,80 ) );
		label->set_align( Label::ALIGN_FILL );
		//label->set_text("There");
		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_pos( Point2( 20,20 ) );
		button->set_size( Point2( 1,1 ) );
		button->set_text("This is a biggie button");


		frame->add_child( button );


#if 0
		Sprite *tf = memnew( Sprite );
		frame->add_child(tf);
		Image img;
		ImageLoader::load_image("LarvoClub.png",&img);

		img.resize(512,512);
		img.generate_mipmaps();
		img.compress();
		Ref<Texture> text = memnew( Texture );
		text->create_from_image(img);
		tf->set_texture(text);
		tf->set_pos(Point2(50,50));
		//tf->set_scale(Point2(0.3,0.3));


		return;
#endif

		Tree * tree = memnew( Tree );
		tree->set_columns(2);

		tree->set_pos( 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);

		//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);		
				
		OptionButton *options = memnew( OptionButton );
		
		options->add_item("Hello, testing");
		options->add_item("My Dearest");
		
		options->set_pos( Point2( 230,180 ) );
		options->set_size( Point2( 1,1 ) );
		
		frame->add_child(options);		

		/*
		Tree * tree = memnew( Tree );
		tree->set_columns(2);
		
		tree->set_pos( 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 = 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 = 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);
		
		frame->add_child(tree);
*/


		RichTextLabel *richtext = memnew( RichTextLabel );

		richtext->set_pos( Point2( 600,210 ) );
		richtext->set_size( Point2( 180,250 ) );
		richtext->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,20);

		frame->add_child(richtext);


		richtext->add_text("Hello, My Friends!\n\nWelcome to the amazing world of ");

		richtext->add_newline();
		richtext->add_newline();

		richtext->push_color(Color(1,0.5,0.5));
		richtext->add_text("leprechauns");
		richtext->pop();
#if 0
		richtext->add_text(" and ");
		richtext->push_color(Color(0,1.0,0.5));
		richtext->add_text("faeries.\n");
		richtext->pop();
		richtext->add_text("In this new episode, we will attemp to ");
		richtext->push_font(richtext->get_font("mono_font","Fonts"));
		richtext->push_color(Color(0.7,0.5,1.0));
		richtext->add_text("deliver something nice");
		richtext->pop();
		richtext->pop();
		richtext->add_text(" to all the viewers! Unfortunately, I need to ");
		richtext->push_underline();
		richtext->add_text("keep writing a lot of text");
		richtext->pop();
		richtext->add_text(" so the label control overflows and the scrollbar appears.\n");
		//richtext->push_indent(1);
		//richtext->add_text("By the way, testing indent levels! Yohohoho! Everything should appear to the right sightly here!\n");
		//richtext->pop();
		richtext->push_meta("http://www.scrollingcapabilities.xz");
		richtext->add_text("This allows to test for the scrolling capabilities ");
		richtext->pop();
		richtext->add_text("of the rich text label for huge text (not like this text will really be huge but, you know).\nAs long as it is so long that it will work nicely for a test/demo, then it's welcomed in my book...\nChanging subject, the day is cloudy today and I'm wondering if I'll get che chance to travel somewhere nice. Sometimes, watching the clouds from satellite images may give a nice insight about how pressure zones in our planet work, althogh it also makes it pretty obvious to see why most weather forecasts get it wrong so often.\nClouds are so difficult to predict!\nBut it's pretty cool how our civilization has adapted to having water falling from the sky each time it rains...");
		//richtext->add_text("Hello!\nGorgeous..");
#endif

		//richtext->push_meta("http://www.scrollingcapabilities.xz");
		///richtext->add_text("Hello!\n");
		//richtext->pop();

		richtext->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END);


		TabContainer * tabc = memnew( TabContainer );

		Control *ctl= memnew( Control );
		ctl->set_name("tab 1");
		tabc->add_child(ctl);

		ctl= memnew( Control );
		ctl->set_name("tab 2");
		tabc->add_child(ctl);
		label = memnew( Label );
		label->set_text("Some Label");
		label->set_pos( Point2(20,20) );
		ctl->add_child(label);;

		ctl= memnew( Control );
		ctl->set_name("tab 3");
		button = memnew( Button );
		button->set_text("Some Button");
		button->set_pos( Point2(30,50) );
		ctl->add_child(button);;

		tabc->add_child(ctl);

		frame->add_child(tabc);
		
		tabc->set_pos( Point2( 400,210 ) );
		tabc->set_size( Point2( 180,250 ) );

		
		Ref<ImageTexture> text = memnew( ImageTexture );
		text->load("test_data/concave.png");

		Sprite* sprite = memnew(Sprite);
		sprite->set_texture(text);
		sprite->set_pos(Point2(300, 300));
		frame->add_child(sprite);
		sprite->show();

		Sprite* sprite2 = memnew(Sprite);
		sprite->set_texture(text);
		sprite->add_child(sprite2);
		sprite2->set_pos(Point2(50, 50));
		sprite2->show();
	}
Exemplo n.º 15
0
	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);


	}
Exemplo n.º 16
0
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
Exemplo n.º 17
0
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
Exemplo n.º 18
0
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);
    }
}
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();

}
void EditorTextureImportDialog::_import() {


//	ImportMonitorBlock imb;

	Vector<String> files=import_path->get_text().split(",");

	if (!files.size()) {

		error_dialog->set_text("Please specify some files!");
		error_dialog->popup_centered(Size2(200,100));
		return;
	}

	String dst_path=save_path->get_text();

	if (save_path->get_text().strip_edges()=="") {
		error_dialog->set_text("Target path is empty.");
		error_dialog->popup_centered_minsize();
		return;
	}

	if (!save_path->get_text().begins_with("res://")) {
		error_dialog->set_text("Target path must be full resource path.");
		error_dialog->popup_centered_minsize();
		return;
	}


	if (!atlas && !large && !DirAccess::exists(save_path->get_text())) {
		error_dialog->set_text("Target path must exist.");
		error_dialog->popup_centered_minsize();
		return;
	}

	if (atlas) { //atlas

		if (files.size()==0) {

			error_dialog->set_text("At least one file needed for Atlas.");
			error_dialog->popup_centered(Size2(200,100));
			return;

		}
		String dst_file = dst_path;
		//dst_file=dst_file.basename()+".tex";
		Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
		//imd->set_editor();
		for(int i=0;i<files.size();i++) {
			imd->add_source(EditorImportPlugin::validate_source_path(files[i]));
		}
		imd->set_option("format",texture_options->get_format());
		imd->set_option("flags",texture_options->get_flags());
		imd->set_option("quality",texture_options->get_quality());
		imd->set_option("atlas",true);
		imd->set_option("atlas_size",int(size->get_val()));
		imd->set_option("large",false);
		imd->set_option("crop",crop_source->is_pressed());

		Error err = plugin->import(dst_file,imd);
		if (err) {

			error_dialog->set_text("Error importing: "+dst_file.get_file());
			error_dialog->popup_centered(Size2(200,100));
			return;

		}
	} else if (large) { //atlas

		if (files.size()!=1) {

			error_dialog->set_text("Only one file is required for large texture");
			error_dialog->popup_centered(Size2(200,100));
			return;

		}
		String dst_file = dst_path;
		//dst_file=dst_file.basename()+".tex";
		Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
		//imd->set_editor();
		for(int i=0;i<files.size();i++) {
			imd->add_source(EditorImportPlugin::validate_source_path(files[i]));
		}
		imd->set_option("format",texture_options->get_format());
		imd->set_option("flags",texture_options->get_flags());
		imd->set_option("quality",texture_options->get_quality());
		imd->set_option("atlas",false);
		imd->set_option("large",true);
		imd->set_option("large_cell_size",int(size->get_val()));
		imd->set_option("crop",crop_source->is_pressed());

		Error err = plugin->import(dst_file,imd);
		if (err) {

			error_dialog->set_text("Error importing: "+dst_file.get_file());
			error_dialog->popup_centered(Size2(200,100));
			return;

		}
	} else {


		for(int i=0;i<files.size();i++) {

			String dst_file = dst_path.plus_file(files[i].get_file());
			dst_file=dst_file.basename()+".tex";
			Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
			//imd->set_editor();
			imd->add_source(EditorImportPlugin::validate_source_path(files[i]));
			imd->set_option("format",texture_options->get_format());
			imd->set_option("flags",texture_options->get_flags());
			imd->set_option("quality",texture_options->get_quality());
			imd->set_option("atlas",false);
			imd->set_option("large",false);

			Error err = plugin->import(dst_file,imd);
			if (err) {

				error_dialog->set_text("Error importing: "+dst_file.get_file());
				error_dialog->popup_centered(Size2(200,100));
				return;

			}
		}
	}

	hide();
}