示例#1
0
static void mesh_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
{
    static sigc::connection c_selection_changed;
    static sigc::connection c_selection_modified;
    static sigc::connection c_subselection_changed;
    static sigc::connection c_defs_release;
    static sigc::connection c_defs_modified;

    if (SP_IS_MESH_CONTEXT(ec)) {
        // connect to selection modified and changed signals
        Inkscape::Selection *selection = desktop->getSelection();
        SPDocument *document = desktop->getDocument();

        c_selection_changed = selection->connectChanged(sigc::bind(sigc::ptr_fun(&ms_tb_selection_changed), holder));
        c_selection_modified = selection->connectModified(sigc::bind(sigc::ptr_fun(&ms_tb_selection_modified), holder));
        c_subselection_changed = desktop->connectToolSubselectionChanged(sigc::bind(sigc::ptr_fun(&ms_drag_selection_changed), holder));

        c_defs_release = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&ms_defs_release), holder));
        c_defs_modified = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&ms_defs_modified), holder));
        ms_tb_selection_changed(selection, holder);
    } else {
        if (c_selection_changed)
            c_selection_changed.disconnect();
        if (c_selection_modified)
            c_selection_modified.disconnect();
        if (c_subselection_changed)
            c_subselection_changed.disconnect();
        if (c_defs_release)
            c_defs_release.disconnect();
        if (c_defs_modified)
            c_defs_modified.disconnect();
    }
}
示例#2
0
 void stopSimulationRequested()
 {
     if (runner.isRunning())
         runner.interrupt();
     if (!progressTimer.empty())
         progressTimer.disconnect();
     updateProgressBar();
 }
示例#3
0
	~WindowVXPrivate()
	{
		shState->texPool().release(base.tex);

		cursorRectCon.disconnect();
		toneCon.disconnect();
		prepareCon.disconnect();
	}
示例#4
0
void
Simple::animate_toggled()
{
  static sigc::connection timer;
  bool  active = m_animate.get_active();
  if (active && !timer.connected())
      timer = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Simple::animate_step), ANIMATE_FRAME_DELAY);
  else if (!active && timer.connected())
      timer.disconnect();
}
示例#5
0
static void box3d_toolbox_check_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
{
    static sigc::connection changed;
    if (SP_IS_BOX3D_CONTEXT(ec)) {
        changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(box3d_toolbox_selection_changed), holder));
        box3d_toolbox_selection_changed(sp_desktop_selection(desktop), holder);
    } else {
        if (changed)
            changed.disconnect();
    }
}
示例#6
0
static void arc_toolbox_check_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
{
    static sigc::connection changed;

    if (SP_IS_ARC_CONTEXT(ec)) {
        changed = desktop->getSelection()->connectChanged(sigc::bind(sigc::ptr_fun(sp_arc_toolbox_selection_changed), holder));
        sp_arc_toolbox_selection_changed(desktop->getSelection(), holder);
    } else {
        if (changed)
            changed.disconnect();
    }
}
示例#7
0
void Screen::ClearFocus()
{
	if (!focusedWidget) return;
	_focusedWidgetOnDelete.disconnect();
	focusedWidget = 0;
	SDL_EnableKeyRepeat(0, 0); // disable key repeat
}
示例#8
0
 virtual bool close()
 {
     monitorOutput.close();
     m_timer.disconnect();
     fprintf(stdout,"done...\n");
     yarp::os::exit(1);        
     return true;
 }
示例#9
0
文件: sprite.cpp 项目: Daverball/mkxp
	void updateSrcRectCon()
	{
		/* Cut old connection */
		srcRectCon.disconnect();
		/* Create new one */
		srcRectCon = srcRect->valueChanged.connect
				(sigc::mem_fun(this, &SpritePrivate::onSrcRectChange));
	}
