Esempio n. 1
0
static void iio_spin_button_update_value(struct iio_widget *widget,
		const char *src, size_t len)
{
	gdouble freq, mag, min, max;
	gdouble scale = widget->priv ? *(gdouble *)widget->priv : 1.0;
	char *end;

	mag = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget->widget));
	gtk_spin_button_get_range(GTK_SPIN_BUTTON(widget->widget), &min, &max);

	freq = g_ascii_strtod(src, &end);
	if (end == src)
		return;

	if (widget->priv_convert_function)
		freq = ((double (*)(double, bool))widget->priv_convert_function)(freq, true);

	freq /= fabs(scale);

	/* if scale is negative, we treat things a little differently */
	if (scale < 0) {
		/* if the setting is negative, and it can be set negative */
		if (mag < 0 && min < 0)
			freq *= -1;
		else if (min >= 0)
			freq *= -1;
	}

	gtk_spin_button_set_value(GTK_SPIN_BUTTON (widget->widget), freq);
}
Esempio n. 2
0
int wxSpinButton::GetMax() const
{
    wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") );

    double max;
    gtk_spin_button_get_range((GtkSpinButton*)m_widget, NULL, &max);
    return int(max);
}
Esempio n. 3
0
static VALUE
rg_range(VALUE self)
{
    gdouble min, max;
    gtk_spin_button_get_range(_SELF(self), &min, &max);

    return rb_ary_new3(2, rb_float_new(min), rb_float_new(max));
}
Esempio n. 4
0
double wxSpinCtrlGTKBase::DoGetMax() const
{
    wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") );

    double max = 0;
    gtk_spin_button_get_range( GTK_SPIN_BUTTON(m_widget), NULL, &max);
    return max;
}
Esempio n. 5
0
int wxSpinCtrl::GetMax() const
{
    wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") );

    double max;
    gtk_spin_button_get_range( GTK_SPIN_BUTTON(m_widget), NULL, &max);
    return int(max);
}
Esempio n. 6
0
int
clip_GTK_SPINBUTTONGETRANGE(ClipMachine * ClipMachineMemory)
{
   C_widget *cspb = _fetch_cw_arg(ClipMachineMemory);

   gdouble   min, max;

   CHECKCWID(cspb, GTK_IS_SPIN_BUTTON);

   gtk_spin_button_get_range(GTK_SPIN_BUTTON(cspb->widget), &min, &max);

   _clip_stornd(ClipMachineMemory, min, 2, 0);
   _clip_stornd(ClipMachineMemory, max, 3, 0);
   return 0;
 err:
   return 1;
}
Esempio n. 7
0
static void iio_spin_button_update(struct iio_widget *widget)
{
	gdouble freq, mag, min, max;
	gdouble scale = widget->priv ? *(gdouble *)widget->priv : 1.0;

	mag = gtk_spin_button_get_value(GTK_SPIN_BUTTON (widget->widget));
	gtk_spin_button_get_range(GTK_SPIN_BUTTON (widget->widget), &min, &max);
	read_devattr_double(widget->attr_name, &freq);
	freq /= fabs(scale);

	/* if scale is negative, we treat things a little differently */
	if (scale < 0) {
		/* if the setting is negative, and it can be set negative */
		if (mag < 0 && min < 0)
			freq *= -1;
	}

	gtk_spin_button_set_value(GTK_SPIN_BUTTON (widget->widget), freq);
}
Esempio n. 8
0
static void
change_unit (GtkSpinButton *spinbutton,
             gdouble factor,
             gint digits,
             gdouble step,
             gdouble page)
{
    gdouble value;
    gdouble range;

    gtk_spin_button_get_range (spinbutton, NULL, &range);
    range *= factor;

    value = gtk_spin_button_get_value (spinbutton);
    value *= factor;

    gtk_spin_button_set_range (spinbutton, 0, range);
    gtk_spin_button_set_value (spinbutton, value);
    gtk_spin_button_set_digits (spinbutton, digits);
    gtk_spin_button_set_increments  (spinbutton, step, page);
}
Esempio n. 9
0
static void up_down_converter_toggled_cb(GtkToggleButton *button, gpointer data)
{
	static gint rx_updn_hid, tx_updn_hid;
	static gdouble lo_min, lo_max;
	static void (*rx_lo_update_value)(struct iio_widget *, const char *, size_t);
	static void (*tx_lo_update_value)(struct iio_widget *, const char *, size_t);

	if (gtk_toggle_button_get_active(button)) {
		iio_spin_button_progress_deactivate(&rx_widgets[rx_lo]);
		iio_spin_button_progress_deactivate(&tx_widgets[tx_lo]);
		rx_updn_hid = g_signal_connect(rx_widgets[rx_lo].widget, "value-changed",
			G_CALLBACK(updn_converter_lo_freq_changed_cb), (gpointer)UPDN_RX);
		tx_updn_hid = g_signal_connect(tx_widgets[tx_lo].widget, "value-changed",
			G_CALLBACK(updn_converter_lo_freq_changed_cb), (gpointer)UPDN_TX);
		gtk_spin_button_get_range(GTK_SPIN_BUTTON(rx_widgets[rx_lo].widget), &lo_min, &lo_max);
		gtk_spin_button_set_range(GTK_SPIN_BUTTON(rx_widgets[rx_lo].widget), 1, 100);
		gtk_spin_button_set_range(GTK_SPIN_BUTTON(tx_widgets[tx_lo].widget), 1, 100);
		rx_lo_update_value = rx_widgets[rx_lo].update_value;
		tx_lo_update_value = tx_widgets[tx_lo].update_value;
		rx_widgets[rx_lo].update_value = NULL;
		tx_widgets[tx_lo].update_value = NULL;
	} else {
		g_signal_handler_disconnect(rx_widgets[rx_lo].widget, rx_updn_hid);
		g_signal_handler_disconnect(tx_widgets[tx_lo].widget, tx_updn_hid);
		rx_widgets[rx_lo].update_value = rx_lo_update_value;
		tx_widgets[tx_lo].update_value = tx_lo_update_value;
		iio_spin_button_progress_activate(&rx_widgets[rx_lo]);
		iio_spin_button_progress_activate(&tx_widgets[tx_lo]);
		g_signal_emit_by_name(rx_widgets[rx_lo].widget,
			"value-changed", NULL);
		g_signal_emit_by_name(tx_widgets[tx_lo].widget,
			"value-changed", NULL);
		gtk_spin_button_set_range(GTK_SPIN_BUTTON(rx_widgets[rx_lo].widget), lo_min, lo_max);
		gtk_spin_button_set_range(GTK_SPIN_BUTTON(tx_widgets[tx_lo].widget), lo_min, lo_max);
	}
}
Esempio n. 10
0
static	void	vj_midi_send_vims_now( vmidi_t *v, int *data )
{
	// format vims message and send it now
	// it would be nice to filter out unique events per frame step
	
	// this can be done by keeping a temporary vevo port
	// and store (instead of send) the VIMS message
	// including the sample_id and chain_entry_id but
	// cutting off all other arguments.
	// then, last SET_SPEED will overwrite any previous ones for this frame step.
	//
	// last, send all messages in temporary port out and cleanup

	char key[32];

	if( v->learn )
	{
		veejay_memcpy( v->learn_event, data, sizeof(v->learn_event ));
		vj_msg(VEEJAY_MSG_INFO, "MIDI %x:%x,%x -> ?", v->learn_event[0],v->learn_event[1],
			v->learn_event[2]);
		return;
	}

	snprintf(key,sizeof(key), "%03d%03d", data[0],data[1] ); //@ event key is midi event type + midi control/param id

	dvims_t *d = NULL;
	int error = vevo_property_get( v->vims, key, 0, &d);
	if( error == VEVO_NO_ERROR )
	{
		if( d->extra )
		{	//@ argument is dynamic
			double min = 0.0;
			double max = 0.0;
			double val = 0.0;
			switch(d->extra)
			{
				case 1: //slider
				{
					GtkAdjustment *a = gtk_range_get_adjustment( GTK_RANGE(
							glade_xml_get_widget_( v->mw, d->widget ) ) );
					
					min = a->lower;
					max = a->upper;
				}
				break;
				case 2: //spinbox
					gtk_spin_button_get_range( GTK_SPIN_BUTTON(
							glade_xml_get_widget_( v->mw, d->widget)), &min, &max);
				
				break;
			}
			
			if( data[0] == SND_SEQ_EVENT_PITCHBEND )
			{
				val =  ( (data[2]/16384.0f) * (max-min) );
			}
			else if( data[0] == SND_SEQ_EVENT_CONTROLLER || data[0] == SND_SEQ_EVENT_KEYPRESS )
			{
				val = ((max-min)/127.0) * data[2] + min;
			}
		   	else {
				vj_msg(VEEJAY_MSG_INFO, "MIDI: what's this %x,%x,%x ?",data[0],data[1],data[2]);
				return;
			}

			char vims_msg[255];
			snprintf(vims_msg,sizeof(vims_msg), "%s %d;", d->msg, (int) val );

			/* use control/param as sample_id */
			int tmpv[3];
			if ( sscanf(vims_msg, "%03d:%d %d;",&tmpv[0],&tmpv[1],&tmpv[2]) == 3 )
			{
			    if(tmpv[1] == 0 && tmpv[0] >= 100 && tmpv[0] < 200) //@ VIMS: sample events, replace 0 (current_id) for control/param number
			    {
				snprintf(vims_msg,sizeof(vims_msg),"%03d:%d %d;", tmpv[0], data[1], (int)val);
			    	veejay_msg(VEEJAY_MSG_DEBUG, "(midi) using control/param %d as sample identifer",data[1]);
			    }	    
			}

			msg_vims( vims_msg );
			vj_msg(VEEJAY_MSG_INFO, "MIDI %x:%x, %x ->  vims %s", data[0], data[1],data[2], vims_msg);
		}
		else
		{
			msg_vims( d->msg );
			vj_msg(VEEJAY_MSG_INFO, "MIDI %x: %x,%x -> vims %s", data[0],data[1],data[2], d->msg);
		}
	}
	else
	{
		vj_msg(VEEJAY_MSG_ERROR, "No vims event for MIDI %x:%x,%x found",data[0],data[1],data[2]);
	}
}