コード例 #1
0
void GazeTracker::boundToScreenCoordinates(Point &estimate) {
	int numMonitors = Gdk::Screen::get_default()->get_n_monitors();
	Gdk::Rectangle monitorGeometry;
	Glib::RefPtr<Gdk::Screen> screen = Gdk::Display::get_default()->get_default_screen();

	// Geometry of main monitor
	screen->get_monitor_geometry(numMonitors - 1, monitorGeometry);

	// If x or y coordinates are outside screen boundaries, correct them
	if (estimate.x < monitorGeometry.get_x()) {
		estimate.x = monitorGeometry.get_x();
	}

	if (estimate.y < monitorGeometry.get_y()) {
		estimate.y = monitorGeometry.get_y();
	}

	if (estimate.x >= monitorGeometry.get_x() + monitorGeometry.get_width()) {
		estimate.x = monitorGeometry.get_x() + monitorGeometry.get_width();
	}

	if (estimate.y >= monitorGeometry.get_y() + monitorGeometry.get_height()) {
		estimate.y = monitorGeometry.get_y() + monitorGeometry.get_height();
	}
}
コード例 #2
0
ファイル: emblemcellrenderer.cpp プロジェクト: egore/meld
void EmblemCellRenderer::do_render(const Cairo::RefPtr<Cairo::Context>& context, int widget, int background_area, Gdk::Rectangle &cell_area, int flags) {
    context->translate(cell_area.get_x(), cell_area.get_y());
    context->rectangle(0, 0, cell_area.get_width(), cell_area.get_height());
    context->clip();

    // TODO: Incorporate padding
    context->push_group();
    if (!this->_icon_name.empty()) {
        Glib::RefPtr<Gdk::Pixbuf> pixbuf = this->_get_pixbuf(this->_icon_name, this->_icon_size);
        context->set_operator(Cairo::OPERATOR_SOURCE);
        // Assumes square icons; may break if we don't get the requested size
        int height_offset = int((cell_area.get_height() - pixbuf->get_height())/2);
        Gdk::Cairo::set_source_pixbuf(context, pixbuf, 0, height_offset);
        context->rectangle(0, height_offset,
                          pixbuf->get_width(), pixbuf->get_height());
        context->fill();

        if (this->_tint_color) {
            Gdk::RGBA* c = this->_tint_color;
            gushort r = c->get_red();
            gushort g = c->get_green();
            gushort b = c->get_blue();
            // Figure out the difference between our tint colour and an
            // empirically determined (i.e., guessed) satisfying luma and
            // adjust the base colours accordingly
            double luma = (r + r + b + g + g + g) / 6.;
            double extra_luma = (1.2 - luma) / 3.;
            r = std::min(r + extra_luma, 1.);
            g = std::min(g + extra_luma, 1.);
            b = std::min(b + extra_luma, 1.);
            context->set_source_rgba(r, g, b, 0.4);
            context->set_operator(Cairo::OPERATOR_ATOP);
            context->paint();
        }

        if (!this->_emblem_name.empty()) {
            Glib::RefPtr<Gdk::Pixbuf> pixbuf = this->_get_pixbuf(this->_emblem_name, this->_emblem_size);
            int x_offset = this->_icon_size - this->_emblem_size;
            context->set_operator(Cairo::OPERATOR_OVER);
            Gdk::Cairo::set_source_pixbuf(context, pixbuf, x_offset, 0);
            context->rectangle(x_offset, 0,
                              cell_area.get_width(), this->_emblem_size);
            context->fill();
        }
    }

    context->pop_group_to_source();
    context->set_operator(Cairo::OPERATOR_OVER);
    context->paint();
}
コード例 #3
0
std::string EntityChooser::ChooseEntity(const std::string& preSelectedEntity)
{
	gtkutil::Dialog dlg(_("Select Entity"), GlobalMainFrame().getTopLevelWindow());

	Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalMainFrame().getTopLevelWindow());

	dlg.set_default_size(static_cast<int>(rect.get_width()/2), static_cast<int>(2*rect.get_height()/3));

	// Instantiate a new chooser class
	EntityChooserPtr chooser(new EntityChooser);
	chooser->setSelectedEntity(preSelectedEntity);

	// add this to the dialog window
	IDialog::Handle handle = dlg.addElement(chooser);

	if (dlg.run() == IDialog::RESULT_OK)
	{
		return dlg.getElementValue(handle);
	}
	else
	{
		// Cancelled
		return "";
	}
}
コード例 #4
0
Gui_DisplayBaseClass::Gui_DisplayBaseClass(Gui_ProcessorHandler& processor_hand):
    m_processor_hand(processor_hand),
    m_deco(this,processor_hand,m_show_idx,m_show_point,m_ROI),
    m_ROI(cv::Point(0,0),cv::Point(0,0)),
    m_draw_result(false),
    m_alph_mask(128),
    m_show_idx(-1),m_show_point(false),m_show_mask(true),
    m_cursor(Gdk::CROSS)
    {

    this->add_events( Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK );
    this->signal_scroll_event().connect( sigc::mem_fun( *this, &Gui_DisplayBaseClass::on_scroll) );
    this->signal_button_press_event().connect( sigc::mem_fun( *this, &Gui_DisplayBaseClass::on_click) );

    m_color.set_rgb_p(0.2,0.2,0.2);
    this->modify_bg(Gtk::STATE_NORMAL,m_color);

    m_processor_hand.signal_state().connect( sigc::mem_fun(*this,&Gui_DisplayBaseClass::myRedraw));

    Glib::RefPtr< Gdk::Screen > screen = Gdk::Screen::get_default();
    Gdk::Rectangle rect;
    screen->get_monitor_geometry(screen->get_primary_monitor(),rect);
    set_size_request(rect.get_width()/4,rect.get_height()/4);



    makeLUT();




}
コード例 #5
0
// Construct the dialog
LightTextureChooser::LightTextureChooser()
:	gtkutil::BlockingTransientWindow(_("Choose texture"), GlobalMainFrame().getTopLevelWindow()),
	_selector(Gtk::manage(new ShaderSelector(this, getPrefixList(), true))) // true >> render a light texture
{
	// Set the default size of the window
	Gdk::Rectangle rect;

	if (GlobalGroupDialog().getDialogWindow()->is_visible())
	{
		rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalGroupDialog().getDialogWindow());
	}
	else
	{
		rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalMainFrame().getTopLevelWindow());
	}

	set_default_size(static_cast<int>(rect.get_width()*0.6f), static_cast<int>(rect.get_height()*0.6f));

	// Construct main VBox, and pack in ShaderSelector and buttons panel
	Gtk::VBox* vbx = Gtk::manage(new Gtk::VBox(false, 6));

	vbx->pack_start(*_selector, true, true, 0);
	vbx->pack_start(createButtons(), false, false, 0);

	add(*vbx);
}
コード例 #6
0
ファイル: NoteItemView.cpp プロジェクト: pzagawa/myagenda
void ItemView::drawButton(const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Image* image, Gdk::Rectangle rect)
{
    const Glib::RefPtr<Gdk::Pixbuf> icon = image->get_pixbuf();

    const int iconLeft = rect.get_x() + (rect.get_width() * 0.5) - (icon->get_width() * 0.5);
    const int iconTop = rect.get_y() + (rect.get_height() * 0.5) - (icon->get_height() * 0.5);

    Gdk::Cairo::set_source_pixbuf(cr, icon, iconLeft, iconTop);
    cr->rectangle(iconLeft, iconTop, icon->get_width(), icon->get_height());
    cr->fill();
}
コード例 #7
0
ファイル: NoteItemView.cpp プロジェクト: pzagawa/myagenda
bool ItemView::isHit(GdkEventButton* event, Gdk::Rectangle& rect)
{
    const int left = rect.get_x();
    const int top = rect.get_y();
    const int right = left + rect.get_width();
    const int bottom = top + rect.get_height();

    if (event->x > left && event->x < right)
        if (event->y > top && event->y < bottom)
            return true;

    return false;}