示例#10
0
void Screen::SetFocused(Widget *w)
{
	if (focusedWidget) {
		_focusedWidgetOnDelete.disconnect();
	}
	_focusedWidgetOnDelete = w->onDelete.connect(sigc::ptr_fun(&Screen::OnDeleteFocusedWidget));
	focusedWidget = w;
}
示例#11
0
static void rect_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
{
    static sigc::connection changed;

    // use of dynamic_cast<> seems wrong here -- we just need to check the current tool

    if (dynamic_cast<Inkscape::UI::Tools::RectTool *>(ec)) {
        Inkscape::Selection *sel = desktop->getSelection();

        changed = sel->connectChanged(sigc::bind(sigc::ptr_fun(sp_rect_toolbox_selection_changed), holder));

        // Synthesize an emission to trigger the update
        sp_rect_toolbox_selection_changed(sel, holder);
    } else {
        if (changed) {
            changed.disconnect();
            purge_repr_listener(NULL, holder);
        }
    }
}
示例#12
0
void on_thread_back_clicked() {
	///To be run when the back button is clicked while viewing a thread
	
	boardView();
	Gtk::TreeView *threadlist = 0;
	pWebKitView = WEBKIT_WEB_VIEW (webkit_web_view_new ());
	Gtk::ScrolledWindow *imgview = 0;
	builder->get_widget("scrolledwindow3", imgview);
	imgview->set_visible(true);
	imgview->show();
	
	gtk_container_add (GTK_CONTAINER (imgview->gobj()), GTK_WIDGET (pWebKitView));
	webkit_web_view_load_uri(pWebKitView, "about:blank");
	webkit_web_view_set_zoom_level(pWebKitView, true);
	gtk_widget_set_can_focus(GTK_WIDGET(pWebKitView), true);
	gtk_widget_show(GTK_WIDGET(pWebKitView));
	builder->get_widget("treeview2", threadlist);
	Glib::RefPtr<Gtk::TreeSelection> thread_selection = threadlist->get_selection();
	thread_selection->signal_changed().connect(sigc::bind<Glib::RefPtr<Gtk::TreeSelection>, WebKitWebView*>(sigc::ptr_fun(&on_selection_changed), thread_selection, pWebKitView));
	
	POST_CLICK_CONNECT.disconnect();
	POST_REFRESH_CONNECT.disconnect();
}
示例#13
0
/**
 * Checks the current tool and connects gradient aux toolbox signals if it happens to be the gradient tool.
 * Called every time the current tool changes by signal emission.
 */
static void gradient_toolbox_check_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
{
    static sigc::connection connChanged;
    static sigc::connection connModified;
    static sigc::connection connSubselectionChanged;
    static sigc::connection connDefsRelease;
    static sigc::connection connDefsModified;

    if (SP_IS_GRADIENT_CONTEXT(ec)) {
        Inkscape::Selection *selection = sp_desktop_selection(desktop);
        SPDocument *document = sp_desktop_document(desktop);

        // connect to selection modified and changed signals
        connChanged = selection->connectChanged(sigc::bind(sigc::ptr_fun(&gr_tb_selection_changed), holder));
        connModified = selection->connectModified(sigc::bind(sigc::ptr_fun(&gr_tb_selection_modified), holder));
        connSubselectionChanged = desktop->connectToolSubselectionChanged(sigc::bind(sigc::ptr_fun(&gr_drag_selection_changed), holder));

        // Is this necessary? Couldn't hurt.
        gr_tb_selection_changed(selection, holder);

        // connect to release and modified signals of the defs (i.e. when someone changes gradient)
        connDefsRelease = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&gr_defs_release), GTK_WIDGET(holder)));
        connDefsModified = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&gr_defs_modified), GTK_WIDGET(holder)));
    } else {
        if (connChanged)
            connChanged.disconnect();
        if (connModified)
            connModified.disconnect();
        if (connSubselectionChanged)
            connSubselectionChanged.disconnect();
        if (connDefsRelease)
            connDefsRelease.disconnect();
        if (connDefsModified)
            connDefsModified.disconnect();
    }
}
示例#14
0
	~ViewportPrivate()
	{
		rectCon.disconnect();
	}
示例#15
0
	void refreshCursorRectCon()
	{
		cursorRectCon.disconnect();
		cursorRectCon = cursorRect->valueChanged.connect
		        (sigc::mem_fun(this, &WindowVXPrivate::invalidateCursorVert));
	}
