Esempio n. 1
0
inline
array_nd<T> cat(size_t dim, const array_nd<T, S1>& a1,
				const array_nd<T, S2>& a2, const array_nd<T, S3>& a3)
{
	CHECK(dim < a1.ndims(), edims());
	CHECK(dim >= 0, edims());
	CHECK (a1.ndims() == a2.ndims(), eshape());
	CHECK (a2.ndims() == a3.ndims(), eshape());
	for (size_t j = 0; j < a1.ndims(); j++)
		if (j != dim) {
			CHECK(a1.size_nd()[j] == a2.size_nd()[j], eshape());
			CHECK(a2.size_nd()[j] == a3.size_nd()[j], eshape());
		}

	size_array sz(a1.size());
	sz[dim] = a1.size_nd(dim);
	sz[dim] += a2.size_nd(dim);
	sz[dim] += a3.size_nd(dim);
	array_nd<T> c(sz);

	array<index_array> indx(a1.ndims(), index_all());
	indx[dim] = size_range(0, a1.size_nd(dim) - 1);
	c(indx) = a1;
	indx[dim] = size_range(indx[dim].last + 1,
							indx[dim].last + a2.size_nd(dim));
	c(indx) = a2;
	indx[dim] = size_range(indx[dim].last + 1,
							indx[dim].last + a3.size_nd(dim));
	c(indx) = a3;
	return c;
}
Esempio n. 2
0
array<typename array_nd<T, S>::create_new> split(
	const array_nd<T, S>& a, const array<size_t, D>& spoint , size_t dim)
{
	CHECK (dim < a.ndims(), edims());
	CHECK (dim >= 0, edims());

	array<typename array_nd<T, S>::create_new> result(spoint.length() + 1);

	for (size_t j = 0; j < spoint.length(); j++)
		CHECK(spoint[j] <= a.size_nd()[dim], erange());

	for (size_t j = 0; j < spoint.length() + 1; j++) {
		array<index_array, tiny> indx(a.ndims());
		for (size_t i = 0; i < a.ndims(); i++) {
			if(i != dim)
				indx[i] = size_array(
					size_range(0, a.size_nd()[i] - 1));
			else
				indx[i] = size_array(size_range((j == 0 ? 0 : spoint[j - 1]),
					(j == (spoint.length()) ?
						a.size_nd()[i] - 1 : spoint[j] - 1) ));
		}
		result[j] = a(indx);
	}
	return result;
}
Esempio n. 3
0
void DiagramWindow::Construct(int w, int h, const std::vector<int>& structures)
{
    m_offscreenImage[0] = fl_create_offscreen(2048, 2048);
    m_imageData[0] = new uchar[2048 * 2048 * 3];
    memset(m_imageData[0], 0, 2048 * 2048 * 3);
    m_offscreenImage[1] = fl_create_offscreen(1024, 1024);
    m_imageData[1] = new uchar[1024 * 1024 * 3];
    memset(m_imageData[1], 0, 1024 * 1024 * 3);

    m_glWindow = new GLWindow(0, 120, w, h - 120);
    m_glWindow->SetTextureData(m_imageData[0], 2048);
    m_glWindow->SetTextureData(m_imageData[1], 1024);

    m_menus[0] = m_menus[1] = m_menus[2] = 0;
    m_menuItems = 0;
    m_menuItemsSize = 0;

    color(FL_BLACK);
    size_range(600, 720);
    box(FL_NO_BOX);

    Fl_Box* resizeBox = new Fl_Box(0, 120, w, h - 120);
    resizable(resizeBox);

    SetStructures(structures);
}
Esempio n. 4
0
inline
typename array_nd<T, S>::create_new cat(
	size_t dim, const array<array_nd<T, S> >& a)
{
	for (size_t i = 0; i < a.length() - 1; i++) {
		CHECK (a[i].ndims() == a[i + 1].ndims(), eshape());
		for (size_t j = 0; j < a[i].ndims(); j++)
			if (j != dim) {
				CHECK(a[i].size_nd()[j] == a[i + 1].size_nd()[j], eshape());
			}
	}
	CHECK(dim < a[0].ndims(), edims());
	CHECK(dim >= 0, edims());
	size_array sz(a[0].ndims());

	for (size_t i = 0; i < a[0].ndims(); i++)
		sz[i] = a[0].size_nd()[i];
	sz[dim] = 0;
	for (size_t j = 0; j < a.length(); j++)
		sz[dim] += a[j].size_nd()[dim];
	typename array_nd<T, S>::create_new c(sz);

	size_t offs = 0;
	for (size_t j = 0; j < a.length(); j++) {
		array<index_array> indx(a[j].ndims());

		for (size_t i = 0; i < a[j].ndims(); i++)
			indx[i] = size_range((i == dim) ? offs : 0,
					a[j].size_nd()[i] - 1 + ((i == dim) ? offs : 0));

		offs += a[j].size_nd()[dim];
		c(indx) = a[j];
	}
	return c;
}
Esempio n. 5
0
gdPluginWindow::gdPluginWindow(Plugin *pPlugin)
    : gWindow(400, 156), pPlugin(pPlugin) // 350
{
    set_non_modal();

    gLiquidScroll *list = new gLiquidScroll(8, 8, w()-16, h()-16);
    list->type(Fl_Scroll::VERTICAL_ALWAYS);
    list->begin();

    int numParams = pPlugin->getNumParams();
    for (int i=0; i<numParams; i++)
        new Parameter(i, pPlugin, list->x(), list->y()+(i*24), list->w());
    list->end();

    end();

    char name[256];
    pPlugin->getProduct(name);
    if (strcmp(name, " ")==0)
        pPlugin->getName(name);
    label(name);

    size_range(400, (24*1)+12);
    resizable(list);

    gu_setFavicon(this);
    show();

}
Esempio n. 6
0
TraceGLWindow::TraceGLWindow(int x, int y, int w, int h, const char *l)
			: Fl_Gl_Window(x,y,w,h,l)
{
	m_nWindowWidth = w;
	m_nWindowHeight = h;
	// Do not allow the user to re-size the window
	size_range(w, h, w, h);
}
Esempio n. 7
0
void TraceGLWindow::resizeWindow(int width, int height)
{
	resize(x(), y(), width, height);
	// Do not allow manual re-sizing
	size_range(w(), h(), w(), h());
	m_nWindowWidth=w();
	m_nWindowHeight=h();
}
Esempio n. 8
0
MyWindow::MyWindow() : Fl_Gl_Window(1024, 768, "Pinocchio"), flatShading(true), floor(true), skeleton(false)
{
    size_range(20, 20, 5000, 5000);
    end();

    resetTransform();
    win = this;
    Fl::add_idle(idle);
}
Esempio n. 9
0
MyWindow::MyWindow() : Fl_Gl_Window(1024, 768, "Pinocchio"), flatShading(false), floor(true), skeleton(false), 
					drawTri(true), drawh(true), drawsph(false), drawline(false), drawskl(false), drawbefore(false),
					onAnimation(true)
{
    size_range(20, 20, 5000, 5000);
    end();

    resetTransform();
    win = this;
    Fl::add_idle(idle);
}
Esempio n. 10
0
typename array_nd<T, S>::create_similar flipdim(
	const array_nd<T, S>& a, size_t dim)
{
	CHECK (dim < a.ndims(), edims());
	CHECK (dim >= 0, edims());
	array<index_array> indx(a.ndims());
	for (size_t i = 0; i < a.ndims(); i++)
		indx[i] = index_array(); // Select all.

	indx[dim] = size_range(a.size_nd()[dim] - 1, -1, 0);
	return typename array_nd<T, S>::create_similar(a(indx));
}
Esempio n. 11
0
/* Uses a 2D gaussian to spread blocks on the surface
 * https://en.wikipedia.org/wiki/Gaussian_function#Two-dimensional_Gaussian_function
 */