コード例 #8
0
void sourceview___::scroll2__(SourceView*sv,Gtk::TextIter ti){
	RefPtr<Gtk::TextBuffer> tb=sv->get_buffer();
	tb->place_cursor(ti);
	Gtk::TextBuffer::iterator i1,i2;
	tb->get_selection_bounds(i1,i2);

	Gdk::Rectangle rect;
	sv->get_visible_rect(rect);
	int y = -1;
	int height = -1;
	sv->get_line_yrange(i1, y, height);
	if (y < rect.get_y() + rect.get_height() + 16)
		 sv->scroll_to_mark(tb->get_insert(), 0);
}
コード例 #9
0
ファイル: widget_gradient.cpp プロジェクト: ZurbaXI/synfig
void
studio::render_gradient_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Gradient &gradient)
{
	int	height = ca.get_height();
	int	width = ca.get_width()-4;

	float sample_width(1.0f/(float)width);
	Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
	const Color bg1(0.25, 0.25, 0.25);
	const Color bg2(0.5, 0.5, 0.5);
	Gdk::Color gdk_c;
	int i;
	for(i=0;i<width;i++)
	{
		const Color c(gradient(float(i)/float(width),sample_width));
		const Color c1(Color::blend(c,bg1,1.0).clamped());
		const Color c2(Color::blend(c,bg2,1.0).clamped());
		gushort r1(256*App::gamma.r_F32_to_U8(c1.get_r()));
		gushort g1(256*App::gamma.g_F32_to_U8(c1.get_g()));
		gushort b1(256*App::gamma.b_F32_to_U8(c1.get_b()));
		gushort r2(256*App::gamma.r_F32_to_U8(c2.get_r()));
		gushort g2(256*App::gamma.g_F32_to_U8(c2.get_g()));
		gushort b2(256*App::gamma.b_F32_to_U8(c2.get_b()));

		if((i*2/height)&1)
		{
			gdk_c.set_rgb(r1,g1,b1);
			gc->set_rgb_fg_color(gdk_c);
			window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);

			gdk_c.set_rgb(r2,g2,b2);
			gc->set_rgb_fg_color(gdk_c);
			window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
		}
		else
		{
			gdk_c.set_rgb(r2,g2,b2);
			gc->set_rgb_fg_color(gdk_c);
			window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);

			gdk_c.set_rgb(r1,g1,b1);
			gc->set_rgb_fg_color(gdk_c);
			window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
		}
	}
	gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
	window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, ca.get_width()-3, height-3);
	gc->set_rgb_fg_color(Gdk::Color("#000000"));
	window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), ca.get_width()-1, height-1);
}
コード例 #10
0
MD5AnimationViewer::MD5AnimationViewer() :
	gtkutil::BlockingTransientWindow(_("MD5 Animation Viewer"), GlobalMainFrame().getTopLevelWindow()),
	_modelList(Gtk::TreeStore::create(_modelColumns)),
	_modelPopulator(_modelList),
	_animList(Gtk::ListStore::create(_animColumns)),
	_preview(new AnimationPreview)
{
	// Set the default border width in accordance to the HIG
	set_border_width(12);
	set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);

	// Set the default size of the window
	const Glib::RefPtr<Gtk::Window>& mainWindow = GlobalMainFrame().getTopLevelWindow();

	Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(mainWindow);
	int height = static_cast<int>(rect.get_height() * 0.6f);

	set_default_size(
		static_cast<int>(rect.get_width() * 0.8f), height
	);

	// Set the default size of the window
	_preview->setSize(rect.get_width() * 0.2f, height);

	// Main dialog vbox
	Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox(false, 12));

	// Create a horizontal box to pack the treeview on the left and the preview on the right
	Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox(false, 6));

	hbox->pack_start(createListPane(), true, true, 0);

	Gtk::VBox* previewBox = Gtk::manage(new Gtk::VBox(false, 0));
	previewBox->pack_start(*_preview, true, true, 0);

	hbox->pack_start(*previewBox, true, true, 0);

	vbox->pack_start(*hbox, true, true, 0);
	vbox->pack_end(createButtons(), false, false, 0);

	// Add main vbox to dialog
	add(*vbox);

	// Populate with model names
	populateModelList();
}
コード例 #11
0
bool GraficoDeTorta::dibujar(const Cairo::RefPtr<Cairo::Context>& contexto){
	Gdk::Rectangle rect = dibujo->get_allocation();
	Pango::FontDescription font;
	font.set_family("Monospace");
	font.set_weight(Pango::WEIGHT_BOLD);

	if(stock.size() == 0) return false;
	contexto->set_source_rgb(1.0,1.0,1.0);
	contexto->paint();	
	
	int total = 0;
	for(unsigned int i = 0; i < stock.size(); i++){
		total +=  stock[i].second;
	}
	float step = 2*M_PI/total;
	total = 0;
	

	float angulo0=0;
	for(unsigned int i = 0; i < stock.size(); i++){
		float angulo1 = step*stock[i].second + angulo0;
		dibujarArco(contexto,rect.get_width()/2-rect.get_width()/4,rect.get_height()/2,rect.get_width()<rect.get_height()?rect.get_width()/4:rect.get_height()/4,angulo0,angulo1,red[i],green[i],blue[i]);
		angulo0 = angulo1;
	}
	
	Glib::RefPtr<Pango::Layout> layout;
	std::stringstream s;
	for(unsigned int i = 0; i < stock.size(); i++){
		s.str("");
		s << stock[i].first << "\t" << stock[i].second;
		layout = dibujo->create_pango_layout(s.str());
		layout -> set_font_description(font);
		int t_width, t_height;
		layout->get_pixel_size(t_width,t_height);
		contexto->set_source_rgb(0,0,0);	
		contexto -> move_to((rect.get_width())/2,15*(i+1)+5);
		layout -> show_in_cairo_context(contexto);
		contexto -> set_source_rgb(red[i],green[i],blue[i]);
		contexto -> rectangle(rect.get_width()/2+80,15*(i+1)+5,30,15);
		contexto -> fill();
	}
	return true;
}
コード例 #12
0
int textview___::insert__(std::deque<Glib::ustring>* p,size_t start){
	Gtk::TextView* tv=tv__(p,1+start);
	if(!tv){
		return 1;
	}
	int i=0;
	size_t i_ctl=3+start;
	if(p->size()>i_ctl){
		if((*p)[i_ctl]=="头")
			i=1;
		else if((*p)[i_ctl]=="尾")
			i=2;
		else{
			d_(sh_,err_show_buzhichi_,2,p,i_ctl);
			return 1;
		}
	}
	Glib::RefPtr < Gtk::TextBuffer > tb = tv->get_buffer();
	Gtk::TextBuffer::iterator i1,i2;
	switch(i){
	case 1:
		i1=tb->begin();
		break;
	case 2:
		i1=tb->end();
		break;
	default:
		tb->get_selection_bounds(i1,i2);
		if(i2>i1){
			i1=tb->erase(i1,i2);
		}
		break;
	}
	Gdk::Rectangle rect;
	tv->get_visible_rect(rect);
	int y = -1;
	int height = -1;
	tv->get_line_yrange(i1, y, height);
	tb->place_cursor(tb->insert(i1, (*p)[2+start]));
	if (y < rect.get_y() + rect.get_height() + 16)
		 tv->scroll_to_mark(tb->get_insert(), 0);
	return 1;
}
コード例 #13
0
ParticlesChooser::ParticlesChooser() :
	gtkutil::BlockingTransientWindow(_("Choose particles"), GlobalMainFrame().getTopLevelWindow()),
	_particlesList(Gtk::ListStore::create(COLUMNS())),
	_selectedParticle(""),
	_preview(new gtkutil::ParticlePreview)
{
	set_border_width(12);

	// Set the default size of the window
	const Glib::RefPtr<Gtk::Window>& mainWindow = GlobalMainFrame().getTopLevelWindow();

	Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(mainWindow);
	int height = static_cast<int>(rect.get_height() * 0.6f);

	set_default_size(
		static_cast<int>(rect.get_width() * 0.4f), height
	);

	// Set the default size of the window
	_preview->setSize(rect.get_width() * 0.2f, height);

	// Main dialog vbox
	Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox(false, 12));

	// Create a horizontal box to pack the treeview on the left and the preview on the right
	Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox(false, 6));

	hbox->pack_start(createTreeView(), true, true, 0);

	Gtk::VBox* previewBox = Gtk::manage(new Gtk::VBox(false, 0));
	previewBox->pack_start(*_preview, true, true, 0);

	hbox->pack_start(*previewBox, true, true, 0);

	vbox->pack_start(*hbox, true, true, 0);
	vbox->pack_end(createButtons(), false, false, 0);

	// Add main vbox to dialog
	add(*vbox);
}
コード例 #14
0
// Constructor
SoundChooser::SoundChooser() :
	BlockingTransientWindow(_("Choose sound"), GlobalMainFrame().getTopLevelWindow()),
	_treeStore(Gtk::TreeStore::create(_columns)),
	_treeView(NULL),
	_preview(Gtk::manage(new SoundShaderPreview))
{
	set_border_width(12);
	set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);

	// Set the default size of the window
	Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalMainFrame().getTopLevelWindow());
	set_default_size(rect.get_width() / 2, rect.get_height() / 2);

	// Main vbox
	Gtk::VBox* vbx = Gtk::manage(new Gtk::VBox(false, 12));

    vbx->pack_start(createTreeView(), true, true, 0);
    vbx->pack_start(*_preview, false, false, 0);
    vbx->pack_start(createButtons(), false, false, 0);

    add(*vbx);
}
コード例 #15
0
	bool
	on_event(GdkEvent *event)
	{
		switch(event->type)
		{
		case GDK_SCROLL:
			if(mimic_tree_view)
			{
				if(event->scroll.direction==GDK_SCROLL_DOWN)
				{
					mimic_tree_view->get_vadjustment()->set_value(
						std::min(
							mimic_tree_view->get_vadjustment()->get_value()+
							mimic_tree_view->get_vadjustment()->get_step_increment(),
							mimic_tree_view->get_vadjustment()->get_upper()-
							mimic_tree_view->get_vadjustment()->get_page_size()
						)
					);
					mimic_tree_view->get_vadjustment()->value_changed();
				}
				else if(event->scroll.direction==GDK_SCROLL_UP)
				{
					mimic_tree_view->get_vadjustment()->set_value(
						std::max(
							mimic_tree_view->get_vadjustment()->get_value()-
							mimic_tree_view->get_vadjustment()->get_step_increment(),
							mimic_tree_view->get_vadjustment()->get_lower()
						)
					);
					mimic_tree_view->get_vadjustment()->value_changed();
				}
			}
			break;
		case GDK_BUTTON_PRESS:
			{
				Gtk::TreeModel::Path path;
				Gtk::TreeViewColumn *column;
				int cell_x, cell_y;
				if(!get_path_at_pos(
					int(event->button.x),int(event->button.y),	// x, y
					path, // TreeModel::Path&
					column, //TreeViewColumn*&
					cell_x,cell_y //int&cell_x,int&cell_y
					)
				) break;
				const Gtk::TreeRow row = *(get_model()->get_iter(path));

				if(column && column->get_first_cell_renderer()==cellrenderer_time_track)
				{
					Gdk::Rectangle rect;
					get_cell_area(path,*column,rect);
					cellrenderer_time_track->property_value_desc()=row[model.value_desc];
					cellrenderer_time_track->property_canvas()=row[model.canvas];
					cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
					queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
					return true;
					//return signal_param_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
				}
			}
			break;

		case GDK_MOTION_NOTIFY:
			{
				Gtk::TreeModel::Path path;
				Gtk::TreeViewColumn *column;
				int cell_x, cell_y;
				if(!get_path_at_pos(
					(int)event->motion.x,(int)event->motion.y,	// x, y
					path, // TreeModel::Path&
					column, //TreeViewColumn*&
					cell_x,cell_y //int&cell_x,int&cell_y
					)
				) break;

				if(!get_model()->get_iter(path))
					break;

				Gtk::TreeRow row = *(get_model()->get_iter(path));

				if ((event->motion.state&GDK_BUTTON1_MASK || event->motion.state&GDK_BUTTON3_MASK) &&
					column &&
					cellrenderer_time_track == column->get_first_cell_renderer())
				{
					Gdk::Rectangle rect;
					get_cell_area(path,*column,rect);
					cellrenderer_time_track->property_value_desc()=row[model.value_desc];
					cellrenderer_time_track->property_canvas()=row[model.canvas];
					cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
					queue_draw();
					//queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
					return true;
				}
/*				else
				if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
				{
					tooltips_.unset_tip(*this);
					Glib::ustring tooltips_string(row[layer_model.tooltip]);
					last_tooltip_path=path;
					if(!tooltips_string.empty())
					{
						tooltips_.set_tip(*this,tooltips_string);
						tooltips_.force_window();
					}
				}
*/
				return true;
			}
			break;
		case GDK_BUTTON_RELEASE:
			{
				Gtk::TreeModel::Path path;
				Gtk::TreeViewColumn *column;
				int cell_x, cell_y;
				if(!get_path_at_pos(
					(int)event->button.x,(int)event->button.y,	// x, y
					path, // TreeModel::Path&
					column, //TreeViewColumn*&
					cell_x,cell_y //int&cell_x,int&cell_y
					)
				) break;

				if(!get_model()->get_iter(path))
					break;

				Gtk::TreeRow row = *(get_model()->get_iter(path));

				if(column && cellrenderer_time_track==column->get_first_cell_renderer())
				{
					Gdk::Rectangle rect;
					get_cell_area(path,*column,rect);
					cellrenderer_time_track->property_value_desc()=row[model.value_desc];
					cellrenderer_time_track->property_canvas()=row[model.canvas];
					cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
					queue_draw();
					queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
					return true;
				}
			}
			break;
		default:
			break;
		}
		mimic_resync();
		return Gtk::TreeView::on_event(event);
	}