示例#16
0
void Screen::OnDeleteFocusedWidget()
{
	_focusedWidgetOnDelete.disconnect();
	focusedWidget = 0;
	SDL_EnableKeyRepeat(0, 0); // disable key repeat
}
示例#17
0
namespace Gui {

bool Screen::initted = false;
int Screen::width;
int Screen::height;
int Screen::realWidth;
int Screen::realHeight;
float Screen::invRealWidth;
float Screen::invRealHeight;
float Screen::fontScale[2];
std::list<Widget*> Screen::kbshortcut_widgets;
Gui::Fixed *Screen::baseContainer;
Gui::Widget *Screen::focusedWidget;
GLdouble Screen::modelMatrix[16];
GLdouble Screen::projMatrix[16];
GLint Screen::viewport[4];

FontCache Screen::s_fontCache;
std::stack< RefCountedPtr<Text::TextureFont> > Screen::s_fontStack;
RefCountedPtr<Text::TextureFont>Screen::s_defaultFont;

Graphics::Renderer *Screen::s_renderer;

void Screen::Init(Graphics::Renderer *renderer, int real_width, int real_height, int ui_width, int ui_height)
{
    s_renderer = renderer;

	Screen::width = ui_width;
	Screen::height = ui_height;
	Screen::realWidth = real_width;
	Screen::realHeight = real_height;
	Screen::invRealWidth = 1.0f/real_width;
	Screen::invRealHeight = 1.0f/real_height;
	Screen::initted = true;
	// Why? because although our font textures get bigger with screen
	// resolution, our Gui Ortho projection is still 800x600 so vertex
	// coords must be scaled.
	Screen::fontScale[0] = ui_width / float(real_width);
	Screen::fontScale[1] = ui_height / float(real_height);
    s_defaultFont = s_fontCache.GetTextureFont("GuiFont");
    PushFont(s_defaultFont);
	Screen::baseContainer = new Gui::Fixed();
	Screen::baseContainer->SetSize(float(Screen::width), float(Screen::height));
	Screen::baseContainer->Show();
}

void Screen::Uninit()
{
	Screen::baseContainer->RemoveAllChildren();		// children deleted elsewhere?
	delete Screen::baseContainer;
}

static sigc::connection _focusedWidgetOnDelete;

void Screen::OnDeleteFocusedWidget()
{
	_focusedWidgetOnDelete.disconnect();
	focusedWidget = 0;
	SDL_EnableKeyRepeat(0, 0); // disable key repeat
}

void Screen::SetFocused(Widget *w, bool enableKeyRepeat)
{
	ClearFocus();
	if (enableKeyRepeat)
		SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
	_focusedWidgetOnDelete = w->onDelete.connect(sigc::ptr_fun(&Screen::OnDeleteFocusedWidget));
	focusedWidget = w;
}

void Screen::ClearFocus()
{
	if (!focusedWidget) return;
	_focusedWidgetOnDelete.disconnect();
	focusedWidget = 0;
	SDL_EnableKeyRepeat(0, 0); // disable key repeat
}

void Screen::ShowBadError(const char *msg)
{
	baseContainer->HideChildren();

	Gui::Fixed *f = new Gui::Fixed(6*GetWidth()/8.0f, 6*GetHeight()/8.0f);
	Gui::Screen::AddBaseWidget(f, GetWidth()/8, GetHeight()/8);
	f->SetTransparency(false);
	f->SetBgColor(0.4f,0,0,1.0f);
	f->Add(new Gui::Label(msg), 10, 10);

	Gui::Button *okButton = new Gui::LabelButton(new Gui::Label("Ok"));
	okButton->SetShortcut(SDLK_RETURN, KMOD_NONE);
	f->Add(okButton, 10.0f, 6*GetHeight()/8.0f - 32);
	f->ShowAll();
	f->Show();

	do {
		Gui::MainLoopIteration();
		SDL_Delay(10);
	} while (!okButton->IsPressed());

	Gui::Screen::RemoveBaseWidget(f);
	delete f;
}

bool Screen::Project(const vector3d &in, vector3d &out)
{
	GLint o = gluProject(in.x, in.y, in.z, modelMatrix, projMatrix, viewport, &out.x, &out.y, &out.z);
	out.x = out.x * width * invRealWidth;
	out.y = GetHeight() - out.y * height * invRealHeight;
	return (o == GL_TRUE);
}

void Screen::EnterOrtho()
{
	glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix);
	glGetDoublev (GL_PROJECTION_MATRIX, projMatrix);
	glGetIntegerv (GL_VIEWPORT, viewport);

