Ejemplo n.º 1
1
void CloseColorDots::cycleThroughColors()
{
	colorIndex = updateValue(colorIndex, up, 0, maxColorIndex, cycles);
	
	for (int n=0;n<countFoos();n++)
	{
		int tmpIndex = updateValueBy(colorIndex, up, n, 0, maxColorIndex, cycles);
		
		foos.entry(n)->me->fLEDs.entry(0)->me->color.calculateRGB(maxColorIndex, tmpIndex);
	}
}
Ejemplo n.º 2
0
/*! Returns `true` if the value of the ModuleParameter has been updated since the last time
this function was called. This should be called right after updateValue() or with `checkForUpdates = true`.
Updates to the value resulting from assignment of a new value with `operator=()` count as updates
to the value.

If you don't care whether the value has been updated before using it, don't call this function.
Instead, just use updateValue() and getValue().

\param checkForUpdates Check for updates before determining whether the value has been updated.
\return `true` if the value has been updated since the last check.
*/
bool ModuleParameter::valueUpdated(bool checkForUpdates) {
	if (checkForUpdates) {
		updateValue();
	}

	if (_updated) {
		_updated = false;
		return true;
	}
	return false;
}
Ejemplo n.º 3
0
/*long int next_int()
{
        long int n = 0;
        char c = getchar();
        while (!('0' <= c && c <= '9'))
        {
                c = getchar();
        }
        while ('0' <= c && c <= '9')
        {
                n = (n<<3)+(n<<1) + c - '0';
                c = getchar();
        }
        return n;
}

*/
int main()
{
 ios_base::sync_with_stdio(false);
	char c[100005];
    int arr[100005],count,i,s,j;
	long int n,q;
cin>>n>>q;
	//n=next_int();
    //q=next_int();
	cin>>c;


for(i=0;i<n;i++)
{
	arr[i]=(c[i]-'0');
}
	
	 int *st = constructST(arr, n);

	while(q--)

	{

		long int a,b,d;

	//	a=next_int();
      //  b=next_int();
      //  d=next_int();
	cin>>a>>b>>d;
		if(a==1)

		{
			    updateValue(arr, st, n, b-1, d);

	}
		else
		{
		count=0;	
		for(i=b-1;i<d;i++)
		{
		for(j=i;j<d;j++)	
		{
		s=getSum(st, n, i, j);

if(s%3==0)
count++;
         }
	
	}
		cout<<count<<"\n";
		}
	}
	return 0;
}
Ejemplo n.º 4
0
AccountWindow::IntegerOption::IntegerOption(PurpleAccount *account_,
    PurpleAccountOption *option_)
: Button(FLAG_VALUE), account(account_), option(option_)
{
  g_assert(account);
  g_assert(option);

  setText(purple_account_option_get_text(option));
  updateValue();
  signal_activate.connect(sigc::mem_fun(this, &IntegerOption::onActivate));
}
Ejemplo n.º 5
0
void
Animation::restart()
{
    forward = true;
    updateValue(0.);
    started = currentTimeMillis();

    if (timer == NULL) {
        timer = new Timer(10, Animation_TimerCallback, (void*)this);
    }
}
 void update(float t) {
   
     
     hasStarted = (t >= startTime);
     hasEnded = (t >= endTime);
     
     if(isAlive) updateValue(t);
     
     if(hasEnded) isAlive = false;
     
 };