コード例 #16
0
ファイル: dependencies.hpp プロジェクト: MrBr3/Space-Deminer
inline bool operator==(const Gdk::Rectangle& a, const Gdk::Rectangle& b)
{
  return a.get_x()==b.get_x() && a.get_y()==b.get_y() && a.get_width()==b.get_width() && a.get_height()==b.get_height();
}
コード例 #17
0
ファイル: GazeTracker.cpp プロジェクト: alc1218/OpenGazer
void GazeTracker::calculateTrainingErrors() {
	int num_of_monitors = Gdk::Screen::get_default()->get_n_monitors();
	Gdk::Rectangle monitorgeometry;
	Glib::RefPtr<Gdk::Screen> screen = Gdk::Display::get_default()->get_default_screen();

	// Geometry of main monitor
	screen->get_monitor_geometry(num_of_monitors - 1, monitorgeometry);
	
	vector<Point> points = getsubvector(caltargets, &CalTarget::point);
	
	int j = 0;
	
	//cout << "Input count: " << input_count;
	//cout << ", Target size: " << caltargets.size() << endl;
	
	for(int i=0; i<caltargets.size(); i++) {
		double x_total = 0;
		double y_total = 0;
		double sample_count = 0;
		
		//cout << points[i].x << ", " << points[i].y << " x " << all_output_coords[j][0] << ", " << all_output_coords[j][1] << endl;
		
		while(j < input_count && points[i].x == all_output_coords[j][0] && points[i].y == all_output_coords[j][1]) {
			double x_estimate = (gpx->getmean(SharedImage(all_images[j], &ignore)) + gpx_left->getmean(SharedImage(all_images_left[j], &ignore))) / 2;
			double y_estimate = (gpy->getmean(SharedImage(all_images[j], &ignore)) + gpy_left->getmean(SharedImage(all_images_left[j], &ignore))) / 2;
			
			//cout << "i, j = (" << i << ", " << j << "), est: " << x_estimate << "("<< gpx->getmean(SharedImage(all_images[j], &ignore)) << ","<< gpx_left->getmean(SharedImage(all_images_left[j], &ignore)) << ")" << ", " << y_estimate << "("<< gpy->getmean(SharedImage(all_images[j], &ignore)) <<","<< gpy_left->getmean(SharedImage(all_images_left[j], &ignore)) << ")"<< endl;
			
			x_total += x_estimate;
			y_total += y_estimate;
			sample_count++;
			j++;
		}
		
		x_total /= sample_count;
		y_total /= sample_count;
	
		*output_file << "TARGET: (" << caltargets[i].point.x << "\t, " << caltargets[i].point.y << "\t),\tESTIMATE: ("<< x_total << "\t, " << y_total <<")" << endl;
		//cout << "TARGET: (" << caltargets[i].point.x << "\t, " << caltargets[i].point.y << "\t),\tESTIMATE: ("<< x_total << "\t, " << y_total <<"),\tDIFF: ("<< fabs(caltargets[i].point.x- x_total) << "\t, " << fabs(caltargets[i].point.y - y_total) <<")" << endl;
		
		// Calibration error removal
		xv[i][0] = x_total;		// Source
		xv[i][1] = y_total;
		
		// Targets
		fv_x[i] = caltargets[i].point.x;
		fv_y[i] = caltargets[i].point.y;
		sigv[i] = 0;
		
		int targetId = getTargetId(Point(x_total, y_total));
		
		if(targetId != i) {
			cout << "Target id is not the expected one!! (Expected: "<< i<< ", Current: "<< targetId << ")" << endl;
		}
		
	}
	
	// Add the corners of the monitor as 4 extra data points. This helps the correction for points that are near the edge of monitor
	xv[caltargets.size()][0] = monitorgeometry.get_x();
	xv[caltargets.size()][1] = monitorgeometry.get_y();
	fv_x[caltargets.size()] = monitorgeometry.get_x()-40;
	fv_y[caltargets.size()] = monitorgeometry.get_y()-40;
	
	xv[caltargets.size()+1][0] = monitorgeometry.get_x() + monitorgeometry.get_width();
	xv[caltargets.size()+1][1] = monitorgeometry.get_y();
	fv_x[caltargets.size()+1] = monitorgeometry.get_x() + monitorgeometry.get_width() + 40;
	fv_y[caltargets.size()+1] = monitorgeometry.get_y() - 40;
	
	xv[caltargets.size()+2][0] = monitorgeometry.get_x() + monitorgeometry.get_width();
	xv[caltargets.size()+2][1] = monitorgeometry.get_y() + monitorgeometry.get_height();
	fv_x[caltargets.size()+2] = monitorgeometry.get_x() + monitorgeometry.get_width() + 40;
	fv_y[caltargets.size()+2] = monitorgeometry.get_y() + monitorgeometry.get_height() + 40;
	
	xv[caltargets.size()+3][0] = monitorgeometry.get_x();
	xv[caltargets.size()+3][1] = monitorgeometry.get_y() + monitorgeometry.get_height();
	fv_x[caltargets.size()+3] = monitorgeometry.get_x() - 40;
	fv_y[caltargets.size()+3] = monitorgeometry.get_y() + monitorgeometry.get_height() + 40;
	
	int point_count = caltargets.size() + 4;
    int N = point_count;
    N = binomialInv(N, 2) - 1;
	
	// Find the best beta and gamma parameters for interpolation
    mirBetaGamma(1, 2, point_count, (double*)xv, fv_x, sigv, 0, NULL, NULL, NULL,
                 N, 2, 50.0, &beta_x, &gamma_x);
    mirBetaGamma(1, 2, point_count, (double*)xv, fv_y, sigv, 0, NULL, NULL, NULL,
                 N, 2, 50.0, &beta_y, &gamma_y);
	
	*output_file << endl << endl;
	cout << endl << endl;
	
	output_file->flush();
	
	
	cout << "ERROR CALCULATION FINISHED. BETA = " << beta_x << ", " << beta_y << ", GAMMA IS " << gamma_x << ", " << gamma_y << endl;
	for(int j=0; j<point_count; j++) {
			cout << xv[j][0] << ", " << xv[j][1] << endl;
	}
	

    //checkErrorCorrection();
}
コード例 #18
0
void OSGDrawingArea::invalidate ()
{
    Gdk::Rectangle lRect = get_allocation ();
    get_window ()->invalidate_rect (Gdk::Rectangle (0, 0, lRect.get_width (), lRect.get_height ()),
        false);
}
コード例 #19
0
void GazeTracker::calculateTrainingErrors() {
	int numMonitors = Gdk::Screen::get_default()->get_n_monitors();
	Gdk::Rectangle monitorGeometry;
	Glib::RefPtr<Gdk::Screen> screen = Gdk::Display::get_default()->get_default_screen();

	// Geometry of main monitor
	screen->get_monitor_geometry(numMonitors - 1, monitorGeometry);

	std::vector<Point> points = getSubVector(_calTargets, &CalTarget::point);

	//std::cout << "Input count: " << _inputCount;
	//std::cout << ", Target size: " << _calTargets.size() << std::endl;

	for (int i = 0; i < _calTargets.size(); i++) {
		double xTotal = 0;
		double yTotal = 0;
		double sampleCount = 0;

		//std::cout << points[i].x << ", " << points[i].y << " x " << allOutputCoords[j][0] << ", " << allOutputCoords[j][1] << std::endl;

		int j = 0;
		while (j < _inputCount && points[i].x == allOutputCoords[j][0] && points[i].y == allOutputCoords[j][1]) {
			double xEstimate = (_gaussianProcessX->getmean(Utils::SharedImage(allImages[j], &ignore)) + _gaussianProcessXLeft->getmean(Utils::SharedImage(allImagesLeft[j], &ignore))) / 2;
			double yEstimate = (_gaussianProcessY->getmean(Utils::SharedImage(allImages[j], &ignore)) + _gaussianProcessYLeft->getmean(Utils::SharedImage(allImagesLeft[j], &ignore))) / 2;

			//std::cout << "i, j = (" << i << ", " << j << "), est: " << xEstimate << "(" << _gaussianProcessX->getmean(SharedImage(allImages[j], &ignore)) << "," << _gaussianProcessXLeft->getmean(SharedImage(allImagesLeft[j], &ignore)) << ")" << ", " << yEstimate << "(" << _gaussianProcessY->getmean(SharedImage(allImages[j], &ignore)) << "," << _gaussianProcessYLeft->getmean(SharedImage(allImagesLeft[j], &ignore)) << ")" << std::endl;

			xTotal += xEstimate;
			yTotal += yEstimate;
			sampleCount++;
			j++;
		}

		xTotal /= sampleCount;
		yTotal /= sampleCount;

		*outputFile << "TARGET: (" << _calTargets[i].point.x << "\t, " << _calTargets[i].point.y << "\t),\tESTIMATE: (" << xTotal << "\t, " << yTotal << ")" << std::endl;
		//std::cout << "TARGET: (" << _calTargets[i].point.x << "\t, " << _calTargets[i].point.y << "\t),\tESTIMATE: (" << xTotal << "\t, " << yTotal << "),\tDIFF: (" << fabs(_calTargets[i].point.x- x_total) << "\t, " << fabs(_calTargets[i].point.y - y_total) << ")" << std::endl;

		// Calibration error removal
		_xv[i][0] = xTotal;		// Source
		_xv[i][1] = yTotal;

		// Targets
		_fvX[i] = _calTargets[i].point.x;
		_fvY[i] = _calTargets[i].point.y;
		_sigv[i] = 0;

		int targetId = getTargetId(Point(xTotal, yTotal));

		if (targetId != i) {
			std::cout << "Target id is not the expected one!! (Expected: "<< i << ", Current: " << targetId << ")" << std::endl;
		}
	}

	// Add the corners of the monitor as 4 extra data points. This helps the correction for points that are near the edge of monitor
	_xv[_calTargets.size()][0] = monitorGeometry.get_x();
	_xv[_calTargets.size()][1] = monitorGeometry.get_y();
	_fvX[_calTargets.size()] = monitorGeometry.get_x()-40;
	_fvY[_calTargets.size()] = monitorGeometry.get_y()-40;

	_xv[_calTargets.size()+1][0] = monitorGeometry.get_x() + monitorGeometry.get_width();
	_xv[_calTargets.size()+1][1] = monitorGeometry.get_y();
	_fvX[_calTargets.size()+1] = monitorGeometry.get_x() + monitorGeometry.get_width() + 40;
	_fvY[_calTargets.size()+1] = monitorGeometry.get_y() - 40;

	_xv[_calTargets.size()+2][0] = monitorGeometry.get_x() + monitorGeometry.get_width();
	_xv[_calTargets.size()+2][1] = monitorGeometry.get_y() + monitorGeometry.get_height();
	_fvX[_calTargets.size()+2] = monitorGeometry.get_x() + monitorGeometry.get_width() + 40;
	_fvY[_calTargets.size()+2] = monitorGeometry.get_y() + monitorGeometry.get_height() + 40;

	_xv[_calTargets.size()+3][0] = monitorGeometry.get_x();
	_xv[_calTargets.size()+3][1] = monitorGeometry.get_y() + monitorGeometry.get_height();
	_fvX[_calTargets.size()+3] = monitorGeometry.get_x() - 40;
	_fvY[_calTargets.size()+3] = monitorGeometry.get_y() + monitorGeometry.get_height() + 40;

	int pointCount = _calTargets.size() + 4;
	int N = pointCount;
	N = binomialInv(N, 2) - 1;

	// Find the best beta and gamma parameters for interpolation
	mirBetaGamma(1, 2, pointCount, (double *)_xv, _fvX, _sigv, 0, NULL, NULL, NULL, N, 2, 50.0, &_betaX, &_gammaX);
	mirBetaGamma(1, 2, pointCount, (double *)_xv, _fvY, _sigv, 0, NULL, NULL, NULL, N, 2, 50.0, &_betaY, &_gammaY);

	*outputFile << std::endl << std::endl;
	std::cout << std::endl << std::endl;

	outputFile->flush();

	std::cout << "ERROR CALCULATION FINISHED. BETA = " << _betaX << ", " << _betaY << ", GAMMA IS " << _gammaX << ", " << _gammaY << std::endl;
	for (int i = 0; i < pointCount; i++) {
		std::cout << _xv[i][0] << ", " << _xv[i][1] << std::endl;
	}

	//checkErrorCorrection();
}
コード例 #20
0
void
CellRenderer_TimeTrack::render_vfunc(
	const ::Cairo::RefPtr< ::Cairo::Context>& cr,
	Gtk::Widget& /* widget */,
	const Gdk::Rectangle& /* background_area */,
	const Gdk::Rectangle& cell_area,
	Gtk::CellRendererState /* flags */)
{
	if(!cr)
		return;

	Glib::RefPtr<Gtk::Adjustment> adjustment=get_adjustment();
	// Gtk::StateType state = Gtk::STATE_ACTIVE;
	// Gtk::ShadowType shadow;

	Gdk::Color
		curr_time_color("#0000ff"),
		inactive_color("#000000"),
		keyframe_color("#a07f7f");
	Gdk::Color activepoint_color[2];

	activepoint_color[0]=Gdk::Color("#ff0000");
	activepoint_color[1]=Gdk::Color("#00ff00");

	int stride = Cairo::ImageSurface::format_stride_for_width(Cairo::FORMAT_A1, 2);
	std::vector<unsigned char> stipple_xpm(2*stride, 0);
	stipple_xpm[0] = 2;
	Cairo::RefPtr<Cairo::ImageSurface> inactive_mask_img = Cairo::ImageSurface::create(&stipple_xpm.front(), Cairo::FORMAT_A1, 2, 2, stride);

	synfig::Canvas::Handle canvas(property_canvas().get_value());

	synfigapp::ValueDesc value_desc = property_value_desc().get_value();
	synfig::ValueNode *base_value = value_desc.get_value_node().get();
	// synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(base_value);

	synfig::ValueNode_DynamicList *parent_value_node(0);
	if(property_value_desc().get_value().parent_is_value_node())
		parent_value_node=dynamic_cast<synfig::ValueNode_DynamicList*>(property_value_desc().get_value().get_parent_value_node().get());

	// If the canvas is defined, then load up the keyframes
	if(canvas)
	{
		const synfig::KeyframeList& keyframe_list(canvas->keyframe_list());
		synfig::KeyframeList::const_iterator iter;

		for(iter=keyframe_list.begin();iter!=keyframe_list.end();++iter)
		{
			if(!iter->get_time().is_valid())
				continue;

			const int x((int)((float)cell_area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->get_time()-adjustment->get_lower())));
			if(iter->get_time()>=adjustment->get_lower() && iter->get_time()<adjustment->get_upper())
			{
				cr->set_source_rgb(keyframe_color.get_red_p(), keyframe_color.get_green_p(), keyframe_color.get_blue_p());
				cr->rectangle(cell_area.get_x()+x, cell_area.get_y(), 1, cell_area.get_height()+1);
				cr->fill();
			}
		}
	}

	//render all the time points that exist
	{
		const synfig::Node::time_set *tset = get_times_from_vdesc(value_desc);

		if(tset)
		{
			const synfig::Time time_offset = get_time_offset_from_vdesc(value_desc);
			synfig::Node::time_set::const_iterator	i = tset->begin(), end = tset->end();

			float 	lower = adjustment->get_lower(),
					upper = adjustment->get_upper();

			Gdk::Rectangle area(cell_area);

			bool valselected = sel_value.get_value_node() == base_value && !sel_times.empty();

			float cfps = get_canvas()->rend_desc().get_frame_rate();

			vector<Time>	drawredafter;

			Time diff = actual_time - actual_dragtime;//selected_time-drag_time;
			for(; i != end; ++i)
			{
				//find the coordinate in the drawable space...
				Time t_orig = i->get_time();
				if(!t_orig.is_valid()) continue;
				Time t = t_orig - time_offset;
				if(t<adjustment->get_lower() || t>adjustment->get_upper()) continue;

				//if it found it... (might want to change comparison, and optimize
				//					 sel_times.find to not produce an overall nlogn solution)

				bool selected=false;
				//not dragging... just draw as per normal
				//if move dragging draw offset
				//if copy dragging draw both...

				if(valselected && sel_times.find(t_orig) != sel_times.end())
				{
					if(dragging) //skip if we're dragging because we'll render it later
					{
						if(mode & COPY_MASK) // draw both blue and red moved
						{
							drawredafter.push_back(t + diff.round(cfps));
						}else if(mode & DELETE_MASK) //it's just red...
						{
							selected=true;
						}else //move - draw the red on top of the others...
						{
							drawredafter.push_back(t + diff.round(cfps));
							continue;
						}
					}else
					{
						selected=true;
					}
				}

				//synfig::info("Displaying time: %.3f s",(float)t);
				const int x = (int)((t-lower)*area.get_width()/(upper-lower));

				//should draw me a grey filled circle...
				Gdk::Rectangle area2(
					area.get_x() - area.get_height()/2 + x + 1,
					area.get_y() + 1,
					area.get_height()-2,
					area.get_height()-2
				);
				render_time_point_to_window(cr,area2,*i - time_offset,selected);
			}

			{
				vector<Time>::iterator i = drawredafter.begin(), end = drawredafter.end();
				for(; i != end; ++i)
				{
					//find the coordinate in the drawable space...
					Time t = *i;

					if(!t.is_valid())
						continue;

					//synfig::info("Displaying time: %.3f s",(float)t);
					const int x = (int)((t-lower)*area.get_width()/(upper-lower));

					//should draw me a grey filled circle...

					Gdk::Rectangle area2(
						area.get_x() - area.get_height()/2 + x + 1,
						area.get_y() + 1,
						area.get_height()-2,
						area.get_height()-2
					);
					render_time_point_to_window(cr,area2,*i,true);
				}
			}
		}
	}

	Gdk::Rectangle area(cell_area);
	// If the parent of this value node is a dynamic list, then
	// render the on and off times
	if(parent_value_node)
	{
		const int index(property_value_desc().get_value().get_index());
		const synfig::ValueNode_DynamicList::ListEntry& list_entry(parent_value_node->list[index]);
		const synfig::ValueNode_DynamicList::ListEntry::ActivepointList& activepoint_list(list_entry.timing_info);
		synfig::ValueNode_DynamicList::ListEntry::ActivepointList::const_iterator iter,next;

		bool is_off(false);
		if(!activepoint_list.empty())
			is_off=!activepoint_list.front().state;

		int xstart(0);

		int x=0 /*,prevx=0*/;
		for(next=activepoint_list.begin(),iter=next++;iter!=activepoint_list.end();iter=next++)
		{
			x=((int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->time-adjustment->get_lower())));
			if(x<0)x=0;
			if(x>area.get_width())x=area.get_width();

			bool status_at_time=0;
			if(next!=activepoint_list.end())
			{
				status_at_time=!list_entry.status_at_time((iter->time+next->time)/2.0);
			}
			else
				status_at_time=!list_entry.status_at_time(Time::end());

			if(!is_off && status_at_time)
			{
				xstart=x;
				is_off=true;
			}
			else
			if(is_off && !status_at_time)
			{
				cr->set_source_rgb( inactive_color.get_red_p(),
									inactive_color.get_green_p(),
									inactive_color.get_red_p() );
				cr->mask(inactive_mask_img, 0, 0);
				cr->rectangle(area.get_x()+xstart, area.get_y(), x-xstart, area.get_height());
				cr->fill();
				is_off=false;
			}

			if(iter->time>=adjustment->get_lower() && iter->time<adjustment->get_upper())
			{
				int w(1);
				if(selected==*iter)
					w=3;
				cr->set_source_rgb( activepoint_color[iter->state].get_red_p(),
									activepoint_color[iter->state].get_green_p(),
									activepoint_color[iter->state].get_red_p() );
				cr->rectangle(area.get_x()+x-w/2, area.get_y(), w, area.get_height());
				cr->fill();
			}
			//prevx=x;
		}
		if(is_off)
		{
			cr->set_source_rgb( inactive_color.get_red_p(),
								inactive_color.get_green_p(),
								inactive_color.get_red_p() );
			cr->mask(inactive_mask_img, 0, 0);
			cr->rectangle(area.get_x()+xstart, area.get_y(), area.get_width()-xstart, area.get_height());
			cr->fill();
		}
	}

	// Render a line that defines the current tick in time
	{
		const int x((int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(adjustment->get_value()-adjustment->get_lower())));
		if(adjustment->get_value()>=adjustment->get_lower() && adjustment->get_value()<adjustment->get_upper())
		{
			cr->set_source_rgb( curr_time_color.get_red_p(),
								curr_time_color.get_green_p(),
								curr_time_color.get_red_p() );
			cr->rectangle(area.get_x()+x, area.get_y(), 1, area.get_height());
			cr->fill();
		}
	}
}
コード例 #21
0
void
CellRenderer_ValueBase::render_vfunc(
		const Glib::RefPtr<Gdk::Drawable>& window,
		Gtk::Widget& widget,
		const Gdk::Rectangle& background_area,
		const Gdk::Rectangle& ca,
		const Gdk::Rectangle& expose_area,
		Gtk::CellRendererState flags)
{
	if(!window)
		return;
//	const unsigned int cell_xpad = property_xpad();
//	const unsigned int cell_ypad = property_ypad();

	//int x_offset = 0, y_offset = 0;
//	int	width = ca.get_width();
	int	height = ca.get_height();
//	get_size(widget, ca, x_offset, y_offset, width, height);

//	width  -= cell_xpad * 2;
//	height -= cell_ypad * 2;

//	if(width <= 0 || height <= 0)
//		return;

	Gtk::StateType state = Gtk::STATE_INSENSITIVE;
	if(property_editable())
		state = Gtk::STATE_NORMAL;
	if((flags & Gtk::CELL_RENDERER_SELECTED) != 0)
		state = (widget.has_focus()) ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE;

	ValueBase data=property_value_.get_value();

	Type &type(data.get_type());
	if (type == type_real)
	{
		if(((synfig::ParamDesc)property_param_desc_).get_is_distance())
		{
			Distance x(data.get(Real()),Distance::SYSTEM_UNITS);
			x.convert(App::distance_system,get_canvas()->rend_desc());
			property_text()=(Glib::ustring)x.get_string(6).c_str();
		}
		else
			property_text()=(Glib::ustring)strprintf("%.6f",data.get(Real()));
	}
	else
	if (type == type_time)
	{
		property_text()=(Glib::ustring)data.get(Time()).get_string(get_canvas()->rend_desc().get_frame_rate(),App::get_time_format());
	}
	else
	if (type == type_angle)
	{
		property_text()=(Glib::ustring)strprintf("%.2fᵒ",(Real)Angle::deg(data.get(Angle())).get());
	}
	else
	if (type == type_integer)
	{
		String param_hint, child_param_hint;
		param_hint=get_param_desc().get_hint();
		child_param_hint=get_child_param_desc().get_hint();
		if(param_hint!="enum" && child_param_hint!="enum")
		{
			property_text()=(Glib::ustring)strprintf("%i",data.get(int()));
		}
		else
		{
			property_text()=(Glib::ustring)strprintf("(%i)",data.get(int()));
			std::list<synfig::ParamDesc::EnumData> enum_list;
			if(param_hint=="enum")
				enum_list=((synfig::ParamDesc)property_param_desc_).get_enum_list();
			else if(child_param_hint=="enum")
				enum_list=((synfig::ParamDesc)property_child_param_desc_).get_enum_list();
			std::list<synfig::ParamDesc::EnumData>::iterator iter;
			for(iter=enum_list.begin();iter!=enum_list.end();iter++)
				if(iter->value==data.get(int()))
				{
					// don't show the key_board s_hortcut under_scores
					String local_name = iter->local_name;
					String::size_type pos = local_name.find_first_of('_');
					if (pos != String::npos)
						property_text() = local_name.substr(0,pos) + local_name.substr(pos+1);
					else
						property_text() = local_name;
					break;
				}
		}
	}
	else
	if (type == type_vector)
	{
		Vector vector=data.get(Vector());
		Distance x(vector[0],Distance::SYSTEM_UNITS),y(vector[1],Distance::SYSTEM_UNITS);
		x.convert(App::distance_system,get_canvas()->rend_desc());
		y.convert(App::distance_system,get_canvas()->rend_desc());
		property_text()=static_cast<Glib::ustring>(strprintf("%s,%s",x.get_string(6).c_str(),y.get_string(6).c_str()));
	}
	else
	if (type == type_transformation)
	{
		const Transformation &transformation=data.get(Transformation());
		const Vector &offset = transformation.offset;
		const Angle::deg angle(transformation.angle);
		const Vector &scale = transformation.scale;
		Distance x(offset[0],Distance::SYSTEM_UNITS),y(offset[1],Distance::SYSTEM_UNITS);
		x.convert(App::distance_system,get_canvas()->rend_desc());
		y.convert(App::distance_system,get_canvas()->rend_desc());
		Distance sx(scale[0],Distance::SYSTEM_UNITS),sy(scale[1],Distance::SYSTEM_UNITS);
		sx.convert(App::distance_system,get_canvas()->rend_desc());
		sy.convert(App::distance_system,get_canvas()->rend_desc());
		property_text()=static_cast<Glib::ustring>(strprintf(
			"%s,%s,%.2fᵒ,%s,%s",
			x.get_string(6).c_str(), y.get_string(6).c_str(),
			(Real)angle.get(),
			sx.get_string(6).c_str(), sy.get_string(6).c_str()
		));
	}
	else
	if (type == type_string)
	{
		if(data.get_type()==type_string)
		{
			if(!data.get(synfig::String()).empty())
				property_text()=static_cast<Glib::ustring>(data.get(synfig::String()));
			else
				property_text()=Glib::ustring("<empty>");
		}
	}
	else
	if (type == type_canvas)
	{
		if(data.get(etl::handle<synfig::Canvas>()))
		{
			if(data.get(etl::handle<synfig::Canvas>())->is_inline())
				property_text()=_("<Group>");
			else
				property_text()=(Glib::ustring)data.get(etl::handle<synfig::Canvas>())->get_id();
		}
		else
			property_text()=_("<No Image Selected>");
	}
	else
	if (type == type_color)
	{
		render_color_to_window(window,ca,data.get(Color()));
		return;
	}
	else
	if (type == type_bool)
	{
		widget.get_style()->paint_check(
			Glib::RefPtr<Gdk::Window>::cast_static(window), state,
			data.get(bool())?Gtk::SHADOW_IN:Gtk::SHADOW_OUT,
			ca, widget, "cellcheck",
			ca.get_x()/* + x_offset + cell_xpad*/,
			ca.get_y()/* + y_offset + cell_ypad*/,
			height-1,height-1);
		return;
	}
	else
	if (type == type_nil)
	{
		//property_text()=(Glib::ustring)" ";
		return;
	}
	else
	if (type == type_gradient)
	{
		render_gradient_to_window(window,ca,data.get(Gradient()));
		return;
	}
	else
	if (type == type_bone_object
	 || type == type_segment
	 || type == type_list
	 || type == type_bline_point
	 || type == type_width_point
	 || type == type_dash_item)
	{
		property_text()=(Glib::ustring)(data.get_type().description.local_name);
	}
	else
	if (type == type_bone_valuenode)
	{
		ValueNode_Bone::Handle bone_node(data.get(ValueNode_Bone::Handle()));
		String name(_("No Parent"));

		if (!bone_node->is_root())
		{
			name = (*(bone_node->get_link("name")))(get_canvas()->get_time()).get(String());
			if (name.empty())
				name = bone_node->get_guid().get_string();
		}

		property_text()=(Glib::ustring)(name);
	}
	else
	{
		property_text()=static_cast<Glib::ustring>(type.description.local_name);
	}

	CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags);
}
コード例 #22
0
GazeTrackerGtk::GazeTrackerGtk(int argc, char **argv):
	_picture(argc, argv),
	_vbox(false, 0),
	_buttonBar(true, 0),
	_calibrateButton("Calibrate"),
	_loadButton("Load points"),
	_saveButton("Save points"),
	_chooseButton("Choose points"),
	_pauseButton("Pause"),
	_clearButton("Clear points"),
	_testButton("Test")
{
	try {
		set_title("opengazer 0.1.1");

		Glib::RefPtr<Gdk::Screen> screen = Gdk::Display::get_default()->get_default_screen();
		Gdk::Rectangle rect;
		screen->get_monitor_geometry(Gdk::Screen::get_default()->get_n_monitors() - 1, rect);

		set_size_request(rect.get_width(), rect.get_height());
		move(0, 0);

		// Construct view
		add(_vbox);

		_vbox.pack_start(_buttonBar, false, true, 0);
		_vbox.pack_start(_picture);

		_buttonBar.pack_start(_chooseButton);
		_buttonBar.pack_start(_clearButton);
		_buttonBar.pack_start(_calibrateButton);
		_buttonBar.pack_start(_testButton);
		_buttonBar.pack_start(_pauseButton);
		_buttonBar.pack_start(_saveButton);
		_buttonBar.pack_start(_loadButton);

		// Connect buttons
		_calibrateButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::startCalibration));
		_testButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::startTesting));
		_saveButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::savePoints));
		_loadButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::loadPoints));
		_chooseButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::choosePoints));
		_pauseButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::pauseOrRepositionHead));
		_pauseButton.signal_clicked().connect(sigc::mem_fun(this, &GazeTrackerGtk::changePauseButtonText));
		_clearButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::clearPoints));

		// Display view
		_vbox.show();
		_buttonBar.show();
		_picture.show();
		_calibrateButton.show();
		//_saveButton.show();
		//_loadButton.show();
		_chooseButton.show();
		_pauseButton.show();
		_clearButton.show();
		_testButton.show();
	}
	catch (Utils::QuitNow) {
		std::cout << "Caught it!\n";
	}
}
コード例 #23
0
void ActivityDrawingArea::invalidateWindow() {
	Gdk::Rectangle lRect = this->get_allocation();
	this->get_window()->invalidate_rect(Gdk::Rectangle(0, 0, lRect.get_width(), lRect.get_height()), false);
}
コード例 #24
0
ファイル: Element.cpp プロジェクト: hiasmstudio/hiasm5
void LinkHint::draw(DrawContext dc) {
	if(!textLayout) {
		textLayout = Pango::Layout::create(dc);
		textLayout->set_text(text);
		textLayout->set_wrap(Pango::WRAP_WORD);
		//textLayout->set_ellipsize(Pango::ELLIPSIZE_END);
		Pango::FontDescription f("arial 8");
		textLayout->set_font_description(f);
		textLayout->set_indent(10);
		textLayout->set_alignment(Pango::ALIGN_LEFT);
		textLayout->set_width(width*Pango::SCALE);
		textLayout->set_height(-1);
		textLayout->get_pixel_size(width, height);
	}

	Gdk::Rectangle r = drawRect();

	Gdk::Cairo::set_source_rgba(dc, darkColor);
	int px = parent->x + parent->width / 2;
	int py = parent->y + parent->height / 2;
	int mx = parent->x + x + width / 2;
	int my = parent->y + y + height / 2;

	dc->set_dash(dash, 1);
	dc->move_to(px, py);
	if(!(x + width < 0 || x > parent->width))
		dc->line_to((px + mx) / 2, my);
	else if(x < 0)
		dc->line_to((px + parent->x + x + width) / 2, my);
	else
		dc->line_to((px + parent->x + x) / 2, my);
	dc->line_to(mx, my);
	dc->stroke();
	dc->unset_dash();

	//Cairo::Antialias old_a = dc->get_antialias();
	//if(old_a == Cairo::ANTIALIAS_NONE)
	//	dc->set_antialias(Cairo::ANTIALIAS_DEFAULT);

	Gdk::Cairo::set_source_rgba(dc, sysColors.btnLight);
	dc->rectangle(r.get_x(), r.get_y(), r.get_width(), r.get_height());
	//roundRect(dc, r.get_x(), r.get_y(), r.get_width(), r.get_height());
	dc->fill();

	Gdk::Cairo::set_source_rgba(dc, sysColors.btnDark);
	dc->rectangle(r.get_x(), r.get_y(), r.get_width(), r.get_height());
	//roundRect(dc, r.get_x(), r.get_y(), r.get_width(), r.get_height());
	dc->stroke();

	//dc->set_antialias(old_a);

	//Gdk::Cairo::set_source_color(dc, darkColor);
	//dc->rectangle(r.get_x(), r.get_y(), r.get_width() - 1, r.get_height() - 1);
	//roundRect(dc, r.get_x(), r.get_y(), r.get_width(), r.get_height());
	//dc->stroke();

	//dc->set_font_size(11);
	//dc->select_font_face("arial", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL);
	//dc->move_to(r.get_x() + 4, r.get_y() + 12);
	//dc->show_text(text);

	//dc->rectangle(r.get_x(), r.get_y(), r.get_width(), r.get_height());
	//dc->clip();

	dc->set_source_rgb(0, 0, 0);
	dc->move_to(r.get_x() + 3, r.get_y() + 3);
	textLayout->show_in_cairo_context(dc);

	//dc->reset_clip();
}
コード例 #25
0
ファイル: Element.cpp プロジェクト: hiasmstudio/hiasm5
bool LinkHints::getObjectAtPos(gdouble x, gdouble y, ObjectType *obj) {
	for(iterator h = begin(); h != end(); h++) {
		Gdk::Rectangle r = (*h)->drawRect();
		if(x >= r.get_x() && y >= r.get_y() && x <= r.get_x() + r.get_width() && y <= r.get_y() + r.get_height()) {
			*obj = ObjectType(*h);
			return true;
		}
	}
	return false;
}
コード例 #26
0
void
CellRenderer_ValueBase::render_vfunc(
		const Glib::RefPtr<Gdk::Drawable>& window,
		Gtk::Widget& widget,
		const Gdk::Rectangle& background_area,
		const Gdk::Rectangle& ca,
		const Gdk::Rectangle& expose_area,
		Gtk::CellRendererState flags)
{
	if(!window)
		return;
//	const unsigned int cell_xpad = property_xpad();
//	const unsigned int cell_ypad = property_ypad();

	//int x_offset = 0, y_offset = 0;
//	int	width = ca.get_width();
	int	height = ca.get_height();
//	get_size(widget, ca, x_offset, y_offset, width, height);

//	width  -= cell_xpad * 2;
//	height -= cell_ypad * 2;

//	if(width <= 0 || height <= 0)
//		return;

	Gtk::StateType state = Gtk::STATE_INSENSITIVE;
	if(property_editable())
		state = Gtk::STATE_NORMAL;
	if((flags & Gtk::CELL_RENDERER_SELECTED) != 0)
		state = (widget.has_focus()) ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE;

	ValueBase data=property_value_.get_value();

	switch(data.get_type())
	{
	case ValueBase::TYPE_REAL:
		if(((synfig::ParamDesc)property_param_desc_).get_is_distance())
		{
			Distance x(data.get(Real()),Distance::SYSTEM_UNITS);
			x.convert(App::distance_system,get_canvas()->rend_desc());
			property_text()=(Glib::ustring)x.get_string(6).c_str();
		}
		else
			property_text()=(Glib::ustring)strprintf("%.6f",data.get(Real()));
		break;
	case ValueBase::TYPE_TIME:
		property_text()=(Glib::ustring)data.get(Time()).get_string(get_canvas()->rend_desc().get_frame_rate(),App::get_time_format());
		break;
	case ValueBase::TYPE_ANGLE:
		property_text()=(Glib::ustring)strprintf("%.2fᵒ",(Real)Angle::deg(data.get(Angle())).get());
		break;
	case ValueBase::TYPE_INTEGER:
		{
			String param_hint, child_param_hint;
			param_hint=get_param_desc().get_hint();
			child_param_hint=get_child_param_desc().get_hint();
			if(param_hint!="enum" && child_param_hint!="enum")
			{
				property_text()=(Glib::ustring)strprintf("%i",data.get(int()));
			}
			else
			{
				property_text()=(Glib::ustring)strprintf("(%i)",data.get(int()));
				std::list<synfig::ParamDesc::EnumData> enum_list;
				if(param_hint=="enum")
					enum_list=((synfig::ParamDesc)property_param_desc_).get_enum_list();
				else if(child_param_hint=="enum")
					enum_list=((synfig::ParamDesc)property_child_param_desc_).get_enum_list();
				std::list<synfig::ParamDesc::EnumData>::iterator iter;
				for(iter=enum_list.begin();iter!=enum_list.end();iter++)
					if(iter->value==data.get(int()))
					{
						// don't show the key_board s_hortcut under_scores
						String local_name = iter->local_name;
						String::size_type pos = local_name.find_first_of('_');
						if (pos != String::npos)
							property_text() = local_name.substr(0,pos) + local_name.substr(pos+1);
						else
							property_text() = local_name;
						break;
					}
			}
		}
		break;

	case ValueBase::TYPE_VECTOR:
		{
			Vector vector=data.get(Vector());
			Distance x(vector[0],Distance::SYSTEM_UNITS),y(vector[1],Distance::SYSTEM_UNITS);
			x.convert(App::distance_system,get_canvas()->rend_desc());
			y.convert(App::distance_system,get_canvas()->rend_desc());
			property_text()=static_cast<Glib::ustring>(strprintf("%s,%s",x.get_string(6).c_str(),y.get_string(6).c_str()));
		}
		break;

	case ValueBase::TYPE_STRING:

		if(data.get_type()==ValueBase::TYPE_STRING)
		{
			if(!data.get(synfig::String()).empty())
				property_text()=static_cast<Glib::ustring>(data.get(synfig::String()));
			else
				property_text()=Glib::ustring("<empty>");
		}
		break;
	case ValueBase::TYPE_CANVAS:
		if(data.get(etl::handle<synfig::Canvas>()))
		{
			if(data.get(etl::handle<synfig::Canvas>())->is_inline())
				property_text()=_("<Group>");
			else
				property_text()=(Glib::ustring)data.get(etl::handle<synfig::Canvas>())->get_id();
		}
		else
			property_text()=_("<No Image Selected>");
		break;
	case ValueBase::TYPE_COLOR:
		{
			render_color_to_window(window,ca,data.get(Color()));
			return;
		}
		break;
	case ValueBase::TYPE_BOOL:
		{
			widget.get_style()->paint_check(
				Glib::RefPtr<Gdk::Window>::cast_static(window), state,
				data.get(bool())?Gtk::SHADOW_IN:Gtk::SHADOW_OUT,
				ca, widget, "cellcheck",
				ca.get_x()/* + x_offset + cell_xpad*/,
				ca.get_y()/* + y_offset + cell_ypad*/,
				height-1,height-1);
			return;
		}
		break;
	case ValueBase::TYPE_NIL:
		//property_text()=(Glib::ustring)" ";
		return;
		break;
	case ValueBase::TYPE_GRADIENT:
		render_gradient_to_window(window,ca,data.get(Gradient()));
		return;
		break;
	case ValueBase::TYPE_BONE:
	case ValueBase::TYPE_SEGMENT:
	case ValueBase::TYPE_LIST:
	case ValueBase::TYPE_BLINEPOINT:
	case ValueBase::TYPE_WIDTHPOINT:
	case ValueBase::TYPE_DASHITEM:
		property_text()=(Glib::ustring)(ValueBase::type_local_name(data.get_type()));
		break;
	case ValueBase::TYPE_VALUENODE_BONE:
	{
		ValueNode_Bone::Handle bone_node(data.get(ValueNode_Bone::Handle()));
		String name(_("No Parent"));

		if (!bone_node->is_root())
		{
			name = (*(bone_node->get_link("name")))(get_canvas()->get_time()).get(String());
			if (name.empty())
				name = bone_node->get_guid().get_string();
		}

		property_text()=(Glib::ustring)(name);
		break;
	}
	default:
		property_text()=static_cast<Glib::ustring>(_("UNKNOWN"));
		break;
	}
	CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags);
}
コード例 #27
0
ファイル: widget_color.cpp プロジェクト: blackwarthog/synfig
void
studio::render_color_to_window(const Cairo::RefPtr<Cairo::Context> &cr, const Gdk::Rectangle &ca, const synfig::Color &color)
{
	const int height(ca.get_height());
	const int width(ca.get_width());

	const int square_size(height/2);

	if(color.get_alpha()!=1.0)
	{
		// In this case we need to render the alpha squares

		const Color bg1(
			colorconv_apply_gamma(
				Color::blend(color,Color(0.75, 0.75, 0.75),1.0).clamped() ));
		const Color bg2(
			colorconv_apply_gamma(
				Color::blend(color,Color(0.5, 0.5, 0.5),1.0).clamped() ));

		bool toggle(false);
		for(int i=0;i<width;i+=square_size)
		{
			const int square_width(min(square_size,width-i));

			if(toggle)
			{
		        cr->set_source_rgb(bg1.get_r(), bg1.get_g(), bg1.get_b());
		        cr->rectangle(ca.get_x()+i, ca.get_y(), square_width, square_size);
		        cr->fill();

		        cr->set_source_rgb(bg2.get_r(), bg2.get_g(), bg2.get_b());
		        cr->rectangle(ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
		        cr->fill();
				toggle=false;
			}
			else
			{
		        cr->set_source_rgb(bg2.get_r(), bg2.get_g(), bg2.get_b());
		        cr->rectangle(ca.get_x()+i, ca.get_y(), square_width, square_size);
		        cr->fill();

		        cr->set_source_rgb(bg1.get_r(), bg1.get_g(), bg1.get_b());
		        cr->rectangle(ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
		        cr->fill();
				toggle=true;
			}
		}
	}
	else
	{
		synfig::Color c = colorconv_apply_gamma(color);
        cr->set_source_rgb(c.get_r(), c.get_g(), c.get_b());
        cr->rectangle(ca.get_x(), ca.get_y(), width-1, height-1);
        cr->fill();
	}

	cr->set_source_rgb(1.0, 1.0, 1.0);
    cr->rectangle(ca.get_x()+1, ca.get_y()+1, width-3, height-3);
    cr->stroke();

    cr->set_source_rgb(0.0, 0.0, 0.0);
    cr->rectangle(ca.get_x(), ca.get_y(), width-1, height-1);
    cr->stroke();
}
コード例 #28
0
bool
CellRenderer_TimeTrack::activate_vfunc(
	GdkEvent* event,
	Gtk::Widget& /*widget*/,
	const Glib::ustring& treepath,
	const Gdk::Rectangle& /*background_area*/,
	const Gdk::Rectangle& cell_area,
	Gtk::CellRendererState /*flags*/)
{
	if (!event)
	{
		// Catch a null event received us a result of a keypress (only?)
		return true; //On tab key press, Focus go to next panel. If return false, focus goes to canvas
	}

	path=treepath;
	synfig::ValueNode_Animated::WaypointList::iterator iter;
	Glib::RefPtr<Gtk::Adjustment> adjustment=get_adjustment();

	// synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(property_value_desc().get_value().get_value_node().get());

	synfig::Canvas::Handle canvas(get_canvas());

	Time deltatime = 0;
	Time curr_time;
	switch(event->type)
	{
	case GDK_MOTION_NOTIFY:
		curr_time=((float)event->motion.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();

		mode = NONE;
		{
			Gdk::ModifierType mod;
			Gdk::Event(event).get_state(mod);
			mode = mod;
		}
		break;
	case GDK_BUTTON_PRESS:
	case GDK_BUTTON_RELEASE:
	default:
		curr_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
		{
			Gdk::ModifierType mod;
			Gdk::Event(event).get_state(mod);
			mode = mod;
		}
		break;
	}
	actual_time = curr_time;
	if(canvas)
		curr_time=curr_time.round(canvas->rend_desc().get_frame_rate());
	selected_time=curr_time;

    Time pixel_width((adjustment->get_upper()-adjustment->get_lower())/cell_area.get_width());

    switch(event->type)
    {
	case GDK_BUTTON_PRESS:
		//selected_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();

		//Deal with time point selection, but only if they aren't involved in the insanity...
		if(/*!value_node && */event->button.button == 1)
		{
			Time stime;

			/*!	UI specification:

				When nothing is selected, clicking on a point in either normal mode or
					additive mode will select the time point closest to the click.
					Subtractive click will do nothing

				When things are already selected, clicking on a selected point does
					nothing (in both normal and add mode).  Add mode clicking on an unselected
					point adds it to the set.  Normal clicking on an unselected point will
					select only that one time point.  Subtractive clicking on any point
					will remove it from the the set if it is included.
			*/

			synfigapp::ValueDesc valdesc = property_value_desc().get_value();
			const Node::time_set *tset = get_times_from_vdesc(valdesc);
			const synfig::Time time_offset = get_time_offset_from_vdesc(valdesc);

			bool clickfound = tset && get_closest_time(*tset,actual_time+time_offset,pixel_width*cell_area.get_height(),stime);
			bool selectmode = mode & SELECT_MASK;

			//NOTE LATER ON WE SHOULD MAKE IT SO MULTIPLE VALUENODES CAN BE SELECTED AT ONCE
			//we want to jump to the value desc if we're not currently on it
			//	but only if we want to add the point
			if(clickfound && !(sel_value == valdesc))
			{
				sel_value = valdesc;
				sel_times.clear();
			}

			//now that we've made sure we're selecting the correct value, deal with the already selected points
			set<Time>::iterator foundi = clickfound ? sel_times.find(stime) : sel_times.end();
			bool found = foundi != sel_times.end();

			//remove all other points from our list... (only select the one we need)
			if(!selectmode && !found)
			{
				sel_times.clear();
			}

			if(found && selectmode) //remove a single already selected point
			{
				sel_times.erase(foundi);
			}else if(clickfound) //otherwise look at adding it
			{
				//for replace the list was cleared earlier, and for add it wasn't so it works
				sel_times.insert(stime);
			}
		}

		selection=false;
		try
		{
			iter=find_editable_waypoint(selected_time,pixel_width*cell_area.get_height()/2);
			selected_waypoint=iter;
			selected=*iter;

			selection=true;
		}
		catch(int)
		{
			selection=false;
			selected=synfig::UniqueID::nil();
		}

		if((!sel_times.empty() || selection) && event->button.button==1)
		{
			dragging=true;
			drag_time=selected_time;
			actual_dragtime=actual_time;
		}
		//selected_time=iter->time;

		/*
		// Activepoint Selection
		if(parent_value_node)
		{
			const int index(property_value_desc().get_value().get_index());
			const synfig::ValueNode_DynamicList::ListEntry::ActivepointList& activepoint_list(parent_value_node->list[index].timing_info);
			synfig::ValueNode_DynamicList::ListEntry::ActivepointList::const_iterator iter;

			for(iter=activepoint_list.begin();iter!=activepoint_list.end();++iter)
			{
				Time val=abs(iter->time-selected_time);
				if(val<nearest)
				{
					nearest=val;
					selected=*iter;
					selection=true;
				}
			}
			// Perhaps I should signal if we selected this activepoint?
		}*/

			if(event->button.button==3)
			{
				Time stime;
				synfigapp::ValueDesc valdesc = property_value_desc().get_value();
				const Node::time_set *tset = get_times_from_vdesc(valdesc);
				synfig::Time time_offset = get_time_offset_from_vdesc(valdesc);

				bool clickfound = tset && get_closest_time(*tset,actual_time+time_offset,pixel_width*cell_area.get_height(),stime);

				etl::handle<synfig::Node> node;
				if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") &&
				   valdesc.get_value(stime).get_type()==type_canvas)
				{
					node=Canvas::Handle(valdesc.get_value(stime).get(Canvas::Handle()));
				}
				else //if(valdesc.is_value_node())
				{
					node=valdesc.get_value_node();
				}

				if(clickfound && node)
					signal_waypoint_clicked_cellrenderer()(node, stime, time_offset, 2);
			}

		break;
	case GDK_MOTION_NOTIFY:
		//if(selection && dragging)
		//	selected_time=((float)event->motion.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
		return true;

		break;
	case GDK_BUTTON_RELEASE:
		{
			//selected_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
			dragging=false;

			/*if(event->button.button==3 && selection)
			{
				signal_waypoint_clicked_cellrenderer()(path,*selected_waypoint,event->button.button-1);
				return true;
			}
			*/

			//Time point stuff...
			if(event->button.button == 1)
			{
				bool delmode = (mode & DELETE_MASK) && !(mode & COPY_MASK);
				deltatime = actual_time - actual_dragtime;
				if(sel_times.size() != 0 && (delmode || !deltatime.is_equal(Time(0))))
				{
					synfigapp::Action::ParamList param_list;
					param_list.add("canvas",canvas_interface()->get_canvas());
					param_list.add("canvas_interface",canvas_interface());

					if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") &&
					   sel_value.get_value_type() == synfig::type_canvas)
					{
						param_list.add("addcanvas",sel_value.get_value().get(Canvas::Handle()));
					}else
					{
						param_list.add("addvaluedesc",sel_value);
					}

					set<Time>	newset;
					std::set<synfig::Time>::iterator i = sel_times.begin(), end = sel_times.end();
					for(; i != end; ++i)
					{
						param_list.add("addtime",*i);

						newset.insert((*i + deltatime).round(get_canvas()->rend_desc().get_frame_rate()));
					}

					if(!delmode)
						param_list.add("deltatime",deltatime);
				//	param_list.add("time",canvas_interface()->get_time());

					if(mode & COPY_MASK) //copy
					{
						etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
							->process_action("TimepointsCopy", param_list);
					}else if(delmode) //DELETE
					{
						etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
							->process_action("TimepointsDelete", param_list);
					}else //MOVE
					{
						etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
							->process_action("TimepointsMove", param_list);
					}

					//now replace all the selected with the new selected
					sel_times = newset;
				}
			}



			/*if(value_node && selection)
			{
				if(selected_time==drag_time && event->button.button!=3)
					signal_waypoint_clicked_cellrenderer()(path,*selected_waypoint,event->button.button-1);
				else
				if(event->button.button==1)
				{
					synfig::Waypoint waypoint(*selected_waypoint);
					Time newtime((waypoint.get_time()+(selected_time-drag_time)).round(canvas->rend_desc().get_frame_rate()));
					if(waypoint.get_time()!=newtime)
					{
						waypoint.set_time(newtime);
						signal_waypoint_changed_(waypoint,value_node);
					}
				}
			}*/

			//if(selection)
			//	selected_time=iter->time;
			//selected_time=iter->get_time();
			return true;
		}
	default:
		//std::cerr<<"unknown event type "<<event->type<<std::endl;
		return false;
		break;
	}



	return false;
}
コード例 #29
0
bool MouseAwareTreeView::queueDrawIfNeccesary(int32_t x, int32_t y, Glib::ustring* pPath)
{
    Gtk::TreeModel::Path mousePath;
    Gtk::TreeViewColumn* pColumn;
    Gdk::Rectangle rect;

    convert_bin_window_to_widget_coords (x, y, m_MouseInfo.x, m_MouseInfo.y);

    if (get_path_at_pos(x, y, mousePath, pColumn, x, y))
    {
        int32_t offsetX, offsetY;
        convert_bin_window_to_widget_coords(0, 0, offsetX, offsetY);

        m_MouseInfo.x -= offsetX;
        m_MouseInfo.y -= offsetY;

        get_cell_area(mousePath, *pColumn, rect);
        queue_draw_area(rect.get_x() + offsetX, rect.get_y() + offsetY, rect.get_width(), rect.get_height());
        if (rect.get_y() != m_CurrentCell)
        {
            m_CurrentCell = rect.get_y();
            m_CellChanged = true;
        }

        if (pPath)
        {
            *pPath = mousePath.to_string();
        }
        return true;
    }

    return false;
}
コード例 #30
0
void
studio::render_time_point_to_window(
	const Glib::RefPtr<Gdk::Drawable>& window,
	const Gdk::Rectangle& area,
	const synfig::TimePoint &tp,
	bool selected
)
{
	Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
	const Gdk::Color black("#2e3436");

	if(selected)
		gc->set_line_attributes(2,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
	else
		gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);

	Gdk::Color color;
	std::vector<Gdk::Point> points;

/*-	BEFORE ------------------------------------- */

	color=get_interp_color(tp.get_before());
	color=color_darken(color,1.0f);
	if(selected)color=color_darken(color,1.3f);
	gc->set_rgb_fg_color(color);

	switch(tp.get_before())
	{
	case INTERPOLATION_TCB:
		window->draw_arc(
			gc,
			true,
			area.get_x(),
			area.get_y(),
			area.get_width(),
			area.get_height(),
			64*90,
			64*180
		);
		gc->set_rgb_fg_color(black);
		window->draw_arc(
			gc,
			false,
			area.get_x(),
			area.get_y(),
			area.get_width(),
			area.get_height(),
			64*90,
			64*180
		);
		break;

	case INTERPOLATION_HALT:
		window->draw_arc(
			gc,
			true,
			area.get_x(),
			area.get_y(),
			area.get_width(),
			area.get_height()*2,
			64*90,
			64*90
		);
		gc->set_rgb_fg_color(black);
		window->draw_arc(
			gc,
			false,
			area.get_x(),
			area.get_y(),
			area.get_width(),
			area.get_height()*2,
			64*90,
			64*90
		);

		points.clear();
		points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
		window->draw_lines(gc,points);

		break;

	case INTERPOLATION_LINEAR:
		points.clear();
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
		points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
		window->draw_polygon(gc,true,points);
		gc->set_rgb_fg_color(black);
		window->draw_lines(gc,points);
		break;

	case INTERPOLATION_CONSTANT:
		points.clear();
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/4,area.get_y()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/4,area.get_y()+area.get_height()/2));
		points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()/2));
		points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
		window->draw_polygon(gc,true,points);
		gc->set_rgb_fg_color(black);
		window->draw_lines(gc,points);
		break;

	case INTERPOLATION_CLAMPED:
		points.clear();
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
		points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()/2));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
		window->draw_polygon(gc,true,points);
		gc->set_rgb_fg_color(black);
		window->draw_lines(gc,points);
		break;

	case INTERPOLATION_UNDEFINED: default:
		points.clear();
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/3,area.get_y()));
		points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()/3));
		points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()-area.get_height()/3));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/3,area.get_y()+area.get_height()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
		window->draw_polygon(gc,true,points);
		gc->set_rgb_fg_color(black);
		window->draw_lines(gc,points);
		break;
	}