	glDisable(GL_DEPTH_TEST);
	glDisable(GL_LIGHTING);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);	
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0, width, height, 0, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
}

void Screen::LeaveOrtho()
{	
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glEnable(GL_LIGHTING);
	glEnable(GL_DEPTH_TEST);
}

void Screen::Draw()
{
	assert(Screen::initted);
	EnterOrtho();
	baseContainer->Draw();
	LeaveOrtho();
}

bool Screen::IsBaseWidget(const Widget *w)
{
	return w == static_cast<const Widget*>(baseContainer);
}

void Screen::AddBaseWidget(Widget *w, int x, int y)
{
	baseContainer->Add(w, float(x), float(y));
}

void Screen::RemoveBaseWidget(Widget *w)
{
	baseContainer->Remove(w);
}
	
void Screen::SDLEventCoordToScreenCoord(int sdlev_x, int sdlev_y, float *x, float *y)
{
	*y = sdlev_y*height*invRealHeight;
	*x = sdlev_x*width*invRealWidth;
}

void Screen::OnMouseMotion(SDL_MouseMotionEvent *e)
{
	MouseMotionEvent ev;
	float x, y;
	Screen::SDLEventCoordToScreenCoord(e->x, e->y, &x, &y);
	ev.screenX = ev.x = x;
	ev.screenY = ev.y = y;
	baseContainer->OnMouseMotion(&ev);
	ev.screenX = ev.x = x;
	ev.screenY = ev.y = y;
	RawEvents::onMouseMotion.emit(&ev);
}

void Screen::OnClick(SDL_MouseButtonEvent *e)
{
	MouseButtonEvent ev;
	float x, y;
	Screen::SDLEventCoordToScreenCoord(e->x, e->y, &x, &y);
	ev.button = e->button;
	ev.isdown = (e->type == SDL_MOUSEBUTTONDOWN);
	ev.screenX = ev.x = x;
	ev.screenY = ev.y = y;
	if (ev.isdown) {
		baseContainer->OnMouseDown(&ev);
		RawEvents::onMouseDown.emit(&ev);
	} else {
		baseContainer->OnMouseUp(&ev);
		RawEvents::onMouseUp.emit(&ev);
	}
}

void Screen::OnKeyDown(const SDL_keysym *sym)
{
	if (focusedWidget) {
		bool accepted = focusedWidget->OnKeyPress(sym);
		// don't check shortcuts if the focused widget accepted the key-press
		if (accepted)
			return;
	}
	for (std::list<Widget*>::iterator i = kbshortcut_widgets.begin(); i != kbshortcut_widgets.end(); ++i) {
		if (!(*i)->IsVisible()) continue;
		if (!(*i)->GetEnabled()) continue;
		(*i)->OnPreShortcut(sym);
	}
}

void Screen::OnKeyUp(const SDL_keysym *sym)
{
}

float Screen::GetFontHeight(Text::TextureFont *font)
{
    if (!font) font = GetFont().Get();

	return font->GetHeight() * fontScale[1];
}

float Screen::GetFontDescender(Text::TextureFont *font)
{
    if (!font) font = GetFont().Get();

	return font->GetDescender() * fontScale[1];
}

void Screen::MeasureString(const std::string &s, float &w, float &h, Text::TextureFont *font)
{
	if (!font) font = GetFont().Get();
	assert(font);

	font->MeasureString(s.c_str(), w, h);
	w *= fontScale[0];
	h *= fontScale[1];
}

