GTK GUI :

Added fullscreen support (toggle with F11)
This commit is contained in:
bgk 2008-04-29 19:08:47 +00:00
parent 0509c211b1
commit baf094ce92
4 changed files with 65 additions and 1 deletions

View File

@ -598,6 +598,20 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child> <child>
<widget class="GtkMenu" id="VideoMenu_menu"> <widget class="GtkMenu" id="VideoMenu_menu">
<child>
<widget class="GtkImageMenuItem" id="VideoFullscreen">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-fullscreen</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<accelerator key="F11" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
</widget>
</child>
<child> <child>
<widget class="GtkRadioMenuItem" id="VideoOpenGL"> <widget class="GtkRadioMenuItem" id="VideoOpenGL">
<property name="visible">True</property> <property name="visible">True</property>

View File

@ -90,7 +90,8 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) :
m_iJoypadMin (1), m_iJoypadMin (1),
m_iJoypadMax (4), m_iJoypadMax (4),
m_iVideoOutputMin (OutputCairo), m_iVideoOutputMin (OutputCairo),
m_iVideoOutputMax (OutputXvideo) m_iVideoOutputMax (OutputXvideo),
m_bFullscreen (false)
{ {
m_poXml = _poXml; m_poXml = _poXml;
m_poFileOpenDialog = NULL; m_poFileOpenDialog = NULL;
@ -131,6 +132,9 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) :
Gtk::MenuItem * poMI; Gtk::MenuItem * poMI;
Gtk::CheckMenuItem * poCMI; Gtk::CheckMenuItem * poCMI;
// Menu bar
m_poMenuBar = dynamic_cast<Gtk::MenuBar *>(_poXml->get_widget("MenuBar"));
// Video output menu // Video output menu
// //
struct struct
@ -828,6 +832,11 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) :
poCMI, astAutofire[i].m_eKeyFlag)); poCMI, astAutofire[i].m_eKeyFlag));
} }
// Fullscreen menu
//
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("VideoFullscreen"));
poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnVideoFullscreen));
// GDB menu // GDB menu
// //
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("GdbWait")); poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("GdbWait"));
@ -1953,4 +1962,18 @@ void Window::vUpdateGameSlots()
} }
} }
void Window::vToggleFullscreen()
{
if(!m_bFullscreen)
{
fullscreen();
m_poMenuBar->hide();
}
else
{
unfullscreen();
m_poMenuBar->show();
}
}
} // VBA namespace } // VBA namespace

View File

@ -159,6 +159,7 @@ protected:
virtual void vOnFrameskipToggled(Gtk::CheckMenuItem * _poCMI, int _iValue); virtual void vOnFrameskipToggled(Gtk::CheckMenuItem * _poCMI, int _iValue);
virtual void vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent); virtual void vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent);
virtual void vOnThrottleOther(Gtk::CheckMenuItem * _poCMI); virtual void vOnThrottleOther(Gtk::CheckMenuItem * _poCMI);
virtual void vOnVideoFullscreen();
virtual void vOnVideoOutputToggled(Gtk::CheckMenuItem * _poCMI, int _iOutput); virtual void vOnVideoOutputToggled(Gtk::CheckMenuItem * _poCMI, int _iOutput);
virtual void vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale); virtual void vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale);
virtual void vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer); virtual void vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer);
@ -198,6 +199,7 @@ protected:
virtual bool on_focus_out_event(GdkEventFocus * _pstEvent); virtual bool on_focus_out_event(GdkEventFocus * _pstEvent);
virtual bool on_key_press_event(GdkEventKey * _pstEvent); virtual bool on_key_press_event(GdkEventKey * _pstEvent);
virtual bool on_key_release_event(GdkEventKey * _pstEvent); virtual bool on_key_release_event(GdkEventKey * _pstEvent);
virtual bool on_window_state_event(GdkEventWindowState* _pstEvent);
private: private:
// Config limits // Config limits
@ -248,6 +250,7 @@ private:
Gtk::CheckMenuItem * m_poFilePauseItem; Gtk::CheckMenuItem * m_poFilePauseItem;
Gtk::CheckMenuItem * m_poUseBiosItem; Gtk::CheckMenuItem * m_poUseBiosItem;
Gtk::CheckMenuItem * m_poSoundOffItem; Gtk::CheckMenuItem * m_poSoundOffItem;
Gtk::MenuBar * m_poMenuBar;
struct SGameSlot struct SGameSlot
{ {
@ -269,6 +272,7 @@ private:
std::vector<JoypadConfig> m_oJoypads; std::vector<JoypadConfig> m_oJoypads;
Keymap * m_poKeymap; Keymap * m_poKeymap;
int m_bFullscreen;
int m_iScreenWidth; int m_iScreenWidth;
int m_iScreenHeight; int m_iScreenHeight;
@ -311,6 +315,7 @@ private:
void vSetThrottle(int _iPercent); void vSetThrottle(int _iPercent);
void vSelectBestThrottleItem(); void vSelectBestThrottleItem();
void vUpdateGameSlots(); void vUpdateGameSlots();
void vToggleFullscreen();
}; };
} // namespace VBA } // namespace VBA

View File

@ -590,6 +590,11 @@ void Window::vOnThrottleOther(Gtk::CheckMenuItem * _poCMI)
vSelectBestThrottleItem(); vSelectBestThrottleItem();
} }
void Window::vOnVideoFullscreen()
{
vToggleFullscreen();
}
void Window::vOnVideoOutputToggled(Gtk::CheckMenuItem * _poCMI, int _iOutput) void Window::vOnVideoOutputToggled(Gtk::CheckMenuItem * _poCMI, int _iOutput)
{ {
if (! _poCMI->get_active()) if (! _poCMI->get_active())
@ -1323,6 +1328,13 @@ bool Window::on_key_press_event(GdkEventKey * _pstEvent)
{ {
EKey eKey; EKey eKey;
// The menu accelerators are disabled when it is hidden
if (_pstEvent->keyval == GDK_F11 && !m_poMenuBar->is_visible())
{
vToggleFullscreen();
return true;
}
if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask()) if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask())
|| (eKey = m_poKeymap->eGetKey(_pstEvent->hardware_keycode)) == KeyNone) || (eKey = m_poKeymap->eGetKey(_pstEvent->hardware_keycode)) == KeyNone)
{ {
@ -1431,4 +1443,14 @@ bool Window::on_key_release_event(GdkEventKey * _pstEvent)
return true; return true;
} }
bool Window::on_window_state_event(GdkEventWindowState* _pstEvent)
{
if (_pstEvent->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
{
m_bFullscreen = _pstEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
}
return true;
}
} // namespace VBA } // namespace VBA