/*-	AFTER -------------------------------------- */

	color=get_interp_color(tp.get_after());
	color=color_darken(color,0.8f);
	if(selected)color=color_darken(color,1.3f);
	gc->set_rgb_fg_color(color);

	switch(tp.get_after())
	{
	case INTERPOLATION_TCB:
		window->draw_arc(
			gc,
			true,
			area.get_x(),
			area.get_y(),
			area.get_width(),
			area.get_height(),
			64*270,
			64*180
		);
		gc->set_rgb_fg_color(black);
		window->draw_arc(
			gc,
			false,
			area.get_x(),
			area.get_y(),
			area.get_width(),
			area.get_height(),
			64*270,
			64*180
		);
		break;

	case INTERPOLATION_HALT:
		window->draw_arc(
			gc,
			true,
			area.get_x(),
			area.get_y()-area.get_height(),
			area.get_width(),
			area.get_height()*2,
			64*270,
			64*90
		);
		gc->set_rgb_fg_color(black);
		window->draw_arc(
			gc,
			false,
			area.get_x(),
			area.get_y()-area.get_height(),
			area.get_width(),
			area.get_height()*2,
			64*270,
			64*90
		);

		points.clear();
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()));
		window->draw_lines(gc,points);

		break;

	case INTERPOLATION_LINEAR:
		points.clear();
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
		window->draw_polygon(gc,true,points);
		gc->set_rgb_fg_color(black);
		window->draw_lines(gc,points);
		break;

	case INTERPOLATION_CONSTANT:
		points.clear();
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/2));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/4,area.get_y()+area.get_height()/2));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/4,area.get_y()+area.get_height()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
		window->draw_polygon(gc,true,points);
		gc->set_rgb_fg_color(black);
		window->draw_lines(gc,points);
		break;

	case INTERPOLATION_CLAMPED:
		points.clear();
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/2));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
		window->draw_polygon(gc,true,points);
		gc->set_rgb_fg_color(black);
		window->draw_lines(gc,points);
		break;

	case INTERPOLATION_UNDEFINED: default:
		points.clear();
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/3,area.get_y()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/3));
		points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()-area.get_height()/3));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/3,area.get_y()+area.get_height()));
		points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
		window->draw_polygon(gc,true,points);
		gc->set_rgb_fg_color(black);
		window->draw_lines(gc,points);
		break;
	}

}