void Simulation::add_blocks(int count, int size){

    float xc = -0.4; //skew gauss and location
    float yc = 0;
    float s = 0.5; //spread gauss and location

    typedef boost::mt19937 RNGType;
    RNGType rng( time(0) );
    /* s-1 is the location based on how spread it is, which wraps the gaussian bell over
     * the relevant parts making the gauss and the locations in the same range.
     * The reason we subtract 1 is to chop off the "skirts" of the gauss, prevent the creation
     * of miniscule boxes which does nothing but impact performance.
     */
    boost::uniform_real<> loc_range(-(s-0.1),s-0.1);
    boost::variate_generator<boost::mt19937&, boost::uniform_real<> > rlocation(rng,loc_range);
    boost::uniform_real<> size_range(0.002, (float) size/1000);
    boost::variate_generator<boost::mt19937&, boost::uniform_real<> > rsize(rng,size_range);

    for(int i = 0; i < count; ++i){
        //Gaussian gaussian amplitudes
        float a = rsize();

        float x = rlocation() + xc; //random + gaussian skew
        float y = rlocation() + yc;

        //2D gaussian
        float bsize = a*exp( -( (pow((x-xc), 2) / (2*pow(s, 2)) ) +
                    (pow((y-yc), 2) / (2*pow(s, 2)) ) ));


        /*tan(angle) is conversion from degrees to slope (relationship between rise and run)
         *Multiplying this with -x will find the correct height of the block based on the
         *rise. This means that you can place boxes along x and y in a slope, and the boxes will
         *follow the slope
         */
        ode::Object::ptr_t b
            (new ode::Box(*env, Eigen::Vector3d(x, y, bsize/2 + (tan(tilt)*-x)),
                          10, bsize*4, bsize*4, bsize)); //multiply by 4 to stretch out

        b->set_rotation(0.0f, -tilt, 0.0f);
        boxes.push_back(b);
        if(!headless){
            b->accept(*v);
        }
        b->fix();
        env->add_to_ground(*b);
    }
}
Esempio n. 12
0
gdMainWindow::gdMainWindow(int W, int H, const char *title, int argc, char **argv)
	: gWindow(W, H, title)
{
	Fl::visible_focus(0);
	Fl::background(25, 25, 25);
	Fl::set_boxtype(G_BOX, gDrawBox, 1, 1, 2, 2);    // custom box G_BOX

	size_range(GUI_WIDTH, GUI_HEIGHT);

	menu       = new gMenu(8, -1);
	inOut      = new gInOut(408, 8);
	controller = new gController(8, 39);
	timing     = new gTiming(632, 39);
	beatMeter  = new gBeatMeter(100, 83, 609, 20);
	keyboard   = new gKeyboard(8, 122, w()-16, 380);

	/* zone 1 - menus, and I/O tools */

	Fl_Group *zone1 = new Fl_Group(8, 8, W-16, 20);
	zone1->add(menu);
	zone1->resizable(new Fl_Box(300, 8, 80, 20));
	zone1->add(inOut);

	/* zone 2 - controller and timing tools */

	Fl_Group *zone2 = new Fl_Group(8, controller->y(), W-16, controller->h());
	zone2->add(controller);
	zone2->resizable(new Fl_Box(controller->x()+controller->w()+4, zone2->y(), 80, 20));
	zone2->add(timing);

	/* zone 3 - beat meter */

	Fl_Group *zone3 = new Fl_Group(8, beatMeter->y(), W-16, beatMeter->h());
	zone3->add(beatMeter);

	/* zone 4 - the keyboard (Fl_Group is unnecessary here, keyboard is
	 * a group by itself) */

	resizable(keyboard);

	add(zone1);
	add(zone2);
	add(zone3);
	add(keyboard);
	callback(cb_endprogram);
	gu_setFavicon(this);
	show(argc, argv);
}
Esempio n. 13
0
CqFramebuffer::CqFramebuffer(TqUlong width, TqUlong height, TqInt depth,
		const std::string& bookName) : 
	Fl_Double_Window(width+20, height, bookName.c_str()),
	m_doResize(false),
	m_title(bookName),
	m_bookName(bookName),
	m_keyHeld(false)
{
	Fl::lock();
	size_range(400, 300); // restrict min size
	// I was going to make a toolbar, but I decided to disable it for now
//	m_theWindow = new Fl_Window(width, height+16);
	
//	Fl_Pack *vpack = new Fl_Pack(0, 0, width, height);
//	vpack->type(Fl_Pack::VERTICAL);

//	Fl_Pack *toolbar_pck = new Fl_Pack(0,0, width, 30);
//	toolbar_pck->type(Fl_Pack::HORIZONTAL);
//	Fl_Button *but1 = new Fl_Button(0,0, 100,30, "Red");
//	but1->image(new Fl_PNG_Image("red_chan.png"));
//	Fl_Button *but2 = new Fl_Button(0,0, 100,30, "Green");
//	but2->image(new Fl_PNG_Image("green_chan.png"));
//	Fl_Button *but3 = new Fl_Button(0,0, 100,30, "Blue");
//	but3->image(new Fl_PNG_Image("blue_chan.png"));
//	toolbar_pck->end();
//	toolbar_pck->resizable(toolbar_pck);
	boost::shared_ptr<CqImage> t;
	m_scroll = new Fl_Scroll(0, 0, width+20, height);
	m_scroll->color(FL_LIGHT1);
	m_uiImageWidget = new Fl_FrameBuffer_Widget(0,0, width, height, t);
	m_scroll->end();

	Fl::visual(FL_RGB);
	m_popupMenu = new Fl_Menu_Button(0,0,width, height, "");
	m_popupMenu->type(Fl_Menu_Button::POPUP3);
	m_popupMenu->box(FL_NO_BOX);
	m_popupMenu->menu(m_popupMenuItems); 

	resizable(m_scroll);

	end();
	Fl_Window::show();
	Fl::unlock();
}
Esempio n. 14
0
void qr<T>::output(array_2d<T>& q, array_2d<T>& r) const
{
	array<T> tau(min_nm);

	if(r.rows() != m || r.columns() != n)
		r.resize(idx(m, n));

	lapack_interface<T>::call_lapack_geqrf(r, tau, a);

	//Now construct Q
	//Q should be a MxM matrix
	if(q.rows() != m || q.columns() != m)
		q.resize(idx(m, m));

	if(n <= m) {
		//Q can hold the MxN values of R needed by lapack's xORGQR routines
		for(size_t i = 0; i < m; i++)
			for(size_t j = 0; j < n; j++)
				q[m*j + i] = r(i,j);

		lapack_interface<T>::call_lapack_orgqr(q, tau);

	} else {
		//create a new array and do a copy since
		//Q cannot hold the MxN values of R as needed by lapack's xORGQR routines
		array_2d<T> temp_q(r(all(), size_range(0, m - 1)));

		lapack_interface<T>::call_lapack_orgqr(temp_q, tau);

		//copy the Q values from temp
		for(size_t i = 0; i < m; i++)
			for(size_t j = 0; j < m; j++)
				q[m*j + i] = temp_q[m*j + i];
	}

	// R is upper triangular
	for(size_t i = 0; i < m; i++)
		for(size_t j = 0; j < n; j++)
			if(i > j)
				r(i,j) = 0;
}
Esempio n. 15
0
MapsWindow::MapsWindow(Model & model, Cache& cache):
    Fl_Double_Window(100, 100, "Maps"),
    model_(model),
    cache_(cache),
    prefs_(prefs(), label())
{
    int const scrollW = Fl::scrollbar_size();
    mapArea_ = new MapArea(0, 0, w()-scrollW, h());
    scrollbar_ = new Fl_Scrollbar(w()-scrollW, 0, scrollW, h());
    resizable(mapArea_);
    end();

    scrollbar_->callback(&callbackScrollbar, this);
    scrollbar_->linesize(MapArea::SIZE_);

    int x, y, w, h;
    prefs_.get(PrefWindowX, x, 0);
    prefs_.get(PrefWindowY, y, 0);
    prefs_.get(PrefWindowW, w, 600);
    prefs_.get(PrefWindowH, h, 600);
    resize(x,y,w,h);
    size_range(MapArea::SIZE_ + scrollW, MapArea::SIZE_, 0, 0, 0, 0, 0);
}
Esempio n. 16
0
void Fl_File_Dialog::init()
{
	cancelled_ = false;
	fullpath_ = 0;
	size_range(300, 200);

	up_->callback(cb_up, this);
	home_->callback(cb_home, this);
	refresh_->callback(cb_refresh, this);
	new_folder_->callback(cb_new, this);

	//listview_->text_background(FL_WHITE);
	listview_->callback(cb_list, this);
	preview_but_->callback(cb_preview, this);
		
	filter_->add("(*) All Files");
	filter_->value("(*) All Files");
	filter_->callback(cb_filter, this);

	path_->callback(cb_dirc, this);

	cancel_->callback(cb_cancel, this);
	ok_->callback(cb_ok, this);
}
Esempio n. 17
0
sgetris::backgrounds::flakes::object::object(
	boost::program_options::variables_map &_program_options,
	sge::renderer::device &_renderer,
	// The flakes get the loader because in a later version more than one flake image could be loaded
	// from a directory
	texture_manager &_texture_manager)