Ejemplo n.º 7
0
void MovingFoo::move(bool direction)
{
	if (hasLEDs())
	{
		for (int n=0;n<countLEDs();n++)
		{
			byte addr = fLEDs.entry(n)->me->address;
			addr = updateValue(addr, direction, 0, 31, cycles);
			fLEDs.entry(n)->me->address = addr;
		}
	}
}
Ejemplo n.º 8
0
void AccountWindow::StringOption::initialize()
{
  if (type == TYPE_PASSWORD)
    setText(_("Password"));
  else if (type == TYPE_ALIAS)
    setText(_("Alias"));
  else
    setText(purple_account_option_get_text(option));

  updateValue();
  signal_activate.connect(sigc::mem_fun(this, &StringOption::onActivate));
}
Ejemplo n.º 9
0
bool Slider::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
{
    State state = getState();

    switch (evt)
    {
    case Touch::TOUCH_PRESS:
        updateValue(x, y);
        return true;

    case Touch::TOUCH_MOVE:
        if (state == ACTIVE)
        {
            updateValue(x, y);
            return true;
        }
        break;
    }

    return Control::touchEvent(evt, x, y, contactIndex);
}
Ejemplo n.º 10
0
// Textual value change notification.
void qtractorTimeSpinBox::valueChangedSlot ( const QString& sText )
{
#ifdef CONFIG_DEBUG_0
	qDebug("qtractorTimeSpinBox[%p]::valueChangedSlot(\"%s\")",
		this, sText.toUtf8().constData());
#endif

	// Kind of interim fixup.
	if (updateValue(valueFromText(sText), false)) {
		// Just forward this one...
		emit valueChanged(sText);
	}
}
Ejemplo n.º 11
0
//BEGIN Class PropertyEditorItem
PropertyEditorItem::PropertyEditorItem( PropertyEditorItem * par, Property * property )
	: KListViewItem( par, property->editorCaption(), property->displayString() )
{
	setExpandable( false );
	m_property=property;
	connect( m_property, SIGNAL(valueChanged( QVariant, QVariant )), this, SLOT(propertyValueChanged()) );

	updateValue();

	//3 rows per item is enough?
	setMultiLinesEnabled( true );
	setHeight(static_cast<PropertyEditor*>(listView())->baseRowHeight()*3);
}
Ejemplo n.º 12
0
void BatteryFoo::grow()
{
	// set the color of each subsequent LED as some range from red to green
	// this is a bit of a hack, but it works and looks cool.
	// calculateRGB is the same function used to create a rainbow line of
	//	arbitrary length.
	Color tmpColor = Color(LITColor.black);
	tmpColor.calculateRGB(96, valueCounter);
	
	addLEDs(tmpColor, maxBrightness, valueCounter, valueCounter);
	
	valueCounter = updateValue(valueCounter, up, 0, value, !cycles);
}
Ejemplo n.º 13
0
	ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp)
	:	super_t(fontp),
		name("name"),
		size("size"),
		style("style")
	{
		if (!fontp)
		{
			updateValue(LLFontGL::getFontDefault());
		}
		addSynonym(name, "");
		updateBlockFromValue(false);
	}
Ejemplo n.º 14
0
	void FloatEntry::setValue(double val)
	{
		if (_log)
		{
			if (val == 0.0f)
				_value = _minValue;
			else
				_value = fast_log10(val) * 20.0f;
		}
		else
			_value = val;
		updateValue();
	}
Ejemplo n.º 15
0
	void ParamValue<const LLFontGL*>::updateValueFromBlock()
	{
		const LLFontGL* res_fontp = LLFontGL::getFontByName(name);
		if (res_fontp)
		{
			updateValue(res_fontp);
			return;
		}

		U8 fontstyle = 0;
		fontstyle = LLFontGL::getStyleFromString(style());
		LLFontDescriptor desc(name(), size(), fontstyle);
		const LLFontGL* fontp = LLFontGL::getFont(desc);
		if (fontp)
		{
			updateValue(fontp);
		}
		else
		{
			updateValue(LLFontGL::getFontDefault());
		}
	}
