1// Aseprite
2// Copyright (C) 2018 Igara Studio S.A.
3// Copyright (C) 2001-2016 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifndef APP_UI_RECENT_LISTBOX_H_INCLUDED
9#define APP_UI_RECENT_LISTBOX_H_INCLUDED
10#pragma once
11
12#include "base/paths.h"
13#include "obs/connection.h"
14#include "ui/listbox.h"
15#include "ui/view.h"
16
17namespace app {
18
19 class RecentFileItem;
20
21 class RecentListBox : public ui::ListBox,
22 public ui::ViewableWidget {
23 friend class RecentFileItem;
24 public:
25 RecentListBox();
26
27 void updateRecentListFromUIItems();
28
29 protected:
30 // ui::ViewableWidget impl
31 virtual void onScrollRegion(ui::ScrollRegionEvent& ev);
32
33 virtual void onRebuildList() = 0;
34 virtual void onClick(const std::string& path) = 0;
35 virtual void onUpdateRecentListFromUIItems(const base::paths& pinnedPaths,
36 const base::paths& recentPaths) = 0;
37
38 private:
39 void rebuildList();
40
41 obs::scoped_connection m_recentFilesConn;
42 obs::scoped_connection m_showFullPathConn;
43 };
44
45 class RecentFilesListBox : public RecentListBox {
46 public:
47 RecentFilesListBox();
48
49 private:
50 void onRebuildList() override;
51 void onClick(const std::string& path) override;
52 void onUpdateRecentListFromUIItems(const base::paths& pinnedPaths,
53 const base::paths& recentPaths) override;
54 };
55
56 class RecentFoldersListBox : public RecentListBox {
57 public:
58 RecentFoldersListBox();
59
60 private:
61 void onRebuildList() override;
62 void onClick(const std::string& path) override;
63 void onUpdateRecentListFromUIItems(const base::paths& pinnedPaths,
64 const base::paths& recentPaths) override;
65 };
66
67} // namespace app
68
69#endif
70