:
	texture_manager_(
		_texture_manager),
	ss_(
		_renderer),
	clock_(),
	frame_timer_(
		sgetris::diff_timer::parameters(
			fcppt::chrono::second(1)
		)
	),
	flakes_()
{
	texture_manager_.load(
		media_path()/FCPPT_TEXT("backgrounds")/FCPPT_TEXT("flakes")/FCPPT_TEXT("textures.ini"));
	fcppt::random::uniform<sprite::scalar>
		xposition_rng(
			fcppt::random::make_inclusive_range(
				static_cast<sprite::scalar>(0),
				static_cast<sprite::scalar>(
					_renderer->screen_size().w()))),
		yposition_rng(
			fcppt::random::make_inclusive_range(
				static_cast<sprite::scalar>(0),
				static_cast<sprite::scalar>(
					_renderer.screen_size().h())));

	// Those pairs are real to avoid ugly casting below, they'll be cast
	// one time sprite::scalar
	std::pair<real,real>
		size_range(
			static_cast<real>(
				_renderer.screen_size().w())*
			_program_options["flakes-size-min"].as<real>(),
			static_cast<real>(
				_renderer.screen_size().w())*
			_program_options["flakes-size-max"].as<real>());

	std::pair<real,real>
		speed_range(
			_program_options["flakes-speed-min"].as<real>(),
			_program_options["flakes-speed-max"].as<real>());

	fcppt::random::uniform<real> rng(
		fcppt::random::make_inclusive_range(
			static_cast<real>(
				0),
			static_cast<real>(
				1)));

	for(
		flake_count i = 0,
		fc = _program_options["flakes-count"].as<flake_count>();
		i < fc;
		++i)
	{
		// Roll the dice
		real const v =
			rng();

		sprite::vector const position(
			xposition_rng(),
			yposition_rng());

		sprite::dim const size(
			fcppt::math::dim::structure_cast<sprite::dim>(
				fcppt::math::dim::make(
					size_range.first + v * (size_range.second - size_range.first),
					size_range.first + v * (size_range.second - size_range.first))));

		sprite::scalar const speed =
			static_cast<sprite::scalar>(
				speed_range.first + v * (speed_range.second - speed_range.first));

		flakes_.push_back(
			new flake(
				real(
					v),
				_renderer.screen_size(),
				sprite::parameters()
					.system(
						&ss_)
					.order(
						0u)
					.pos(
						position)
					.texture(
						texture_manager_.texture(
							FCPPT_TEXT("flake")))
					.size(
						size),
				speed));
	}

	_renderer.state(
		sge::renderer::state::list
			(sge::renderer::state::bool_::clear_backbuffer = true)
			(sge::renderer::state::color::clear_color
				= sge::image::colors::black()
			)
	);
}
Esempio n. 18
0
gdEditor::gdEditor(SampleChannel *ch)
	: gWindow(640, 480),
		ch(ch)
{
	set_non_modal();

	if (G_Conf.sampleEditorX)
		resize(G_Conf.sampleEditorX, G_Conf.sampleEditorY, G_Conf.sampleEditorW, G_Conf.sampleEditorH);

	Fl_Group *bar = new Fl_Group(8, 8, w()-16, 20);
	bar->begin();
		reload  = new gClick(bar->x(), bar->y(), 50, 20, "Reload");
		zoomOut = new gClick(bar->x()+bar->w()-20, bar->y(), 20, 20, "-");
		zoomIn  = new gClick(zoomOut->x()-24, bar->y(), 20, 20, "+");
	bar->end();
	bar->resizable(new gBox(reload->x()+reload->w()+4, bar->y(), 80, bar->h()));

	waveTools = new gWaveTools(8, 36, w()-16, h()-120, ch);
	waveTools->end();

	Fl_Group *tools = new Fl_Group(8, waveTools->y()+waveTools->h()+8, w()-16, 130);
	tools->begin();
		volume        = new gDial (tools->x()+42,	                   tools->y(), 20, 20, "Volume");
		volumeNum     = new gInput(volume->x()+volume->w()+4,        tools->y(), 46, 20, "dB");

		boost         = new gDial (volumeNum->x()+volumeNum->w()+80, tools->y(), 20, 20, "Boost");
		boostNum      = new gInput(boost->x()+boost->w()+4,          tools->y(), 46, 20, "dB");

		normalize     = new gClick(boostNum->x()+boostNum->w()+40,   tools->y(), 70, 20, "Normalize");
		pan 				  = new gDial (normalize->x()+normalize->w()+40, tools->y(), 20, 20, "Pan");
		panNum    	  = new gInput(pan->x()+pan->w()+4,              tools->y(), 45, 20, "%");

		pitch				  = new gDial  (tools->x()+42,	                     volume->y()+volume->h()+4, 20, 20, "Pitch");
		pitchNum		  = new gInput (pitch->x()+pitch->w()+4,	           volume->y()+volume->h()+4, 46, 20);
		pitchToBar    = new gClick (pitchNum->x()+pitchNum->w()+4,       volume->y()+volume->h()+4, 46, 20, "To bar");
		pitchToSong   = new gClick (pitchToBar->x()+pitchToBar->w()+4,   volume->y()+volume->h()+4, 46, 20, "To song");
		pitchReset    = new gClick (pitchToSong->x()+pitchToSong->w()+4, volume->y()+volume->h()+4, 46, 20, "Reset");

		chanStart     = new gInput(tools->x()+52,                    pitch->y()+pitch->h()+4, 60, 20, "Start");
		chanEnd       = new gInput(chanStart->x()+chanStart->w()+40, pitch->y()+pitch->h()+4, 60, 20, "End");
		resetStartEnd = new gClick(chanEnd->x()+chanEnd->w()+4,      pitch->y()+pitch->h()+4, 46, 20, "Reset");

	tools->end();
	tools->resizable(new gBox(chanStart->x()+chanStart->w()+4, tools->y(), 80, tools->h()));

	char buf[16];
	///sprintf(buf, "%d", ch->beginTrue / 2); // divided by 2 because stereo
	sprintf(buf, "%d", ch->begin / 2); // divided by 2 because stereo
	chanStart->value(buf);
	chanStart->type(FL_INT_INPUT);
	chanStart->callback(cb_setChanPos, this);

	/* inputs callback: fire when they lose focus or Enter is pressed. */

	chanStart->when(FL_WHEN_RELEASE | FL_WHEN_ENTER_KEY);
	chanEnd  ->when(FL_WHEN_RELEASE | FL_WHEN_ENTER_KEY);

	///sprintf(buf, "%d", ch->endTrue / 2);	// divided by 2 because stereo
	sprintf(buf, "%d", ch->end / 2);  // divided by 2 because stereo
	chanEnd->value(buf);
	chanEnd->type(FL_INT_INPUT);
	chanEnd->callback(cb_setChanPos, this);

	resetStartEnd->callback(cb_resetStartEnd, this);

	volume->callback(cb_setVolume, (void*)this);
	volume->value(ch->guiChannel->vol->value());

	float dB = 20*log10(ch->volume);   // dB = 20*log_10(linear value)
	if (dB > -INFINITY)	sprintf(buf, "%.2f", dB);
	else            		sprintf(buf, "-inf");
	volumeNum->value(buf);
	volumeNum->align(FL_ALIGN_RIGHT);
	volumeNum->callback(cb_setVolumeNum, (void*)this);

	boost->range(1.0f, 10.0f);
	boost->callback(cb_setBoost, (void*)this);
	if (ch->boost > 10.f)
		boost->value(10.0f);
	else
		boost->value(ch->boost);
	boost->when(FL_WHEN_CHANGED | FL_WHEN_RELEASE);

	float boost = 20*log10(ch->boost); // dB = 20*log_10(linear value)
	sprintf(buf, "%.2f", boost);
	boostNum->value(buf);
	boostNum->align(FL_ALIGN_RIGHT);
	boostNum->callback(cb_setBoostNum, (void*)this);

	normalize->callback(cb_normalize, (void*)this);

	pan->range(0.0f, 2.0f);
	pan->callback(cb_panning, (void*)this);

	pitch->range(0.01f, 4.0f);
	pitch->value(ch->pitch);
	pitch->callback(cb_setPitch, (void*)this);
	pitch->when(FL_WHEN_RELEASE);

	sprintf(buf, "%.4f", ch->pitch); // 4 digits
	pitchNum->value(buf);
	pitchNum->align(FL_ALIGN_RIGHT);
	pitchNum->callback(cb_setPitchNum, (void*)this);
	pitchNum->when(FL_WHEN_RELEASE | FL_WHEN_ENTER_KEY);

	pitchToBar->callback(cb_setPitchToBar, (void*)this);
	pitchToSong->callback(cb_setPitchToSong, (void*)this);
	pitchReset->callback(cb_resetPitch, (void*)this);

	reload->callback(cb_reload, (void*)this);

	zoomOut->callback(cb_zoomOut, (void*)this);
	zoomIn->callback(cb_zoomIn, (void*)this);

	/* logical samples (aka takes) cannot be reloaded. So far. */

	if (ch->wave->isLogical)
		reload->deactivate();

	if (ch->panRight < 1.0f) {
		char buf[8];
		sprintf(buf, "%d L", abs((ch->panRight * 100.0f) - 100));
		pan->value(ch->panRight);
		panNum->value(buf);
	}
	else if (ch->panRight == 1.0f && ch->panLeft == 1.0f) {
	  pan->value(1.0f);
	  panNum->value("C");
	}
	else {
		char buf[8];
		sprintf(buf, "%d R", abs((ch->panLeft * 100.0f) - 100));
		pan->value(2.0f - ch->panLeft);
		panNum->value(buf);
	}

	panNum->align(FL_ALIGN_RIGHT);
	panNum->readonly(1);
	panNum->cursor_color(FL_WHITE);

	gu_setFavicon(this);
	size_range(640, 480);
	resizable(waveTools);

	label(ch->wave->name.c_str());

	show();
}
Esempio n. 19
0
MainFltkMenu::MainFltkMenu(VMDApp *vmdapp)
: VMDFltkMenu("main", "VMD Main", vmdapp) {
  // set initial window size
  size(MAINFLTKMENUWIDTH, MAINFLTKMENUHEIGHT);
 
  // set resizable in y but not in x...
  size_range(MAINFLTKMENUWIDTH, MAINFLTKMENUHEIGHT, MAINFLTKMENUWIDTH, 0);

  command_wanted(Command::MOL_NEW);
  command_wanted(Command::MOL_DEL);
  command_wanted(Command::MOL_ACTIVE);
  command_wanted(Command::MOL_ON);
  command_wanted(Command::MOL_RENAME);
  command_wanted(Command::MOL_FIX);
  command_wanted(Command::MOL_TOP);
  command_wanted(Command::MOL_VOLUME);
  command_wanted(Command::ANIM_JUMP);
  command_wanted(Command::ANIM_NEW_FRAME);
  command_wanted(Command::ANIM_NEW_NUM_FRAMES);
  command_wanted(Command::MOUSE_MODE);
  command_wanted(Command::MENU_TK_ADD);
  command_wanted(Command::MENU_TK_REMOVE);
  command_wanted(Command::ANIM_STYLE);
  command_wanted(Command::ANIM_SKIP);
  command_wanted(Command::ANIM_SPEED);
  command_wanted(Command::ANIM_DIRECTION);
  command_wanted(Command::ANIM_JUMP);

  command_wanted(Command::DISP_DEPTHCUE);
  command_wanted(Command::DISP_CULLING);
  command_wanted(Command::DISP_ANTIALIAS);
  command_wanted(Command::DISP_FPS);
  command_wanted(Command::DISP_LIGHT_ON);
  command_wanted(Command::CMD_STAGE);
  command_wanted(Command::CMD_AXES);
  command_wanted(Command::DISP_BACKGROUNDGRADIENT);
  command_wanted(Command::DISP_PROJ);
  command_wanted(Command::DISP_STEREO);
  command_wanted(Command::DISP_STEREOSWAP);
  command_wanted(Command::DISP_CACHEMODE);
  command_wanted(Command::DISP_RENDERMODE);

  browser = new MolBrowser(vmdapp, this, 0, 60, MAINFLTKMENUWIDTH, 90);

  // ******** CREATE MENUS *********
  // We make copies of the static data because we will be changing the state
  // and contents of some menus and menu items.
  
  int menulen;
  Fl_Menu_Item nullitem = {NULL};
     
  // create menu instances and fill in user_data fields for menu callback use.
  menulen = sizeof(init_file_menuitems)/sizeof(Fl_Menu_Item);
  file_menuitems = new Fl_Menu_Item[menulen];
  int j;
  for (j=0; j<menulen; j++) {
    file_menuitems[j] = init_file_menuitems[j];
    file_menuitems[j].user_data(this);
  }
  // these are set here because the are private functions
  file_menuitems[1].callback(loadfile_cb);
  file_menuitems[2].callback(savefile_cb);
        
  menulen = sizeof(init_molecule_menuitems)/sizeof(Fl_Menu_Item);
  molecule_menuitems = new Fl_Menu_Item[menulen];
  for (j=0; j<menulen; j++) {
    molecule_menuitems[j] = init_molecule_menuitems[j];
    molecule_menuitems[j].user_data(browser);
  }
  
  
  // This is the popup menu in the molbrowser window (mix of file and molecule menus)
  menulen = sizeof(init_browserpopup_menuitems)/sizeof(Fl_Menu_Item);
  browserpopup_menuitems = new Fl_Menu_Item[menulen];
  for (j=0; j<3; j++) {
    browserpopup_menuitems[j] = init_browserpopup_menuitems[j];
    browserpopup_menuitems[j].user_data(this);
  }
  for (j=3; j<menulen; j++) {
    browserpopup_menuitems[j] = init_browserpopup_menuitems[j];
    browserpopup_menuitems[j].user_data(browser);
  }
  // these are set here because the are private functions
  browserpopup_menuitems[1].callback(loadfile_cb);
  browserpopup_menuitems[2].callback(savefile_cb);

  
  menulen = sizeof(init_display_menuitems)/sizeof(Fl_Menu_Item);
  display_menuitems = new Fl_Menu_Item[menulen];
  for (j=0; j<menulen; j++)
    display_menuitems[j] = init_display_menuitems[j];
  if (app->display->aa_available()) display_menuitems[4].activate();
  if (app->display->cueing_available()) display_menuitems[5].activate();
  if (app->display->culling_available()) display_menuitems[6].activate();
  
  menulen = app->axes->locations();
  axes_menuitems_storage = new Fl_Menu_Item[menulen+2]; 
  axes_menuitems_storage[0] = nullitem;   // pad the beginning of the array 
                                          // to prevent an Fltk crash
  axes_menuitems = axes_menuitems_storage+1; 
  for (j=0; j<menulen; j++) {
    Fl_Menu_Item item = {app->axes->loc_description(j), 0, axes_cb, app, FL_MENU_RADIO};
    axes_menuitems[j] = item;
  }
  axes_menuitems[menulen] = nullitem;
  display_menuitems[12].user_data(axes_menuitems);

  menulen = 2;
  backgroundmode_menuitems_storage = new  Fl_Menu_Item[menulen+2];
  backgroundmode_menuitems_storage[0] = nullitem;
  backgroundmode_menuitems = backgroundmode_menuitems_storage+1;
  {
    Fl_Menu_Item item = { "Solid Color", 0, backgroundmode_cb, app, FL_MENU_RADIO};
    backgroundmode_menuitems[0] = item;
  }
  {
    Fl_Menu_Item item = { "Gradient", 0, backgroundmode_cb, app, FL_MENU_RADIO};
    backgroundmode_menuitems[1] = item;
  }
  backgroundmode_menuitems[menulen] = nullitem;
  display_menuitems[13].user_data(backgroundmode_menuitems);
 
  menulen = app->stage->locations();
  stage_menuitems_storage = new Fl_Menu_Item[menulen+2]; 
  stage_menuitems_storage[0] = nullitem;
  stage_menuitems = stage_menuitems_storage+1;  
  for (j=0; j<menulen; j++) {
    Fl_Menu_Item item = {app->stage->loc_description(j), 0, stage_cb, app, FL_MENU_RADIO};  
    stage_menuitems[j] = item;
  }
  stage_menuitems[menulen] = nullitem;
  display_menuitems[14].user_data(stage_menuitems);
  
  menulen = app->display->num_stereo_modes();
  stereo_menuitems_storage = new Fl_Menu_Item[menulen+2]; 
  stereo_menuitems_storage[0] = nullitem;
  stereo_menuitems = stereo_menuitems_storage+1; 
  for (j=0; j<menulen; j++) {
    Fl_Menu_Item item = {app->display->stereo_name(j), 0, stereo_cb, vmdapp, FL_MENU_RADIO}; 
    stereo_menuitems[j] = item;
  }
  stereo_menuitems[menulen] = nullitem;
  display_menuitems[15].user_data(stereo_menuitems);

  menulen = 2;
  stereoswap_menuitems_storage = new Fl_Menu_Item[menulen+2]; 
  stereoswap_menuitems_storage[0] = nullitem;
  stereoswap_menuitems = stereoswap_menuitems_storage+1; 
  for (j=0; j<menulen; j++) {
    const char * StereoSwap[] = { "Off", "On" };
    Fl_Menu_Item item = {StereoSwap[j], 0, stereoswap_cb, vmdapp, FL_MENU_RADIO}; 
    stereoswap_menuitems[j] = item;
  }
  stereoswap_menuitems[menulen] = nullitem;
  display_menuitems[16].user_data(stereoswap_menuitems);

  menulen = app->display->num_cache_modes();
  cachemode_menuitems_storage = new Fl_Menu_Item[menulen+2]; 
  cachemode_menuitems_storage[0] = nullitem;
  cachemode_menuitems = cachemode_menuitems_storage+1; 
  for (j=0; j<menulen; j++) {
    Fl_Menu_Item item = {app->display->cache_name(j), 0, cachemode_cb, vmdapp, FL_MENU_RADIO}; 
    cachemode_menuitems[j] = item;
  }
  cachemode_menuitems[menulen] = nullitem;
  display_menuitems[17].user_data(cachemode_menuitems);
  
  menulen = app->display->num_render_modes();
  rendermode_menuitems_storage = new Fl_Menu_Item[menulen+2]; 
  rendermode_menuitems_storage[0] = nullitem;
  rendermode_menuitems = rendermode_menuitems_storage+1; 
  for (j=0; j<menulen; j++) {
    Fl_Menu_Item item = {app->display->render_name(j), 0, rendermode_cb, vmdapp, FL_MENU_RADIO}; 
    rendermode_menuitems[j] = item;
  }
  rendermode_menuitems[menulen] = nullitem;
  display_menuitems[18].user_data(rendermode_menuitems);

  update_dispmode();

  menulen = sizeof(init_mouse_menuitems)/sizeof(Fl_Menu_Item);
  mouse_menuitems_storage = new Fl_Menu_Item[menulen+2]; 
  mouse_menuitems_storage[0] = nullitem;
  mouse_menuitems = mouse_menuitems_storage+1; 
  for (j=0; j<menulen; j++)
    mouse_menuitems[j] = init_mouse_menuitems[j];

  
  // ******** CREATE MENU BAR *********
  menubar = new Fl_Menu_Bar(0, 0, MAINFLTKMENUWIDTH, 30);
#if defined(VMDMENU_WINDOW)
  menubar->color(VMDMENU_WINDOW);
#endif
  menubar->add("File",0,0,(void *)file_menuitems,FL_SUBMENU_POINTER);
  menubar->add("Molecule",0,0,(void *)molecule_menuitems,FL_SUBMENU_POINTER);
  menubar->add("Graphics",0,0,(void *)graphics_menuitems, FL_SUBMENU_POINTER);
  menubar->add("Display",0,0,(void*)display_menuitems, FL_SUBMENU_POINTER);
  menubar->add("Mouse",0,0,(void *)mouse_menuitems, FL_SUBMENU_POINTER);
  menubar->add(EXT_MENU_NAME,0,0, NULL, FL_SUBMENU);
  menubar->add("Help",0,0,(void *)init_help_menuitems, FL_SUBMENU_POINTER);
  menubar->user_data(vmdapp);
  menubar->selection_color(VMDMENU_MENU_SEL);

  // ******** CREATE CONTROLS *********
  Fl_Group::current()->resizable(browser);

  Fl_Button *b;
  int bwidth = 20, bheight = 20;
  b = new Fl_Button(0, 150, bwidth, bheight, "@4->|");
  VMDFLTKTOOLTIP(b, "Jump to beginning")
  b->labeltype(FL_SYMBOL_LABEL);
  b->callback(start_cb, app);

  reverse = new Fl_Button(0, 150+bheight, bwidth, bheight, "@<");
  VMDFLTKTOOLTIP(reverse, "Play in reverse")
  reverse->labeltype(FL_SYMBOL_LABEL);
  reverse->type(FL_TOGGLE_BUTTON);
  reverse->callback(reverse_cb, app);

  b = new Fl_Button(bwidth, 150+bheight, bwidth, bheight, "@<|");
  VMDFLTKTOOLTIP(b, "Step in reverse")
  b->labeltype(FL_SYMBOL_LABEL);
  b->callback(prev_cb, app);

  b = new Fl_Button(MAINFLTKMENUWIDTH-bwidth, 150, bwidth, bheight, "@->|");
  VMDFLTKTOOLTIP(b, "Jump to end")
  b->labeltype(FL_SYMBOL_LABEL);
  b->callback(stop_cb, app);

  forward = new Fl_Button(MAINFLTKMENUWIDTH-bwidth, 150+bheight,
                          bwidth, bheight, "@>");
  VMDFLTKTOOLTIP(forward, "Play forward")
  forward->labeltype(FL_SYMBOL_LABEL);
  forward->type(FL_TOGGLE_BUTTON);
  forward->callback(forward_cb, app);

  b = new Fl_Button(MAINFLTKMENUWIDTH-2*bwidth, 150+bheight,
                    bwidth, bheight, "@|>");
  VMDFLTKTOOLTIP(b, "Step forward")
  b->labeltype(FL_SYMBOL_LABEL);
  b->callback(next_cb, app);
  
  curframe = new Fl_Int_Input(bwidth, 150, 2*bwidth, bheight);
  VMDFLTKTOOLTIP(curframe, "Set current frame")
  curframe->textsize(12);
  curframe->callback(curframe_cb, app);
  curframe->when(FL_WHEN_ENTER_KEY);
  curframe->selection_color(VMDMENU_VALUE_SEL2);

  frameslider = new Fl_Slider(3*bwidth, 150,
                              MAINFLTKMENUWIDTH-4*bwidth, bheight);
  VMDFLTKTOOLTIP(frameslider, "Drag to set current frame")
  frameslider->type(FL_HOR_NICE_SLIDER);
  frameslider->step(1,1);
  frameslider->callback(frameslider_cb, this);
  frameslider->color(VMDMENU_SLIDER_BG, VMDMENU_SLIDER_FG);
  frameslider->when(FL_WHEN_CHANGED | FL_WHEN_RELEASE);

  step = new Fl_Counter(220,150+bheight, 45,bheight, "step");
  VMDFLTKTOOLTIP(step, "Animation step size")
  step->labelsize(12);
  step->type(FL_SIMPLE_COUNTER);
  step->step(1,1);
  step->minimum(1);
  step->value(1);
  step->callback(step_cb, app);
  step->align(FL_ALIGN_LEFT);

  style = new Fl_Choice(120, 150+bheight, 65, bheight);
  VMDFLTKTOOLTIP(style, "Set animation looping mode")
  style->textsize(12);
  style->selection_color(VMDMENU_MENU_SEL);
  style->box(FL_THIN_UP_BOX);
  for (int s=0; s<Animation::ANIM_TOTAL_STYLES; s++)
    style->add(animationStyleName[s]);

  // XXX The Animation class starts with ANIM_LOOP as its style, so that's
  // what we do, too.
  style->value(1);
  style->callback(style_cb, app);

  zoom = new Fl_Check_Button(80, 150+bheight-2, bwidth+5, bheight+5, "zoom");
  VMDFLTKTOOLTIP(zoom, "Zoom in slider onto 100-frame subrange centered on current frame")
  zoom->labelsize(12);
  zoom->align(FL_ALIGN_LEFT);
  zoom->value(0);
  //zoom->selection_color(FL_RED);
  zoom->color(VMDMENU_CHECKBOX_BG, VMDMENU_CHECKBOX_FG);
  zoom->callback(zoom_cb, this);

  speed = new Fl_Slider(315, 150+bheight, 90, bheight, "speed");
  VMDFLTKTOOLTIP(speed, "Drag slider to change animation speed")
  speed->labelsize(12);
  speed->type(FL_HORIZONTAL);
  speed->color(VMDMENU_SLIDER_BG, VMDMENU_SLIDER_FG);
  speed->value(1.0);
  speed->callback(speed_cb, app);
  speed->align(FL_ALIGN_LEFT);

  guistate = UNDEFINED;
  update_gui_state();

  callback(vmd_main_window_cb); // override default FLTK/VMD global handlers
          
  Fl_Window::end();
}
Esempio n. 20
0
gdActionEditor::gdActionEditor(int chan)
: gWindow(640, 176), chan(chan), zoom(100)
{

	if (G_Conf.actionEditorW) {
		resize(G_Conf.actionEditorX, G_Conf.actionEditorY, G_Conf.actionEditorW, G_Conf.actionEditorH);
		zoom = G_Conf.actionEditorZoom;
	}

	framesPerBar   = G_Mixer.framesPerBar / 2;      // /2 = we don't care about stereo infos
	framesPerBeat  = G_Mixer.framesPerBeat / 2;
	framesPerBeats = framesPerBeat * G_Mixer.beats;
	totalFrames    = framesPerBeat * MAX_BEATS;
	beatWidth      = framesPerBeat / zoom;
	totalWidth     = (int) ceilf(totalFrames / (float) zoom);

	/* container with zoom buttons and the action type selector. Scheme of
	 * the resizable boxes: |[--b1--][actionType][--b2--][+][-]| */

	Fl_Group *upperArea = new Fl_Group(8, 8, w()-16, 20);
	upperArea->begin();
	  actionType = new gChoice(104, 8, 80, 20);
	  gridTool   = new gGridTool(188, 8, this);
		gBox *b1   = new gBox  (248, 8, 300, 20);    // padding actionType - zoomButtons
		zoomIn     = new gClick(w()-8-40-4, 8, 20, 20, "+");
		zoomOut    = new gClick(w()-8-20,   8, 20, 20, "-");
	upperArea->end();
	upperArea->resizable(b1);

	actionType->add("key press");
	actionType->add("key release");
	actionType->add("kill chan");
	actionType->value(0);

	gridTool->init(G_Conf.actionEditorGridVal, G_Conf.actionEditorGridOn);
	gridTool->calc();

	if (G_Mixer.chanMode[chan] == SINGLE_PRESS || G_Mixer.chanMode[chan] & LOOP_ANY)
		actionType->deactivate();

	zoomIn->callback(cb_zoomIn, (void*)this);
	zoomOut->callback(cb_zoomOut, (void*)this);

	/* side boxes with text infos for the channel (actions, mute, ...)
	 * Even here we need the padding box trick, otherwise when you enlarge
	 * the window vertically, text boxes strech. */

	Fl_Group *texts = new Fl_Group(8, 36, 92, 160);
		gBox *txtActions = new gBox(8, 36,  92, 20, "Actions");
		gBox *txtMutes   = new gBox(8, 80,  92, 20, "Mute");
		gBox *txtDist    = new gBox(8, 100, 92, 20);  // pading border - buttons

		txtActions->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
		txtMutes  ->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);

		if (G_Mixer.chanMode[chan] & LOOP_ANY) {
			gBox *txtDisabled = new gBox(8, 48, 92, 20, "disabled");
			txtDisabled->labelsize(9);
			txtDisabled->labelcolor(COLOR_BD_0);
			txtDisabled->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
		}
	texts->end();
	texts->resizable(txtDist);

	/* main scroller: contains all widgets */

	scroller = new Fl_Scroll(104, 36, this->w()-112, this->h()-44);
	scroller->type(Fl_Scroll::HORIZONTAL);
	scroller->hscrollbar.color(COLOR_BG_0);
	scroller->hscrollbar.selection_color(COLOR_BG_1);
	scroller->hscrollbar.labelcolor(COLOR_BD_1);
	scroller->hscrollbar.slider(G_BOX);

	scroller->begin();
		ac = new gActionChannel(scroller->x(), 36, this);
		mc = new gMuteChannel  (scroller->x(), 84, this);
	scroller->end();

	end();

	/* if channel is LOOP_ANY, deactivate it: a loop mode channel cannot
	 * hold keypress/keyrelease actions */

	if (G_Mixer.chanMode[chan] & LOOP_ANY)
		ac->deactivate();

	gu_setFavicon(this);

	char buf[256];
	sprintf(buf, "Edit Actions in Channel %d", chan+1);
	label(buf);

	set_non_modal();
	size_range(640, 176);
	resizable(scroller);

	show();
}
Esempio n. 21
0
gdActionEditor::gdActionEditor(channel *chan)
: gWindow(640, 284), chan(chan), zoom(100)
{

	if (G_Conf.actionEditorW) {
		resize(G_Conf.actionEditorX, G_Conf.actionEditorY, G_Conf.actionEditorW, G_Conf.actionEditorH);
		zoom = G_Conf.actionEditorZoom;
	}

	/* compute values */

	calc();

	/* container with zoom buttons and the action type selector. Scheme of
	 * the resizable boxes: |[--b1--][actionType][--b2--][+][-]| */

	Fl_Group *upperArea = new Fl_Group(8, 8, w()-16, 20);
	upperArea->begin();
	if (chan->type == CHANNEL_SAMPLE) {
	  actionType = new gChoice(8, 8, 80, 20);
	  gridTool   = new gGridTool(actionType->x()+actionType->w()+4, 8, this);
	}
	else
		gridTool   = new gGridTool(8, 8, this);

		gBox *b1   = new gBox(gridTool->x()+gridTool->w()+4, 8, 300, 20);    // padding actionType - zoomButtons
		zoomIn     = new gClick(w()-8-40-4, 8, 20, 20, "+");
		zoomOut    = new gClick(w()-8-20,   8, 20, 20, "-");
	upperArea->end();
	upperArea->resizable(b1);

	if (chan->type == CHANNEL_SAMPLE) {
		actionType->add("key press");
		actionType->add("key release");
		actionType->add("kill chan");
		actionType->value(0);
	}

	gridTool->init(G_Conf.actionEditorGridVal, G_Conf.actionEditorGridOn);
	gridTool->calc();

	if (chan->type == CHANNEL_SAMPLE &&
	   (chan->mode == SINGLE_PRESS   ||
			chan->mode & LOOP_ANY))
		actionType->deactivate();

	zoomIn->callback(cb_zoomIn, (void*)this);
	zoomOut->callback(cb_zoomOut, (void*)this);

	/* main scroller: contains all widgets */

	scroller = new gScroll(8, 36, this->w()-16, this->h()-44);

	if (chan->type == CHANNEL_SAMPLE) {
		ac = new gActionChannel     (scroller->x(), upperArea->y()+upperArea->h()+8, this);
		mc = new gMuteChannel       (scroller->x(), ac->y()+ac->h()+8, this);
		vc = new gEnvelopeChannel   (scroller->x(), mc->y()+mc->h()+8, this, ACTION_VOLUME, RANGE_FLOAT, "volume");
		scroller->add(ac);
		//scroller->add(new gResizerBar(ac->x(), ac->y()+ac->h(), scroller->w(), 8));
		scroller->add(mc);
		//scroller->add(new gResizerBar(mc->x(), mc->y()+mc->h(), scroller->w(), 8));
		scroller->add(vc);
		//scroller->add(new gResizerBar(vc->x(), vc->y()+vc->h(), scroller->w(), 8));

		/* fill volume envelope with actions from recorder */

		vc->fill();

		/* if channel is LOOP_ANY, deactivate it: a loop mode channel cannot
		 * hold keypress/keyrelease actions */

		if (chan->mode & LOOP_ANY)
			ac->deactivate();
	}
	else {
		pr = new gPianoRollContainer(scroller->x(), upperArea->y()+upperArea->h()+8, this);
		scroller->add(pr);
		scroller->add(new gResizerBar(pr->x(), pr->y()+pr->h(), scroller->w(), 8));
	}

	end();

	gu_setFavicon(this);

	char buf[256];
	sprintf(buf, "Edit Actions in Channel %d", chan->index+1);
	label(buf);

	set_non_modal();
	size_range(640, 284);
	resizable(scroller);

	show();
}
Esempio n. 22
0
 myglwindow(int wx, int wy, int width, int height, const char *nm, 
   FltkOpenGLDisplayDevice *d, VMDApp *vmdapp) 
 : Fl_Gl_Window(wx, wy, width, height, nm), dispdev(d), app(vmdapp), dragpending(0) {
   // XXX this may not be reliable on MacOS X with recent revs of FLTK
   size_range(1,1,0,0); // resizable to full screen
 }
