Example #1
0
    Tempo_Point_Editor ( float *tempo ) : Fl_Menu_Window(  75, 58, "Edit Tempo" )
        {
            _sucess = false;
            _tempo = tempo;

            set_modal();

            Fl_Float_Input *fi = _fi = new Fl_Float_Input( 12, 0 + 24, 50, 24, "Tempo:" );
            fi->align( FL_ALIGN_TOP );
            fi->when( FL_WHEN_NOT_CHANGED | FL_WHEN_ENTER_KEY );
            fi->callback( &Tempo_Point_Editor::enter_cb, (void*)this );

            char pat[10];
            snprintf( pat, sizeof( pat ), "%.1f", *tempo );

            fi->value( pat );

            end();

            show();

            while ( shown() )
                Fl::wait();
        }
Example #2
0
Fl_Parameters_Manager::Fl_Parameters_Manager(int x, int y, int width, int height, Fl_MDI_Viewport *s, const char *name)
{
	Fl::lock();

	s->begin();
	Fl_MDI_Window *w = PWin = new Fl_MDI_Window(0, 0, width, height, name);
	w->user_data((void *)this);
	w->resizable(w->view());

	w->titlebar()->close_button()->hide();

	w->view()->begin();

	Parameters_Tabs = new Fl_Tabs*[Num_Tunable_Blocks];
	Input_Blocks = new Param_Input_Block_T [Num_Tunable_Parameters];

	for (int i = 0; i < Num_Tunable_Blocks; i++) {
		{ Fl_Tabs *o = Parameters_Tabs[i] = new Fl_Tabs(160, 5, width-165, height-70);
		  o->new_page("Block Parameters");
		  int tot_rows = 0;
		  if (i == Num_Tunable_Blocks - 1) {
		  	for (int j = 0; j < Num_Tunable_Parameters - Tunable_Blocks[i].offset; j++) {
				char scalar_val[20];
				char param_label[MAX_NAMES_SIZE + 10];
				int val_idx;
				unsigned int ncols = Tunable_Parameters[Tunable_Blocks[i].offset+j].n_cols;
				unsigned int nrows = Tunable_Parameters[Tunable_Blocks[i].offset+j].n_rows;
				Input_Blocks[Tunable_Blocks[i].offset+j].inputW = new Fl_Float_Input*[nrows*ncols];

				sprintf(param_label, "%s", Tunable_Parameters[Tunable_Blocks[i].offset+j].param_name);
				for (unsigned int nr = 0; nr < nrows; nr++) {
					for (unsigned int nc = 0; nc < ncols; nc++) {
		  				{ Fl_Float_Input *o = new Fl_Float_Input(10 + nc*110, 30 + (j+nr+tot_rows)*40, 100, 20, strdup(param_label));
						  param_label[0] = '\0';
			    	  		  o->align(FL_ALIGN_LEFT|FL_ALIGN_TOP);
				  		  o->when(FL_WHEN_ENTER_KEY);
						  sprintf(scalar_val, "%G", get_parameter(Tunable_Parameters[Tunable_Blocks[i].offset+j], nr, nc, &val_idx));
			    	  		  o->value(strdup(scalar_val));
						  p_idx_T *idx = new p_idx_T;
						  idx->block_idx = i;
						  idx->param_idx = j;
						  idx->val_idx = val_idx;
				  		  o->callback((Fl_Callback *)rlg_update_parameters_cb, (void *)idx);
						  Input_Blocks[Tunable_Blocks[i].offset+j].inputW[val_idx]=o;
						}
					}
				}
				tot_rows = tot_rows + nrows - 1;
			}
		  } else {
		  	for (int j = 0; j < Tunable_Blocks[i+1].offset-Tunable_Blocks[i].offset; j++) {
				char scalar_val[20];
				char param_label[MAX_NAMES_SIZE + 10];
				int val_idx;
				unsigned int ncols = Tunable_Parameters[Tunable_Blocks[i].offset+j].n_cols;
				unsigned int nrows = Tunable_Parameters[Tunable_Blocks[i].offset+j].n_rows;
				Input_Blocks[Tunable_Blocks[i].offset+j].inputW = new Fl_Float_Input*[nrows*ncols];
				sprintf(param_label, "%s", Tunable_Parameters[Tunable_Blocks[i].offset+j].param_name);
				for (unsigned int nr = 0; nr < nrows; nr++) {
					for (unsigned int nc = 0; nc < ncols; nc++) {
		  				{ Fl_Float_Input *o = new Fl_Float_Input(10 + nc*110, 30 + (j+nr+tot_rows)*40, 100, 20, strdup(param_label));
						  param_label[0] = '\0';
			    	  		  o->align(FL_ALIGN_LEFT|FL_ALIGN_TOP);
				  		  o->when(FL_WHEN_ENTER_KEY);
						  sprintf(scalar_val, "%G", get_parameter(Tunable_Parameters[Tunable_Blocks[i].offset+j], nr, nc, &val_idx));
			    	  		  o->value(strdup(scalar_val));
						  p_idx_T *idx = new p_idx_T;
						  idx->block_idx = i;
						  idx->param_idx = j;
						  idx->val_idx = val_idx;
						  o->callback((Fl_Callback *)rlg_update_parameters_cb, (void *)idx);
						  Input_Blocks[Tunable_Blocks[i].offset+j].inputW[val_idx]=o;
						}
					}
				}
				tot_rows = tot_rows + nrows - 1;
			}
		  }
		  o->end();
		  Fl_Group::current()->resizable(w);
		}
	}
	for (int i = 1; i < Num_Tunable_Blocks; i++) {
		Parameters_Tabs[i]->hide();
	}
	Parameters_Tabs[0]->show();

	Batch_Download = new Fl_Check_Button(width-270, height-60, 120, 25, "Batch Download");
	Batch_Download->callback((Fl_Callback *)batch_download_cb);
	Download = new Fl_Button(width-150, height-60, 70, 25, "Download");
	Download->callback((Fl_Callback *)rlg_batch_update_parameters_cb);
	Download->deactivate();
	Upload = new Fl_Button(width-75, height-60, 70, 25, "Upload");
	Upload->callback((Fl_Callback *)rlg_upload_parameters_cb);
//	Upload->deactivate();
	Help = new Fl_Button(width-150, height-30, 70, 25, "Help");
	Close = new Fl_Button(width-75, height-30, 70, 25, "Close");
	Close->callback((Fl_Callback *)close);

	Fl_Browser *o = Parameters_Tree = new Fl_Browser(5, 5, 150, height-10);
	o->indented(1);
	o->callback((Fl_Callback *)select_block);
	for (int i = 0; i < Num_Tunable_Blocks; i++) {
		add_paper(Parameters_Tree, Tunable_Blocks[i].name, Fl_Image::read_xpm(0, block_icon));
	}

	w->view()->end();

	s->end();

	w->titlebar()->h(15);
	w->titlebar()->color(FL_BLACK);
	w->position(x, y);

	Fl::unlock();
}
//----------------------------------------------------
// Constructor.  Creates all of the widgets.
// Add new widgets here
//----------------------------------------------------
ImpressionistUI::ImpressionistUI() {
	// Create the main window
	m_mainWindow = new Fl_Window(600, 300, "Impressionist");
		m_mainWindow->user_data((void*)(this));	// record self to be used by static callback functions
		// install menu bar
		m_menubar = new Fl_Menu_Bar(0, 0, 600, 25);
		m_menubar->menu(menuitems);

		// Create a group that will hold two sub windows inside the main
		// window
		Fl_Group* group = new Fl_Group(0, 25, 600, 275);

			// install paint view window
			m_paintView = new PaintView(300, 25, 300, 275, "This is the paint view");//0jon
			m_paintView->box(FL_DOWN_FRAME);

			// install original view window
			m_origView = new OriginalView(0, 25, 300, 275, "This is the orig view");//300jon
			m_origView->box(FL_DOWN_FRAME);
			// m_origView->deactivate();

		group->end();
		Fl_Group::current()->resizable(group);
    m_mainWindow->end();

	// init values

	m_nSize = 10;
	m_nAngle = 45;
	m_nAlpha = 255;
	m_nBackgroundAlpha = 100;

	// brush dialog definition
	m_brushDialog = new Fl_Window(400, 325, "Brush Dialog");
		// Add a brush type choice to the dialog
		m_BrushTypeChoice = new Fl_Choice(50,10,150,25,"&Brush");
		m_BrushTypeChoice->user_data((void*)(this));	// record self to be used by static callback functions
		m_BrushTypeChoice->menu(brushTypeMenu);
		m_BrushTypeChoice->callback(cb_brushChoice);

		m_ClearCanvasButton = new Fl_Button(240,10,150,25,"&Clear Canvas");
		m_ClearCanvasButton->user_data((void*)(this));
		m_ClearCanvasButton->callback(cb_clear_canvas_button);

		m_transparentBackgroundButton = new Fl_Button(130,280,150,25,"&Show Background");
		m_transparentBackgroundButton->user_data((void*)(this));
		m_transparentBackgroundButton->callback(cb_transparentBackground);

		m_edgeImageButton = new Fl_Button(130,180,150,25,"&Toggle Edge Image");
		m_edgeImageButton->user_data((void*)(this));
		m_edgeImageButton->callback(cb_edgeImage);

		//Add angle choice menu
		Fl_Choice * myChoice = new Fl_Choice(95,60,150,25,"&Angle Choice");
		myChoice->user_data((void*)(this));	 // record self to be used by static callback functions
		myChoice->menu(angleChoiceMenu);
		myChoice->callback(cb_angleChoice);

		// Add brush size slider to the dialog 
		m_BrushSizeSlider = new Fl_Value_Slider(10, 100, 300, 20, "Size");
		m_BrushSizeSlider->user_data((void*)(this));	// record self to be used by static callback functions
		m_BrushSizeSlider->type(FL_HOR_NICE_SLIDER);
        m_BrushSizeSlider->labelfont(FL_COURIER);
        m_BrushSizeSlider->labelsize(12);
		m_BrushSizeSlider->minimum(1);
		m_BrushSizeSlider->maximum(40);
		m_BrushSizeSlider->step(1);
		m_BrushSizeSlider->value(m_nSize);
		m_BrushSizeSlider->align(FL_ALIGN_RIGHT);
		m_BrushSizeSlider->callback(cb_sizeSlides);

		// Add brush angle slider to the dialog 
		m_BrushSizeSlider = new Fl_Value_Slider(10, 120, 300, 20, "Angle");
		m_BrushSizeSlider->user_data((void*)(this));	// record self to be used by static callback functions
		m_BrushSizeSlider->type(FL_HOR_NICE_SLIDER);
        m_BrushSizeSlider->labelfont(FL_COURIER);
        m_BrushSizeSlider->labelsize(12);
		m_BrushSizeSlider->minimum(0);
		m_BrushSizeSlider->maximum(180);
		m_BrushSizeSlider->step(1);
		m_BrushSizeSlider->value(m_nAngle);
		m_BrushSizeSlider->align(FL_ALIGN_RIGHT);
		m_BrushSizeSlider->callback(cb_angleSlides);

		// Add brush angle slider to the dialog 
		m_BrushSizeSlider = new Fl_Value_Slider(10, 140, 300, 20, "Opacity");
		m_BrushSizeSlider->user_data((void*)(this));	// record self to be used by static callback functions
		m_BrushSizeSlider->type(FL_HOR_NICE_SLIDER);
        m_BrushSizeSlider->labelfont(FL_COURIER);
        m_BrushSizeSlider->labelsize(12);
		m_BrushSizeSlider->minimum(0);
		m_BrushSizeSlider->maximum(255);
		m_BrushSizeSlider->step(1);
		m_BrushSizeSlider->value(m_nAlpha);
		m_BrushSizeSlider->align(FL_ALIGN_RIGHT);
		m_BrushSizeSlider->callback(cb_alphaSlides);

		// Add brush angle slider to the dialog 
		m_BrushSizeSlider = new Fl_Value_Slider(10, 250, 300, 20, "Background\nOpacity");
		m_BrushSizeSlider->user_data((void*)(this));	// record self to be used by static callback functions
		m_BrushSizeSlider->type(FL_HOR_NICE_SLIDER);
        m_BrushSizeSlider->labelfont(FL_COURIER);
        m_BrushSizeSlider->labelsize(12);
		m_BrushSizeSlider->minimum(0);
		m_BrushSizeSlider->maximum(255);
		m_BrushSizeSlider->step(1);
		m_BrushSizeSlider->value(m_nBackgroundAlpha);
		m_BrushSizeSlider->align(FL_ALIGN_RIGHT);
		m_BrushSizeSlider->callback(cb_backgroundAlphaSlides);

    m_brushDialog->end();	

    // filter dialog definition 
    std::fill(fltKernel,fltKernel+(FLT_WIDTH*FLT_HEIGHT)-1,0.0f);
    // m_nScale = 1.0f;
    // m_nOffset = 0.0f;
    m_filterDialog = new Fl_Window(400, 200, "Filter Dialog");

    	m_BrushTypeChoice = new Fl_Choice(150,10,150,25,"&Select Source");
		m_BrushTypeChoice->user_data((void*)(this));	// record self to be used by static callback functions
		m_BrushTypeChoice->menu(filterChoiceMenu);
		m_BrushTypeChoice->callback(cb_filterChoice);

    	m_ApplyFilterButton = new Fl_Button(30,170,100,25,"&Apply Filter");
		m_ApplyFilterButton->user_data((void*)(this));
		m_ApplyFilterButton->callback(cb_apply_filter_button);

		m_PreviewFilterButton = new Fl_Button(150,170,100,25,"&Preview Filter");
		m_PreviewFilterButton->user_data((void*)(this));
		m_PreviewFilterButton->callback(cb_preview_filter_button);

		m_CancelFilterButton = new Fl_Button(270,170,100,25,"&Cancel");
		m_CancelFilterButton->user_data((void*)(this));
		m_CancelFilterButton->callback(cb_cancel_filter_button);

		Fl_Float_Input* scaleInput = new Fl_Float_Input(50, 80, 40, 20,"&Scale");
		scaleInput->user_data((void*)(this)); 
		scaleInput->callback(cb_scaleInput);
		
		Fl_Float_Input* offsetInput = new Fl_Float_Input(50, 100, 40, 20,"&Offset");
		offsetInput->user_data((void*)(this)); 
		offsetInput->callback(cb_offsetInput);

    	Fl_Float_Input* filterInput_00 = new Fl_Float_Input(100, 50, 50, 20);
		filterInput_00->user_data((void*)(this)); 
		filterInput_00->callback(cb_filterInput_00);

		Fl_Float_Input* filterInput_01 = new Fl_Float_Input(150, 50, 50, 20);
		filterInput_01->user_data((void*)(this)); 
		filterInput_01->callback(cb_filterInput_01);

		Fl_Float_Input* filterInput_02 = new Fl_Float_Input(200, 50, 50, 20);
		filterInput_02->user_data((void*)(this)); 
		filterInput_02->callback(cb_filterInput_02);

		Fl_Float_Input* filterInput_03 = new Fl_Float_Input(250, 50, 50, 20);
		filterInput_03->user_data((void*)(this)); 
		filterInput_03->callback(cb_filterInput_03);

		Fl_Float_Input* filterInput_04 = new Fl_Float_Input(300, 50, 50, 20);
		filterInput_04->user_data((void*)(this)); 
		filterInput_04->callback(cb_filterInput_04);

		Fl_Float_Input* filterInput_10 = new Fl_Float_Input(100, 70, 50, 20);
		filterInput_10->user_data((void*)(this)); 
		filterInput_10->callback(cb_filterInput_10);

		Fl_Float_Input* filterInput_11 = new Fl_Float_Input(150, 70, 50, 20);
		filterInput_11->user_data((void*)(this)); 
		filterInput_11->callback(cb_filterInput_11);

		Fl_Float_Input* filterInput_12 = new Fl_Float_Input(200, 70, 50, 20);
		filterInput_12->user_data((void*)(this)); 
		filterInput_12->callback(cb_filterInput_12);

		Fl_Float_Input* filterInput_13 = new Fl_Float_Input(250, 70, 50, 20);
		filterInput_13->user_data((void*)(this)); 
		filterInput_13->callback(cb_filterInput_13);

		Fl_Float_Input* filterInput_14 = new Fl_Float_Input(300, 70, 50, 20);
		filterInput_14->user_data((void*)(this)); 
		filterInput_14->callback(cb_filterInput_14);

		Fl_Float_Input* filterInput_20 = new Fl_Float_Input(100, 90, 50, 20);
		filterInput_20->user_data((void*)(this)); 
		filterInput_20->callback(cb_filterInput_20);

		Fl_Float_Input* filterInput_21 = new Fl_Float_Input(150, 90, 50, 20);
		filterInput_21->user_data((void*)(this)); 
		filterInput_21->callback(cb_filterInput_21);

		Fl_Float_Input* filterInput_22 = new Fl_Float_Input(200, 90, 50, 20);
		filterInput_22->user_data((void*)(this)); 
		filterInput_22->callback(cb_filterInput_22);

		Fl_Float_Input* filterInput_23 = new Fl_Float_Input(250, 90, 50, 20);
		filterInput_23->user_data((void*)(this)); 
		filterInput_23->callback(cb_filterInput_23);

		Fl_Float_Input* filterInput_24 = new Fl_Float_Input(300, 90, 50, 20);
		filterInput_24->user_data((void*)(this)); 
		filterInput_24->callback(cb_filterInput_24);

		Fl_Float_Input* filterInput_30 = new Fl_Float_Input(100, 110, 50, 20);
		filterInput_30->user_data((void*)(this)); 
		filterInput_30->callback(cb_filterInput_30);

		Fl_Float_Input* filterInput_31 = new Fl_Float_Input(150, 110, 50, 20);
		filterInput_31->user_data((void*)(this)); 
		filterInput_31->callback(cb_filterInput_31);

		Fl_Float_Input* filterInput_32 = new Fl_Float_Input(200, 110, 50, 20);
		filterInput_32->user_data((void*)(this)); 
		filterInput_32->callback(cb_filterInput_32);

		Fl_Float_Input* filterInput_33 = new Fl_Float_Input(250, 110, 50, 20);
		filterInput_33->user_data((void*)(this)); 
		filterInput_33->callback(cb_filterInput_33);

		Fl_Float_Input* filterInput_34 = new Fl_Float_Input(300, 110, 50, 20);
		filterInput_34->user_data((void*)(this)); 
		filterInput_34->callback(cb_filterInput_34);

		Fl_Float_Input* filterInput_40 = new Fl_Float_Input(100, 130, 50, 20);
		filterInput_40->user_data((void*)(this)); 
		filterInput_40->callback(cb_filterInput_40);

		Fl_Float_Input* filterInput_41 = new Fl_Float_Input(150, 130, 50, 20);
		filterInput_41->user_data((void*)(this)); 
		filterInput_41->callback(cb_filterInput_41);

		Fl_Float_Input* filterInput_42 = new Fl_Float_Input(200, 130, 50, 20);
		filterInput_42->user_data((void*)(this)); 
		filterInput_42->callback(cb_filterInput_42);

		Fl_Float_Input* filterInput_43 = new Fl_Float_Input(250, 130, 50, 20);
		filterInput_43->user_data((void*)(this)); 
		filterInput_43->callback(cb_filterInput_43);

		Fl_Float_Input* filterInput_44 = new Fl_Float_Input(300, 130, 50, 20);
		filterInput_44->user_data((void*)(this)); 
		filterInput_44->callback(cb_filterInput_44);


    m_filterDialog->end();	


}