void Screen::MeasureCharacterPos(const std::string &s, int charIndex, float &x, float &y, Text::TextureFont *font)
{
	assert((charIndex >= 0) && (charIndex <= int(s.size())));

	if (!font) font = GetFont().Get();
	assert(font);

	font->MeasureCharacterPos(s.c_str(), charIndex, x, y);
	x *= fontScale[0];
	y *= fontScale[1];
}

int Screen::PickCharacterInString(const std::string &s, float x, float y, Text::TextureFont *font)
{
	if (!font) font = GetFont().Get();
	assert(font);

	x /= fontScale[0];
	y /= fontScale[1];

	return font->PickCharacter(s.c_str(), x, y);
}

void Screen::RenderString(const std::string &s, float xoff, float yoff, const Color &color, Text::TextureFont *font)
{
    if (!font) font = GetFont().Get();

	GLdouble modelMatrix_[16];
	glPushMatrix();
	glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix_);
	float x = modelMatrix_[12] + xoff;
	float y = modelMatrix_[13] + yoff;
	glLoadIdentity();
	glTranslatef(floor(x/Screen::fontScale[0])*Screen::fontScale[0],
			floor(y/Screen::fontScale[1])*Screen::fontScale[1], 0);
	glScalef(Screen::fontScale[0], Screen::fontScale[1], 1);
	font->RenderString(s.c_str(), 0, 0, color);
	glPopMatrix();
}

void Screen::RenderMarkup(const std::string &s, const Color &color, Text::TextureFont *font)
{
    if (!font) font = GetFont().Get();

	GLdouble modelMatrix_[16];
	glPushMatrix();
	glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix_);
	float x = modelMatrix_[12];
	float y = modelMatrix_[13];
	glLoadIdentity();
	glTranslatef(floor(x/Screen::fontScale[0])*Screen::fontScale[0],
			floor(y/Screen::fontScale[1])*Screen::fontScale[1], 0);
	glScalef(Screen::fontScale[0], Screen::fontScale[1], 1);
	font->RenderMarkup(s.c_str(), 0, 0, color);
	glPopMatrix();
}

void Screen::AddShortcutWidget(Widget *w)
{
	kbshortcut_widgets.push_back(w);
}

void Screen::RemoveShortcutWidget(Widget *w)
{
	kbshortcut_widgets.remove(w);
}

}
示例#18
0
	void refreshToneCon()
	{
		toneCon.disconnect();
		toneCon = tone->valueChanged.connect
			(sigc::mem_fun(this, &WindowVXPrivate::invalidateBaseTex));
	}
示例#19
0
void AmbientSounds::Uninit()
{
	onChangeCamTypeConnection.disconnect();
}
示例#20
0
void Screen::ClearFocus()
{
	if (!focusedWidget) return;
	_focusedWidgetOnDelete.disconnect();
	focusedWidget = 0;
}
示例#21
0
文件: sprite.cpp 项目: Daverball/mkxp
	~SpritePrivate()
	{
		srcRectCon.disconnect();
		prepareCon.disconnect();
	}
	~AsyncTarget_Scanline()
	{
		ready_connection.disconnect();
	}