Ejemplo n.º 16
0
// Pseudo-fixup slot.
void qtractorTimeSpinBox::editingFinishedSlot (void)
{
#ifdef CONFIG_DEBUG_0
	qDebug("qtractorTimeSpinBox[%p]::editingFinishedSlot()", this);
#endif

	if (m_iValueChanged > 0) {
		// Kind of final fixup.
		if (updateValue(valueFromText(), true)) {
			// Rephrase text display...
			updateText();
		}
	}
}
Ejemplo n.º 17
0
void GConfItemQmlProxy::setKey(const QString &newKey)
{
#ifndef QT_SIMULATOR
   if (_gconfItem) {
       delete _gconfItem;
   }
   _gconfItem = new GConfItem(newKey);
#endif
   _key = newKey;

#ifndef QT_SIMULATOR
   connect(_gconfItem, SIGNAL(valueChanged()), this, SLOT(updateValue()));
#endif
}
Ejemplo n.º 18
0
static void print(void)
{
	stopLcdScroll(0);
	clearLcdLine(0);

	strcpy_P(buffer, (char *) pgm_read_word(&(strings[OPTION_1 + selectedOption])));

	if (stringsSizes[OPTION_1 + selectedOption] > 16)
		newLcdScroll(buffer, 0, 200);
	else
		printLcd(8 - stringsSizes[OPTION_1 + selectedOption], 0, buffer);

	updateValue();
}
Ejemplo n.º 19
0
void TCPJwL::listen()
{
	if (audio.beats.detected())
	{
		baseCycler = updateValue(baseCycler, up, 0, 2, cycles);
		
		TwoColorParticleJam* x = (TwoColorParticleJam*)foos.entry(0)->me;
		
		int a1 = baseCycler;
		int a2 = baseCycler+3;
		
		x->changeColors(*LITColor.colorList[a1],*LITColor.colorList[a2]);
	}
}
Ejemplo n.º 20
0
MemoryTablePrivate::Error MemoryTablePrivate::insert(const key_type &key, const value_type &value, TableMetadata *table)
{
    const quint32 valueSize = dataSize(value);

    IndexElement *tableEnd = end(table);
    IndexElement *position = std::lower_bound(begin(table), tableEnd, key);
    if (position != tableEnd && position->key == key) {
        // This is a replacement - the item has an allocation already
        Allocation *allocation = allocationAt(position->offset, table);
        if (allocation->size < requiredSpace(valueSize)) {
            // Replace the existing allocation with a bigger one
            quint32 newOffset = allocate(valueSize, table, false);
            if (!newOffset)
                return MemoryTable::InsufficientSpace;

            deallocate(position->offset, table);
            position->offset = newOffset;
        } else {
            // Reuse this allocation
            // TODO: swap with a better fit from the free list?
        }
    } else {
        // This item needs to be added to the index
        if (table->count == std::numeric_limits<quint32>::max())
            return MemoryTable::InsufficientSpace;

        quint32 offset = allocate(valueSize, table, true);
        if (!offset)
            return MemoryTable::InsufficientSpace;

        // For index insertion, move the displaced elements of the index
        if (position != tableEnd)
            std::memmove(position + 1, position, (tableEnd - position) * sizeof(IndexElement));

        ++(table->count);
        position->key = key;
        position->offset = offset;
    }

    Q_ASSERT(contains(key, table));

    // Ensure that the data allocation does not overlap the index space
    Q_ASSERT((reinterpret_cast<char *>(table) + table->freeOffset) >= reinterpret_cast<char *>(end(table)));

    // Update the value stored at the position
    updateValue(value, valueSize, position->offset, table);

    return MemoryTable::NoError;
}
Ejemplo n.º 21
0
CertificateDialog::CertificateDialog(QList<QSslCertificate> certificates, QWidget *parent) : Dialog(parent),
	m_certificates(certificates),
	m_ui(new Ui::CertificateDialog)
{
	m_ui->setupUi(this);
	m_ui->buttonBox->button(QDialogButtonBox::Save)->setText(tr("Export…"));

	if (certificates.isEmpty())
	{
		setWindowTitle(tr("Invalid Certificate"));

		return;
	}

	setWindowTitle(tr("View Certificate for %1").arg(certificates.first().subjectInfo(QSslCertificate::CommonName).join(QLatin1String(", "))));

	QStandardItemModel *chainModel(new QStandardItemModel(this));
	QStandardItem *certificateItem(nullptr);

	for (int i = (certificates.count() - 1); i >= 0; --i)
	{
		QStandardItem *parentCertificateItem(certificateItem);

		certificateItem = new QStandardItem(certificates.at(i).subjectInfo(QSslCertificate::Organization).value(0, tr("Unknown")));
		certificateItem->setData(i, Qt::UserRole);

		if (parentCertificateItem)
		{
			parentCertificateItem->appendRow(certificateItem);
		}
		else
		{
			chainModel->appendRow(certificateItem);
		}
	}

	m_ui->chainItemView->setViewMode(ItemViewWidget::TreeViewMode);
	m_ui->chainItemView->setModel(chainModel);
	m_ui->chainItemView->expandAll();
	m_ui->chainItemView->setCurrentIndex(chainModel->index(0, 0));
	m_ui->detailsItemView->setViewMode(ItemViewWidget::TreeViewMode);
	m_ui->detailsItemView->setModel(new QStandardItemModel(this));

	updateCertificate();

	connect(m_ui->chainItemView, SIGNAL(needsActionsUpdate()), this, SLOT(updateCertificate()));
	connect(m_ui->detailsItemView, SIGNAL(needsActionsUpdate()), this, SLOT(updateValue()));
	connect(m_ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked(bool)), this, SLOT(exportCertificate()));
}
Ejemplo n.º 22
0
void ScrollBar::update(uint16_t x1, uint16_t y1, uint16_t z) {
	bool press = false;
	if (z > MINPRESSURE && z < MAXPRESSURE) press = true;



	if (press) {
		if (x < x1 && x1 < (x + size) && y < y1 && y1 < (y + size)) {
			pressedL = true;
			lastpressed = millis();
			updateValue();
		}
		uint16_t v = width + pageW + size + x;
		if (( v ) < x1 && x1 < (v+size)  && y < y1 && y1 < (y + size)) 
		{
			pressedR = true;
			lastpressed = millis();
			updateValue();
		}
	}

	if (millis() - lastpressed > 200) {
		pressedR = false;
		pressedL = false;
	}

	if (pressedR != opressedR || pressedL != opressedL ) { 	// some buttons state changed										
		reDrawButtons();
		opressedR = pressedR;
		opressedL = pressedL;
	
		//if (handler != 0) handler->callBack1(pressed, ID);
		return;
	}
	//if (pressed && handler != 0)  handler->callBack2(pressed, ID);     // continouse pressing 
}
Ejemplo n.º 23
0
void
Animation::rewind()
{
    forward = false;

    if (timer != NULL) {
        int elapsed = currentTimeMillis() - started;
        int remaining = duration - elapsed;
        started = currentTimeMillis() - remaining;
    } else {
        updateValue(1.);
        started = currentTimeMillis();
        timer = new Timer(10, Animation_TimerCallback, (void*)this);
    }
}
Ejemplo n.º 24
0
int RoundRectItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: activated(); break;
        case 1: updateValue((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
Ejemplo n.º 25
0
void Dial::setupUi()
{
	QDial::setCursor(Qt::PointingHandCursor);

	connect(this, &QDial::valueChanged,
			this, &Dial::updateValue);

	setMinimumSize(100,100);

	setMaximumAngle(-360);

	setStartAngle(270);

	updateValue();
}
Ejemplo n.º 26
0
	void FloatEntry::setSValue(const QString& s)
	{
		bool ok;
		double v = s.toFloat(&ok);
		if (ok && (v != _value))
		{
			if (v < _minValue)
				v = _minValue;
			if (v > _maxValue)
				v = _maxValue;
			_value = v;
			updateValue();
			valueChange();
		}
	}
Ejemplo n.º 27
0
	FloatEntry::FloatEntry(QWidget* parent)
	: QLineEdit(parent)
	{
		_id = 0;
		_minValue = 0.0;
		_maxValue = 1.0;
		_log = false;
		evx = 1.0;
		_precision = 3;
		timer = new QTimer(this);
		connect(timer, SIGNAL(timeout()), SLOT(repeat()));
		_value = 0.0f;
		connect(this, SIGNAL(returnPressed()), SLOT(endEdit()));
		setCursor(QCursor(Qt::ArrowCursor));
		updateValue();
	}
Ejemplo n.º 28
0
/*!
 * \brief Focus out event handler.
 *
 * This updates the geometry of parameter group, validates
 * the text and also clears the selection.
 */
void PropertyItem::focusOutEvent(QFocusEvent *event)
{
    if(m_edited) {
        updateValue();
    }

    qApp->removeEventFilter(this);

    // Clear the text selection
    QTextCursor c = textCursor();
    c.clearSelection();
    setTextCursor(c);
    disconnect(document(), SIGNAL(contentsChanged()), this,
            SLOT(textChanged()));

    QGraphicsTextItem::focusOutEvent(event);
}
Ejemplo n.º 29
0
void GuiInspectorDynamicField::setData( const char* data, bool callbacks )
{
   if ( mDynField == NULL )
      return;
   
   const U32 numTargets = mInspector->getNumInspectObjects();
   if( callbacks && numTargets > 1 )
   { mInspector->beginCompoundUndo_callback(); }
      
   // Setting an empty string will kill the field.
   const bool isRemoval = !data[ 0 ];
      
   for( U32 i = 0; i < numTargets; ++ i )
   {
      SimObject* target = mInspector->getInspectObject( i );

      // Callback on the inspector when the field is modified
      // to allow creation of undo/redo actions.
      const char *oldData = target->getDataField( mDynField->slotName, NULL );
      if ( !oldData )
         oldData = "";
      if ( dStrcmp( oldData, data ) != 0 )
      {
         target->inspectPreApply();
         
         if( callbacks )
         {
            if( isRemoval )
            { mInspector->onFieldRemoved_callback( target->getIdString(), mDynField->slotName ); }
            else
            { mInspector->onInspectorFieldModified_callback( target->getIdString(), mDynField->slotName,"(null)", oldData, data ); }
         }

         target->setDataField( mDynField->slotName, NULL, data );

         // give the target a chance to validate
         target->inspectPostApply();
      }
   }
   
   if( callbacks && numTargets > 1 )
   { mInspector->endCompoundUndo_callback(); }

   // Force our edit to update
   updateValue();
}
void ShortIntValueFieldWidget::refreshImpl()
{
    assert(m_ui.m_serValueLineEdit != nullptr);
    updateValue(*m_ui.m_serValueLineEdit, m_wrapper->getSerialisedString());

    auto value = adjustRealToDisplayed(m_wrapper->getValue());
    assert(m_ui.m_valueSpinBox);
    if (m_ui.m_valueSpinBox->value() != value) {
        m_ui.m_valueSpinBox->setValue(value);
    }

    bool valid = m_wrapper->valid();
    setValidityStyleSheet(*m_ui.m_nameLabel, valid);
    setValidityStyleSheet(*m_ui.m_serFrontLabel, valid);
    setValidityStyleSheet(*m_ui.m_serValueLineEdit, valid);
    setValidityStyleSheet(*m_ui.m_serBackLabel, valid);
}