Esempio n. 23
0
gdBrowser::gdBrowser(const char *title, const char *initPath, Channel *ch, int type, int stackType)
	:	gWindow  (396, 302, title),
		ch       (ch),
		type     (type),
		stackType(stackType)
{
	set_non_modal();

	browser = new gBrowser(8, 36, 380, 230);
	Fl_Group *group_btn = new Fl_Group(8, 274, 380, 20);
		gBox *b = new gBox(8, 274, 204, 20); 					        // spacer window border <-> buttons
		ok  	  = new gClick(308, 274, 80, 20);
		cancel  = new gClick(220, 274, 80, 20, "Cancel");
		status  = new gProgress(8, 274, 204, 20);
		status->minimum(0);
		status->maximum(1);
		status->hide();   // show the bar only if necessary
	group_btn->resizable(b);
	group_btn->end();

	Fl_Group *group_upd = new Fl_Group(8, 8, 380, 25);
		if (type == BROWSER_SAVE_PATCH || type == BROWSER_SAVE_SAMPLE || type == BROWSER_SAVE_PROJECT)  /// bitmask please!
			name = new gInput(208, 8, 152, 20);
		if (type == BROWSER_SAVE_PATCH || type == BROWSER_SAVE_SAMPLE || type == BROWSER_SAVE_PROJECT)  /// bitmask please!
			where = new gInput(8, 8, 192, 20);
		else
			where = new gInput(8, 8, 352, 20);
		updir	= new gClick(368, 8, 20, 20, "", updirOff_xpm, updirOn_xpm);
	group_upd->resizable(where);
	group_upd->end();

	end();

	resizable(browser);
	size_range(w(), h(), 0, 0);

	where->readonly(true);
	where->cursor_color(COLOR_BG_DARK);

	if (type == BROWSER_SAVE_PATCH || type == BROWSER_SAVE_SAMPLE || type == BROWSER_SAVE_PROJECT)  /// bitmask please!
		ok->label("Save");
	else
		ok->label("Load");

	if (type == BROWSER_LOAD_PATCH)
		ok->callback(cb_load_patch, (void*)this);
	else
	if (type == BROWSER_LOAD_SAMPLE)
		ok->callback(cb_load_sample, (void*)this);
	else
	if (type == BROWSER_SAVE_PATCH) {
		ok->callback(cb_save_patch, (void*)this);
		name->value(G_Patch.name[0] == '\0' ? "my_patch.gptc" : G_Patch.name);
		name->maximum_size(MAX_PATCHNAME_LEN+5); // +5 for ".gptc"
	}
	else
	if (type == BROWSER_SAVE_SAMPLE) {
		ok->callback(cb_save_sample, (void*)this);
		name->value(((SampleChannel*)ch)->wave->name.c_str());
	}
	else
	if (type == BROWSER_SAVE_PROJECT) {
		ok->callback(cb_save_project, (void*)this);
		name->value(gStripExt(G_Patch.name).c_str());
	}
#ifdef WITH_VST
	else
	if (type == BROWSER_LOAD_PLUGIN) {
		ok->callback(cb_loadPlugin, (void*)this);
	}
#endif

	ok->shortcut(FL_Enter);

	updir->callback(cb_up, (void*)this);
	cancel->callback(cb_close, (void*)this);
	browser->callback(cb_down, this);
	browser->path_obj = where;
	browser->init(initPath);

	if (G_Conf.browserW)
		resize(G_Conf.browserX, G_Conf.browserY, G_Conf.browserW, G_Conf.browserH);

	gu_setFavicon(this);
	show();
}
Esempio n. 24
0
Plugin_Chooser::Plugin_Chooser ( int X,int Y,int W,int H, const char *L )
    : Fl_Double_Window ( X,Y,W,H,L )
{
    set_modal();
    _value = 0;
   
    _plugins = Plugin_Module::get_all_plugins();


    {
        Plugin_Chooser_UI *o = ui = new Plugin_Chooser_UI(X,Y,W,H);

        o->name_input->callback( &Plugin_Chooser::cb_handle, this );
        o->name_input->when( FL_WHEN_CHANGED );


        o->author_input->callback( &Plugin_Chooser::cb_handle, this );
        o->author_input->when( FL_WHEN_CHANGED );


        o->inputs_input->callback( &Plugin_Chooser::cb_handle, this );
        o->inputs_input->when( FL_WHEN_CHANGED );

        o->outputs_input->callback( &Plugin_Chooser::cb_handle, this );
        o->outputs_input->when( FL_WHEN_CHANGED );

        o->favorites_button->callback( &Plugin_Chooser::cb_handle, this );
        o->favorites_button->when( FL_WHEN_CHANGED );

        o->all_button->callback( &Plugin_Chooser::cb_handle, this );
        o->all_button->when( FL_WHEN_CHANGED );


        o->category_choice->callback( &Plugin_Chooser::cb_handle, this );
        o->category_choice->when( FL_WHEN_CHANGED );

        {
            Plugin_Table *o = new Plugin_Table(ui->table->x(),ui->table->y(),ui->table->w(),ui->table->h() );
            ui->table_group->add(o);
            ui->table_group->resizable(o);
            delete ui->table;
            ui->table = o;
            /* ui->scalepack->add( o ); */
            /* ui->scalepack->resizable( o ); */
            o->col_header(1);
            o->col_resize(1);
            o->row_resize(1);
            o->cols(6);
            o->col_resize_min(4);
            o->col_width(0,30);
            o->col_width(1,350 - 7);
            o->col_width(2,200);
            o->col_width(3,75);
            o->col_width(4,30);
            o->col_width(5,30);
            o->color(FL_BLACK);
            o->box(FL_NO_BOX);
            o->when(FL_WHEN_CHANGED);
            o->callback( &Plugin_Chooser::cb_table, this );
            
        }

        resizable(o);
    }
    size_range( 735, 300, 735, 0 );
    
    end();

    load_categories();

    if ( load_favorites() )
    {
        ui->all_button->value(0);
        ui->favorites_button->value(1);
    }
}
Esempio n. 25
0
gdEditor::gdEditor(SampleChannel *ch)
  : gWindow(640, 480),
    ch(ch)
{
  set_non_modal();

  if (G_Conf.sampleEditorX)
    resize(G_Conf.sampleEditorX, G_Conf.sampleEditorY, G_Conf.sampleEditorW, G_Conf.sampleEditorH);

  /* top bar: grid and zoom tools */

  Fl_Group *bar = new Fl_Group(8, 8, w()-16, 20);
  bar->begin();
    grid    = new gChoice(bar->x(), bar->y(), 50, 20);
    snap    = new gCheck(grid->x()+grid->w()+4, bar->y()+4, 12, 12);
    zoomOut = new gClick(bar->x()+bar->w()-20, bar->y(), 20, 20, "", zoomOutOff_xpm, zoomOutOn_xpm);
    zoomIn  = new gClick(zoomOut->x()-24, bar->y(), 20, 20, "", zoomInOff_xpm, zoomInOn_xpm);
  bar->end();
  bar->resizable(new gBox(grid->x()+grid->w()+4, bar->y(), 80, bar->h()));

  /* waveform */

  waveTools = new gWaveTools(8, 36, w()-16, h()-120, ch);
  waveTools->end();

  /* other tools */

  Fl_Group *tools = new Fl_Group(8, waveTools->y()+waveTools->h()+8, w()-16, 130);
  tools->begin();
    volume        = new gDial (tools->x()+50,                    tools->y(), 20, 20, "Volume");
    volumeNum     = new gInput(volume->x()+volume->w()+4,        tools->y(), 46, 20, "dB");

    boost         = new gDial (volumeNum->x()+volumeNum->w()+108, tools->y(), 20, 20, "Boost");
    boostNum      = new gInput(boost->x()+boost->w()+4,           tools->y(), 44, 20, "dB");

    normalize     = new gClick(boostNum->x()+boostNum->w()+54,   tools->y(), 70, 20, "Normalize");
    pan           = new gDial (normalize->x()+normalize->w()+40, tools->y(), 20, 20, "Pan");
    panNum        = new gInput(pan->x()+pan->w()+4,              tools->y(), 45, 20, "%");

    pitch         = new gDial (tools->x()+50,                       volume->y()+volume->h()+4, 20, 20, "Pitch");
    pitchNum      = new gInput(pitch->x()+pitch->w()+4,             volume->y()+volume->h()+4, 46, 20);
    pitchToBar    = new gClick(pitchNum->x()+pitchNum->w()+4,       volume->y()+volume->h()+4, 60, 20, "To bar");
    pitchToSong   = new gClick(pitchToBar->x()+pitchToBar->w()+4,   volume->y()+volume->h()+4, 60, 20, "To song");
    pitchHalf     = new gClick(pitchToSong->x()+pitchToSong->w()+4, volume->y()+volume->h()+4, 20, 20, "", divideOff_xpm, divideOn_xpm);
    pitchDouble   = new gClick(pitchHalf->x()+pitchHalf->w()+4,     volume->y()+volume->h()+4, 20, 20, "", multiplyOff_xpm, multiplyOn_xpm);
    pitchReset    = new gClick(pitchDouble->x()+pitchDouble->w()+4, volume->y()+volume->h()+4, 46, 20, "Reset");
    reload        = new gClick(pitchReset->x()+pitchReset->w()+4,   volume->y()+volume->h()+4, 70, 20, "Reload");

    chanStart     = new gInput(tools->x()+60,                   pitch->y()+pitch->h()+4, 60, 20, "Range");
    chanEnd       = new gInput(chanStart->x()+chanStart->w()+4, pitch->y()+pitch->h()+4, 60, 20, "");
    resetStartEnd = new gClick(chanEnd->x()+chanEnd->w()+4,     pitch->y()+pitch->h()+4, 60, 20, "Reset");

  tools->end();
  tools->resizable(new gBox(panNum->x()+panNum->w()+4, tools->y(), 80, tools->h()));

  /* grid tool setup */

  grid->add("(off)");
  grid->add("2");
  grid->add("3");
  grid->add("4");
  grid->add("6");
  grid->add("8");
  grid->add("16");
  grid->add("32");
  grid->add("64");
  grid->value(G_Conf.sampleEditorGridVal);
  grid->callback(cb_changeGrid, (void*)this);

  snap->value(G_Conf.sampleEditorGridOn);
  snap->callback(cb_enableSnap, (void*)this);

  /* TODO - redraw grid if != (off) */

  char buf[16];
  sprintf(buf, "%d", ch->begin / 2); // divided by 2 because stereo
  chanStart->value(buf);
  chanStart->type(FL_INT_INPUT);
  chanStart->callback(cb_setChanPos, this);

  /* inputs callback: fire when they lose focus or Enter is pressed. */

  chanStart->when(FL_WHEN_RELEASE | FL_WHEN_ENTER_KEY);
  chanEnd  ->when(FL_WHEN_RELEASE | FL_WHEN_ENTER_KEY);

  sprintf(buf, "%d", ch->end / 2);  // divided by 2 because stereo
  chanEnd->value(buf);
  chanEnd->type(FL_INT_INPUT);
  chanEnd->callback(cb_setChanPos, this);

  resetStartEnd->callback(cb_resetStartEnd, this);

  volume->callback(cb_setVolume, (void*)this);
  volume->value(ch->guiChannel->vol->value());

  float dB = 20*log10(ch->volume);   // dB = 20*log_10(linear value)
  if (dB > -INFINITY) sprintf(buf, "%.2f", dB);
  else                sprintf(buf, "-inf");
  volumeNum->value(buf);
  volumeNum->align(FL_ALIGN_RIGHT);
  volumeNum->callback(cb_setVolumeNum, (void*)this);

  boost->range(1.0f, 10.0f);
  boost->callback(cb_setBoost, (void*)this);
  if (ch->boost > 10.f)
    boost->value(10.0f);
  else
    boost->value(ch->boost);
  boost->when(FL_WHEN_CHANGED | FL_WHEN_RELEASE);

  float boost = 20*log10(ch->boost); // dB = 20*log_10(linear value)
  sprintf(buf, "%.2f", boost);
  boostNum->value(buf);
  boostNum->align(FL_ALIGN_RIGHT);
  boostNum->callback(cb_setBoostNum, (void*)this);

  normalize->callback(cb_normalize, (void*)this);

  pan->range(0.0f, 2.0f);
  pan->callback(cb_panning, (void*)this);

  pitch->range(0.01f, 4.0f);
  pitch->value(ch->pitch);
  pitch->callback(cb_setPitch, (void*)this);
  pitch->when(FL_WHEN_RELEASE);

  sprintf(buf, "%.4f", ch->pitch); // 4 digits
  pitchNum->value(buf);
  pitchNum->align(FL_ALIGN_RIGHT);
  pitchNum->callback(cb_setPitchNum, (void*)this);
  pitchNum->when(FL_WHEN_RELEASE | FL_WHEN_ENTER_KEY);

  pitchToBar->callback(cb_setPitchToBar, (void*)this);
  pitchToSong->callback(cb_setPitchToSong, (void*)this);
  pitchHalf->callback(cb_setPitchHalf, (void*)this);
  pitchDouble->callback(cb_setPitchDouble, (void*)this);
  pitchReset->callback(cb_resetPitch, (void*)this);

  reload->callback(cb_reload, (void*)this);

  zoomOut->callback(cb_zoomOut, (void*)this);
  zoomIn->callback(cb_zoomIn, (void*)this);

  /* logical samples (aka takes) cannot be reloaded. So far. */

  if (ch->wave->isLogical)
    reload->deactivate();

  if (ch->panRight < 1.0f) {
    char buf[8];
    sprintf(buf, "%d L", (int) std::abs((ch->panRight * 100.0f) - 100));
    pan->value(ch->panRight);
    panNum->value(buf);
  }
  else if (ch->panRight == 1.0f && ch->panLeft == 1.0f) {
    pan->value(1.0f);
    panNum->value("C");
  }
  else {
    char buf[8];
    sprintf(buf, "%d R", (int) std::abs((ch->panLeft * 100.0f) - 100));
    pan->value(2.0f - ch->panLeft);
    panNum->value(buf);
  }

  panNum->align(FL_ALIGN_RIGHT);
  panNum->readonly(1);
  panNum->cursor_color(FL_WHITE);

  gu_setFavicon(this);
  size_range(640, 480);
  resizable(waveTools);

  label(ch->wave->name.c_str());

  show();
}
Esempio n. 26
0
void resize_rearrange(array_nd<T, S>& a, const array<size_t, D>& new_sz,
						const array<size_t, L>& new_stride,
						bool pad = false, const T& padval = T())
{
	bool skip_flag = true;
	size_t dm = std::min(size_t(a.ndims()), size_t(new_sz.length()));
	array<index_array, tiny> id(a.ndims());

	for(size_t i = dm; i < a.ndims(); i++)
		id[i] = idx(0);

	array<size_t, tiny> junc(dm);
	for(size_t i = 0; i < dm; i++)
		junc[i] = std::min(new_sz[i], a.size_nd(i));

	for(size_t i = 0; i < dm; i++) {
		// should some dims be reverse and some not
		if(a.stride(i) >= new_stride[i])
			id[i] = size_range(0, junc[i] - 1);
		else
			id[i] = size_range(junc[i] - 1, 0);
		if(a.stride(i) != new_stride[i] &&
			!(new_sz[i] == 1) && !(a.size_nd(i) == 1))
			skip_flag = false;
	}

	// if data is in the same position, it needs no repositioning.
	if(!skip_flag) {
		// shape of the old array, but with same number of dims as the new array
		array<size_t, tiny> new_szm(a.ndims(), 1);
		size_range new_szr(0, std::min(new_sz.length() - 1, a.ndims() - 1));
		new_szm[new_szr] = new_sz[new_szr];

		// performs shape manipulation on the array without resizing it:
		array_nd<T, data::ref_iterator<array_nd<T, S> > >
			new_arr(new_szm/* */, a);
		//new_arr.init(a);

		//TODO: ivl::serial(.)
		//and worry about dimension sorting
		force(new_arr(id)) = a(id);
	}

	if(pad) {
		id.resize(new_sz.length(), idx(0));
		array_nd<T, data::ref_iterator<array_nd<T, S> > >
			new_arr(new_sz, a);

		// padding common dimensions
		for(size_t i = 0; i < dm; i++) {
			id[i] = size_range(junc[i], new_sz[i] - 1);
			new_arr(id) = padval;
			id[i] = index_all();
		}

		// padding extra dimensions
		for(size_t i = dm; i < new_sz.length(); i++) {
			id[i] = size_range(1, new_sz[i] - 1);
			new_arr(id) = padval;
			id[i] = index_all();
		}
	}
}