示例#23
0
void Screen::OnDeleteFocusedWidget()
{
	_focusedWidgetOnDelete.disconnect();
	focusedWidget = 0;
}
示例#24
0
namespace Gui {

TextureFontFace *Screen::font;
bool Screen::initted = false;
int Screen::width;
int Screen::height;
int Screen::realWidth;
int Screen::realHeight;
float Screen::invRealWidth;
float Screen::invRealHeight;
float Screen::fontScale[2];
std::list<Widget*> Screen::kbshortcut_widgets;
Gui::Fixed *Screen::baseContainer;
Gui::Widget *Screen::focusedWidget;
GLdouble Screen::modelMatrix[16];
GLdouble Screen::projMatrix[16];
GLint Screen::viewport[4];


void Screen::Init(int real_width, int real_height, int ui_width, int ui_height)
{
	Screen::width = ui_width;
	Screen::height = ui_height;
	Screen::realWidth = real_width;
	Screen::realHeight = real_height;
	Screen::invRealWidth = 1.0f/real_width;
	Screen::invRealHeight = 1.0f/real_height;
	Screen::initted = true;
	// Why? because although our font textures get bigger with screen
	// resolution, our Gui Ortho projection is still 800x600 so vertex
	// coords must be scaled.
	Screen::fontScale[0] = ui_width / (float)real_width;
	Screen::fontScale[1] = ui_height / (float)real_height;
	Screen::font = new TextureFontFace(PIONEER_DATA_DIR "/fonts/guifont.ttf", (int)(12/fontScale[0]), (int)(12/fontScale[1]));
	Screen::baseContainer = new Gui::Fixed();
	Screen::baseContainer->SetSize((float)Screen::width, (float)Screen::height);
	Screen::baseContainer->Show();
}

static sigc::connection _focusedWidgetOnDelete;

void Screen::OnDeleteFocusedWidget()
{
	_focusedWidgetOnDelete.disconnect();
	focusedWidget = 0;
}

void Screen::SetFocused(Widget *w)
{
	if (focusedWidget) {
		_focusedWidgetOnDelete.disconnect();
	}
	_focusedWidgetOnDelete = w->onDelete.connect(sigc::ptr_fun(&Screen::OnDeleteFocusedWidget));
	focusedWidget = w;
}

void Screen::ShowBadError(const char *msg)
{
	fprintf(stderr, "%s", msg);
	baseContainer->HideChildren();
	
	Gui::Fixed *f = new Gui::Fixed(6*GetWidth()/8, 6*GetHeight()/8);
	Gui::Screen::AddBaseWidget(f, GetWidth()/8, GetHeight()/8);
	f->SetTransparency(false);
	f->SetBgColor(0.4,0,0,1.0);
	f->Add(new Gui::Label(msg), 10, 10);

	Gui::Button *okButton = new Gui::LabelButton(new Gui::Label("Ok"));
	okButton->SetShortcut(SDLK_RETURN, KMOD_NONE);
	f->Add(okButton, 10, 6*GetHeight()/8 - 32);
	f->ShowAll();
	f->Show();

	do {
		Gui::MainLoopIteration();
		SDL_Delay(10);
	} while (!okButton->IsPressed());

	Gui::Screen::RemoveBaseWidget(f);
	delete f;
	baseContainer->ShowAll();
}

bool Screen::Project(const vector3d &in, vector3d &out)
{
	GLint o = gluProject(in.x, in.y, in.z, modelMatrix, projMatrix, viewport, &out.x, &out.y, &out.z);
	out.x = out.x * width * invRealWidth;
	out.y = GetHeight() - out.y * height * invRealHeight;
	if (out.x*out.x > 1e8) return false;
	if (out.y*out.y > 1e8) return false;			// these get converted to ints later, must be sane
	return (o == GL_TRUE) ? true : false;
}

void Screen::EnterOrtho()
{
	glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix);
	glGetDoublev (GL_PROJECTION_MATRIX, projMatrix);
	glGetIntegerv (GL_VIEWPORT, viewport);

	glDisable(GL_DEPTH_TEST);
	glDisable(GL_LIGHTING);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);	
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0, width, height, 0, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
}

void Screen::LeaveOrtho()
{	
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glEnable(GL_LIGHTING);
	glEnable(GL_DEPTH_TEST);
}

void Screen::Draw()
{
	assert(Screen::initted);
	EnterOrtho();
	baseContainer->Draw();
	LeaveOrtho();
}

bool Screen::IsBaseWidget(const Widget *w)
{
	return w == static_cast<const Widget*>(baseContainer);
}

void Screen::AddBaseWidget(Widget *w, int x, int y)
{
	baseContainer->Add(w, (float)x, (float)y);
}

void Screen::RemoveBaseWidget(Widget *w)
{
	baseContainer->Remove(w);
}
	
void Screen::SDLEventCoordToScreenCoord(int sdlev_x, int sdlev_y, float *x, float *y)
{
	*y = sdlev_y*height*invRealHeight;
	*x = sdlev_x*width*invRealWidth;
}

