Make menu button only appear on hover
This commit is contained in:
@@ -42,6 +42,23 @@ template game : Box {
|
|||||||
margin-bottom: 6;
|
margin-bottom: 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[overlay]
|
||||||
|
Revealer menu_revealer {
|
||||||
|
transition-type: crossfade;
|
||||||
|
MenuButton menu_button {
|
||||||
|
icon-name: "view-more-symbolic";
|
||||||
|
margin-top: 6;
|
||||||
|
margin-bottom: 6;
|
||||||
|
margin-end: 6;
|
||||||
|
margin-start: 6;
|
||||||
|
menu-model: game_options;
|
||||||
|
halign: end;
|
||||||
|
|
||||||
|
styles [
|
||||||
|
"flat",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Revealer title_revealer {
|
Revealer title_revealer {
|
||||||
transition-type: crossfade;
|
transition-type: crossfade;
|
||||||
reveal-child: true;
|
reveal-child: true;
|
||||||
@@ -51,22 +68,10 @@ template game : Box {
|
|||||||
hexpand: true;
|
hexpand: true;
|
||||||
halign: start;
|
halign: start;
|
||||||
margin-start: 12;
|
margin-start: 12;
|
||||||
|
margin-end: 12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuButton menu_button {
|
|
||||||
icon-name: "view-more-symbolic";
|
|
||||||
margin-top: 6;
|
|
||||||
margin-bottom: 6;
|
|
||||||
margin-end: 6;
|
|
||||||
margin-start: 6;
|
|
||||||
menu-model: game_options;
|
|
||||||
|
|
||||||
styles [
|
|
||||||
"flat",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 876 KiB After Width: | Height: | Size: 911 KiB |
21
src/game.py
21
src/game.py
@@ -32,6 +32,7 @@ class game(Gtk.Box):
|
|||||||
hidden_game_options = Gtk.Template.Child()
|
hidden_game_options = Gtk.Template.Child()
|
||||||
button_revealer = Gtk.Template.Child()
|
button_revealer = Gtk.Template.Child()
|
||||||
title_revealer = Gtk.Template.Child()
|
title_revealer = Gtk.Template.Child()
|
||||||
|
menu_revealer = Gtk.Template.Child()
|
||||||
|
|
||||||
def __init__(self, parent_widget, title, pixbuf, game_id, **kwargs):
|
def __init__(self, parent_widget, title, pixbuf, game_id, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
@@ -46,14 +47,24 @@ class game(Gtk.Box):
|
|||||||
|
|
||||||
self.event_contoller_motion = Gtk.EventControllerMotion.new()
|
self.event_contoller_motion = Gtk.EventControllerMotion.new()
|
||||||
self.overlay.add_controller(self.event_contoller_motion)
|
self.overlay.add_controller(self.event_contoller_motion)
|
||||||
|
self.overlay.set_measure_overlay(self.button_revealer, True)
|
||||||
|
self.overlay.set_measure_overlay(self.menu_revealer, True)
|
||||||
|
|
||||||
self.button_play.connect("clicked", self.launch_game)
|
self.button_play.connect("clicked", self.launch_game)
|
||||||
self.event_contoller_motion.connect("enter", self.toggle_show_play)
|
self.event_contoller_motion.connect("enter", self.show_play)
|
||||||
self.event_contoller_motion.connect("leave", self.toggle_show_play)
|
self.event_contoller_motion.connect("leave", self.hide_play)
|
||||||
|
self.menu_button.get_popover().connect("notify::visible", self.hide_play)
|
||||||
|
|
||||||
def toggle_show_play(self, widget, *args):
|
def show_play(self, widget, *args):
|
||||||
self.button_revealer.set_reveal_child(not self.button_revealer.get_reveal_child())
|
self.button_revealer.set_reveal_child(True)
|
||||||
self.title_revealer.set_reveal_child(not self.title_revealer.get_reveal_child())
|
self.title_revealer.set_reveal_child(False)
|
||||||
|
self.menu_revealer.set_reveal_child(True)
|
||||||
|
|
||||||
|
def hide_play(self, widget, *args):
|
||||||
|
if not self.menu_button.get_active():
|
||||||
|
self.button_revealer.set_reveal_child(False)
|
||||||
|
self.title_revealer.set_reveal_child(True)
|
||||||
|
self.menu_revealer.set_reveal_child(False)
|
||||||
|
|
||||||
def launch_game(self, widget):
|
def launch_game(self, widget):
|
||||||
self.parent_widget.set_active_game(None, None, self.game_id)
|
self.parent_widget.set_active_game(None, None, self.game_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user