예제 #1
0
파일: dirs.c 프로젝트: ayyi/samplecat
	void dirs_init(AGlActor* a)
	{
#ifdef AGL_ACTOR_RENDER_CACHE
		a->fbo = agl_fbo_new(agl_actor__width(a), agl_actor__height(a), 0, AGL_FBO_HAS_STENCIL);
		a->cache.enabled = true;
#endif
	}
예제 #2
0
파일: scrollable.c 프로젝트: ayyi/samplecat
	void scrollable_set_size(AGlActor* actor)
	{
		// first scrollable view child takes up all available space

		AGlActor* child = actor->children->data;
		child->region = (AGliRegion){0, 0, agl_actor__width(actor), agl_actor__height(actor)};
		agl_actor__set_size(child);

		scrollable_set_scroll_position(actor, -1);
	}
예제 #3
0
파일: scrollable.c 프로젝트: ayyi/samplecat
	bool scrollable_event(AGlActor* actor, GdkEvent* event, AGliPt xy)
	{
		ScrollableView* view = (ScrollableView*)actor;

		switch(event->type){
			case GDK_BUTTON_PRESS:
				switch(event->button.button){
					case 4:
						scrollable_set_scroll_position(actor, view->scroll_offset - 10);
						agl_actor__invalidate(actor);
						break;
					case 5:
						if(agl_actor__scrollable_height(((AGlActor*)actor->children->data)) > agl_actor__height(actor)){
							scrollable_set_scroll_position(actor, view->scroll_offset + 10);
							agl_actor__invalidate(actor);
						}
						break;
				}
				break;
			default:
				break;
		}
		return AGL_HANDLED;
	}
예제 #4
0
int
main(int argc, char* argv[])
{
	_debug_ = 0;

	samplecat_init();

	gtk_init_check(&argc, &argv);
	type_init();
	pixmaps_init();
	icon_theme_init();

	Window win;
	GLXContext ctx;
	GLboolean fullscreen = GL_FALSE;
	static int width = 400, height = 300;

	int i; for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-verbose") == 0) {
			_debug_ = 1;
		}
#if 0
		else if (strcmp(argv[i], "-swap") == 0 && i + 1 < argc) {
			swap_interval = atoi( argv[i+1] );
			do_swap_interval = GL_TRUE;
			i++;
		}
		else if (strcmp(argv[i], "-forcegetrate") == 0) {
			/* This option was put in because some DRI drivers don't support the
			 * full GLX_OML_sync_control extension, but they do support
			 * glXGetMscRateOML.
			 */
			force_get_rate = GL_TRUE;
		}
#endif
		else if (strcmp(argv[i], "-fullscreen") == 0) {
			fullscreen = GL_TRUE;
		}
		else if (strcmp(argv[i], "-help") == 0) {
			printf("Usage:\n");
			printf("  glx [options]\n");
			printf("Options:\n");
			printf("  -help                   Print this information\n");
			printf("  -verbose                Output info to stdout\n");
			printf("  -swap N                 Swap no more than once per N vertical refreshes\n");
			printf("  -forcegetrate           Try to use glXGetMscRateOML function\n");
			printf("  -fullscreen             Full-screen window\n");
			return 0;
		}
	}

	Display* dpy = XOpenDisplay(NULL);
	if(!dpy){
		printf("Error: couldn't open display %s\n", XDisplayName(NULL));
		return -1;
	}

	int screen = DefaultScreen(dpy);
	make_window(dpy, "Samplcecat", (XDisplayWidth(dpy, screen) - width) / 2, (XDisplayHeight(dpy, screen) - height) / 2, width, height, fullscreen, &win, &ctx);

	agl_get_extensions();

	glx_init(dpy);

	g_main_loop_new(NULL, true);

	scene = (AGlRootActor*)agl_actor__new_root_(CONTEXT_TYPE_GLX);

	void scene_needs_redraw(AGlScene* scene, gpointer _){ need_draw = true; }
	scene->draw = scene_needs_redraw;

	gboolean add_content(gpointer _)
	{ 
		app->config_ctx.filename = g_strdup_printf("%s/.config/" PACKAGE "/" PACKAGE, g_get_home_dir());
		config_load(&app->config_ctx, &app->config);

		if (app->config.database_backend && can_use(samplecat.model->backends, app->config.database_backend)) {
			#define list_clear(L) g_list_free(L); L = NULL;
			list_clear(samplecat.model->backends);
			samplecat_model_add_backend(app->config.database_backend);
		}

		db_init(
#ifdef USE_MYSQL
			&app->config.mysql
#else
			NULL
#endif
		);
		if (!db_connect()) {
			g_warning("cannot connect to any database.\n");
			return EXIT_FAILURE;
		}

		samplecat_list_store_do_search((SamplecatListStore*)samplecat.store);

		Waveform* w = NULL;

		WaveformCanvas* wfc = wf_context_new(scene);

		agl_actor__add_child((AGlActor*)scene, actors.bg = background_actor(NULL));
		actors.bg->region.x2 = 1;
		actors.bg->region.y2 = 1;

		agl_actor__add_child((AGlActor*)scene, actors.search = search_view(NULL));
		agl_actor__add_child((AGlActor*)scene, actors.list = list_view(NULL));

		agl_actor__add_child((AGlActor*)scene, actors.wave = (AGlActor*)wf_canvas_add_new_actor(wfc, w));

		void scene_set_size(AGlActor* scene)
		{
			#define SPACING 2
			int vspace = scene->region.y2 - 40;
			int y = 20;

			int h = search_view_height((SearchView*)actors.search);
			actors.search->region = (AGliRegion){20, y, scene->region.x2 - 20, y + h};
			agl_actor__set_size(actors.search);
			vspace -= h + SPACING;
			y += h + SPACING;

			actors.list->region = (AGliRegion){20, y, scene->region.x2 - 20, y + vspace / 2};
			vspace -= vspace / 2;
			y += vspace;
			agl_actor__set_size(actors.list); // clear cache

			actors.wave->region = (AGliRegion){
				20,
				y,
				scene->region.x2 - 20,
				y + vspace
			};
			wf_actor_set_rect((WaveformActor*)actors.wave, &(WfRectangle){
				0.0,
				0.0,
				agl_actor__width(actors.wave),
				agl_actor__height(actors.wave)
			});

			need_draw = true;
		}