mirror of
https://gitlab.com/liyaowhen/youtubecollector-git.git
synced 2026-10-01 01:12:59 +00:00
ytsearhbar expands upon having text
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Song {
|
||||||
|
class BackgroundContainer : Gtk.DrawingArea {
|
||||||
|
// WIP entirely
|
||||||
|
// TODO: make this able to
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ song_sources = [
|
|||||||
'playlist_object.vala',
|
'playlist_object.vala',
|
||||||
'widgets/new_playlist_popover.vala',
|
'widgets/new_playlist_popover.vala',
|
||||||
'widgets/yt_search.vala',
|
'widgets/yt_search.vala',
|
||||||
|
'background.vala',
|
||||||
]
|
]
|
||||||
|
|
||||||
song_deps = [
|
song_deps = [
|
||||||
|
|||||||
@@ -1,11 +1,25 @@
|
|||||||
namespace Song {
|
namespace Song {
|
||||||
|
public enum YtSearchBarStates {
|
||||||
|
ENLARGING,
|
||||||
|
SHRINKING,
|
||||||
|
NONE,
|
||||||
|
}
|
||||||
|
|
||||||
public class YtSearchBar : Gtk.Box {
|
public class YtSearchBar : Gtk.Box {
|
||||||
|
|
||||||
private Gtk.SearchEntry search_entry = new Gtk.SearchEntry ();
|
private Gtk.SearchEntry search_entry = new Gtk.SearchEntry ();
|
||||||
private MainViewActionBar container_parent;
|
private MainViewActionBar container_parent;
|
||||||
private Adw.Clamp search_clamp = new Adw.Clamp();
|
private Adw.Clamp search_clamp = new Adw.Clamp();
|
||||||
|
|
||||||
|
private int min_width = 0;
|
||||||
|
private int? max_width;
|
||||||
|
|
||||||
|
private YtSearchBarStates state = YtSearchBarStates.NONE;
|
||||||
|
private bool isEnlarged = false;
|
||||||
|
|
||||||
|
private Adw.TimedAnimation? enlarge_animation = null;
|
||||||
|
private Adw.TimedAnimation? shrink_animation = null;
|
||||||
|
private Adw.AnimationTarget size_animation_target;
|
||||||
|
|
||||||
construct {
|
construct {
|
||||||
var gesture = new Gtk.GestureClick();
|
var gesture = new Gtk.GestureClick();
|
||||||
@@ -18,6 +32,58 @@ namespace Song {
|
|||||||
|
|
||||||
search_clamp.set_child(search_entry);
|
search_clamp.set_child(search_entry);
|
||||||
append(search_clamp);
|
append(search_clamp);
|
||||||
|
|
||||||
|
min_width = search_clamp.get_maximum_size ();
|
||||||
|
max_width = min_width + 200;
|
||||||
|
|
||||||
|
size_animation_target = new Adw.PropertyAnimationTarget(search_clamp, "maximum_size");
|
||||||
|
|
||||||
|
instanciate_signals();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void instanciate_signals() {
|
||||||
|
search_entry.changed.connect((e) => {
|
||||||
|
if (e.get_text() != null && state == YtSearchBarStates.NONE) {
|
||||||
|
if (e.get_text() != "" && !isEnlarged) {
|
||||||
|
enlarge();
|
||||||
|
} else if (e.get_text() == "" && isEnlarged) {
|
||||||
|
shrink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enlarge() {
|
||||||
|
if (enlarge_animation == null) {
|
||||||
|
enlarge_animation = new Adw.TimedAnimation(search_clamp, min_width, max_width, 500, size_animation_target);
|
||||||
|
enlarge_animation.done.connect(() => {
|
||||||
|
isEnlarged = true;
|
||||||
|
state = YtSearchBarStates.NONE;
|
||||||
|
print(state.to_string() + "\n");
|
||||||
|
print(isEnlarged.to_string() + "\n");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
enlarge_animation.play();
|
||||||
|
state = YtSearchBarStates.ENLARGING;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shrink() {
|
||||||
|
if (shrink_animation == null) {
|
||||||
|
shrink_animation = new Adw.TimedAnimation(search_clamp, max_width, min_width, 500, size_animation_target);
|
||||||
|
shrink_animation.done.connect(() => {
|
||||||
|
isEnlarged = false;
|
||||||
|
state = YtSearchBarStates.NONE;
|
||||||
|
print(state.to_string() + "\n");
|
||||||
|
print(isEnlarged.to_string() + "\n");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
shrink_animation.play();
|
||||||
|
state = YtSearchBarStates.SHRINKING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,12 +91,9 @@ namespace Song {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
set_content(_content);
|
set_content(_content);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void new_music_popover_show() {
|
public void new_music_popover_show() {
|
||||||
|
|||||||
Reference in New Issue
Block a user