void Screen::OnMouseMotion(SDL_MouseMotionEvent *e)
{
	MouseMotionEvent ev;
	float x, y;
	Screen::SDLEventCoordToScreenCoord(e->x, e->y, &x, &y);
	ev.screenX = ev.x = x;
	ev.screenY = ev.y = y;
	baseContainer->OnMouseMotion(&ev);
	ev.screenX = ev.x = x;
	ev.screenY = ev.y = y;
	RawEvents::onMouseMotion.emit(&ev);
}

void Screen::OnClick(SDL_MouseButtonEvent *e)
{
	MouseButtonEvent ev;
	float x, y;
	Screen::SDLEventCoordToScreenCoord(e->x, e->y, &x, &y);
	ev.button = e->button;
	ev.isdown = (e->type == SDL_MOUSEBUTTONDOWN);
	ev.screenX = ev.x = x;
	ev.screenY = ev.y = y;
	if (ev.isdown) {
		baseContainer->OnMouseDown(&ev);
		RawEvents::onMouseDown.emit(&ev);
	} else {
		baseContainer->OnMouseUp(&ev);
		RawEvents::onMouseUp.emit(&ev);
	}
}

void Screen::OnKeyDown(const SDL_keysym *sym)
{
	for (std::list<Widget*>::iterator i = kbshortcut_widgets.begin(); i != kbshortcut_widgets.end(); ++i) {
		if (!(*i)->IsVisible()) continue;
		if (!(*i)->GetEnabled()) continue;
		(*i)->OnPreShortcut(sym);
	}
	if (focusedWidget) focusedWidget->OnKeyPress(sym);
}

void Screen::OnKeyUp(const SDL_keysym *sym)
{
}

float Screen::GetFontHeight()
{
	return font->GetHeight() * fontScale[1];
}

void Screen::MeasureString(const std::string &s, float &w, float &h)
{
	font->MeasureString(s.c_str(), w, h);
	w *= fontScale[0];
	h *= fontScale[1];
}

void Screen::RenderString(const std::string &s, float xoff, float yoff)
{
	GLdouble modelMatrix[16];
	glPushMatrix();
	glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix);
	float x = modelMatrix[12] + xoff;
	float y = modelMatrix[13] + yoff;
	glLoadIdentity();
	glTranslatef(floor(x/Screen::fontScale[0])*Screen::fontScale[0],
			floor(y/Screen::fontScale[1])*Screen::fontScale[1], 0);
	glScalef(Screen::fontScale[0], Screen::fontScale[1], 1);
	font->RenderString(s.c_str(), 0, 0);
	glPopMatrix();
}

void Screen::RenderMarkup(const std::string &s)
{
	GLdouble modelMatrix[16];
	glPushMatrix();
	glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix);
	float x = modelMatrix[12];
	float y = modelMatrix[13];
	glLoadIdentity();
	glTranslatef(floor(x/Screen::fontScale[0])*Screen::fontScale[0],
			floor(y/Screen::fontScale[1])*Screen::fontScale[1], 0);
	glScalef(Screen::fontScale[0], Screen::fontScale[1], 1);
	font->RenderMarkup(s.c_str(), 0, 0);
	glPopMatrix();
}

void Screen::AddShortcutWidget(Widget *w)
{
	kbshortcut_widgets.push_back(w);
}

void Screen::RemoveShortcutWidget(Widget *w)
{
	kbshortcut_widgets.remove(w);
}

}
示例#25
0
	void updateRectCon()
	{
		rectCon.disconnect();
		rectCon = rect->valueChanged.connect
		        (sigc::mem_fun(this, &ViewportPrivate::onRectChange));
	}
void AppWindow::Level7()
{
  conn.disconnect();
  conn = Glib::signal_timeout().connect(sigc::mem_fun(*this,&AppWindow::update), 1);
}
	~AsyncTarget_Tile()
	{
		ready_connection.disconnect();
	}
 Q_FOREACH(sigc::connection connection, connections) {
     connection.disconnect();
 }
	~AsyncTarget_Cairo()
	{
		ready_connection.disconnect();
	}
示例#30
0
void on_board_back_clicked() {
	///To be run when "back" is hit while viewing the list of threads on a board
	
	listView();
	THREAD_CLICK_CONNECT.disconnect();
}