65 const wxColour bgColour(42, 42, 42);
66 const wxColour btnNormal(60, 60, 60);
67 const wxColour btnHover(80, 80, 80);
68 const wxColour btnPressed(45, 45, 45);
69 const wxColour entryNormal(50, 50, 50);
70 const wxColour entryHover(65, 65, 65);
71 const wxColour entryPressed(40, 40, 40);
73 auto *panel =
new wxPanel(
m_book, wxID_ANY);
74 panel->SetBackgroundColour(bgColour);
76 auto *rootSizer =
new wxBoxSizer(wxVERTICAL);
77 rootSizer->AddStretchSpacer(1);
79 auto *centerSizer =
new wxBoxSizer(wxVERTICAL);
82 auto bindButtonHighlight = [=](wxButton *btn) {
83 btn->Bind(wxEVT_ENTER_WINDOW, [btn, btnHover](wxMouseEvent &e) {
84 btn->SetBackgroundColour(btnHover);
88 btn->Bind(wxEVT_LEAVE_WINDOW, [btn, btnNormal](wxMouseEvent &e) {
89 btn->SetBackgroundColour(btnNormal);
93 btn->Bind(wxEVT_LEFT_DOWN, [btn, btnPressed](wxMouseEvent &e) {
94 btn->SetBackgroundColour(btnPressed);
98 btn->Bind(wxEVT_LEFT_UP, [btn, btnHover](wxMouseEvent &e) {
99 btn->SetBackgroundColour(btnHover);
105 auto makeButton = [&](wxPanel *parent,
const wxString &label) -> wxButton * {
106 auto *btn =
new wxButton(parent, wxID_ANY, label, wxDefaultPosition, wxSize(220, 36));
107 btn->SetBackgroundColour(btnNormal);
108 btn->SetForegroundColour(wxColour(210, 210, 210));
109 btn->SetFont(wxFont(11, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
110 btn->SetCursor(wxCursor(wxCURSOR_HAND));
111 bindButtonHighlight(btn);
115 auto *newProjectBtn = makeButton(panel,
"New Project");
116 centerSizer->Add(newProjectBtn, 0, wxALIGN_CENTER_HORIZONTAL);
118 auto *openProjectBtn = makeButton(panel,
"Open Project");
119 centerSizer->Add(openProjectBtn, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, 6);
121 auto *docsBtn = makeButton(panel,
"Documentation");
122 centerSizer->Add(docsBtn, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, 6);
124 newProjectBtn->Bind(wxEVT_BUTTON, [
this](wxCommandEvent &) {
128 openProjectBtn->Bind(wxEVT_BUTTON, [
this](wxCommandEvent &) {
132 docsBtn->Bind(wxEVT_BUTTON, [
this](wxCommandEvent &) {
137 centerSizer->AddSpacer(30);
140 auto *recentHeader =
new wxStaticText(panel, wxID_ANY,
"Recent Projects");
141 recentHeader->SetForegroundColour(wxColour(180, 180, 180));
142 recentHeader->SetFont(wxFont(12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
143 centerSizer->Add(recentHeader, 0, wxALIGN_CENTER_HORIZONTAL);
145 auto *line =
new wxStaticLine(panel, wxID_ANY, wxDefaultPosition, wxSize(300, 1));
146 centerSizer->Add(line, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP | wxBOTTOM, 6);
150 if (recentProjects.empty()) {
151 auto *emptyLabel =
new wxStaticText(panel, wxID_ANY,
"No recent projects");
152 emptyLabel->SetForegroundColour(wxColour(100, 100, 100));
153 emptyLabel->SetFont(wxFont(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_NORMAL));
154 centerSizer->Add(emptyLabel, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, 4);
156 auto bindEntryHighlight = [=](wxPanel *ep) {
157 ep->Bind(wxEVT_ENTER_WINDOW, [ep, entryHover](wxMouseEvent &e) {
158 ep->SetBackgroundColour(entryHover);
162 ep->Bind(wxEVT_LEAVE_WINDOW, [ep, entryNormal](wxMouseEvent &e) {
163 ep->SetBackgroundColour(entryNormal);
167 ep->Bind(wxEVT_LEFT_DOWN, [ep, entryPressed](wxMouseEvent &e) {
168 ep->SetBackgroundColour(entryPressed);
172 ep->Bind(wxEVT_LEFT_UP, [ep, entryHover](wxMouseEvent &e) {
173 ep->SetBackgroundColour(entryHover);
179 for (
const auto &projectPath : recentProjects) {
180 wxFileName fn(wxString::FromUTF8(projectPath));
181 wxString projectName = fn.GetName();
182 wxString displayPath = fn.GetFullPath();
184 auto *entryPanel =
new wxPanel(panel, wxID_ANY);
185 entryPanel->SetBackgroundColour(entryNormal);
186 entryPanel->SetMinSize(wxSize(400, -1));
188 auto *entrySizer =
new wxBoxSizer(wxVERTICAL);
190 auto *nameLabel =
new wxStaticText(entryPanel, wxID_ANY, projectName);
191 nameLabel->SetForegroundColour(wxColour(100, 180, 255));
192 nameLabel->SetFont(wxFont(11, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
193 entrySizer->Add(nameLabel, 0, wxLEFT | wxTOP, 6);
195 auto *pathLabel =
new wxStaticText(entryPanel, wxID_ANY, displayPath);
196 pathLabel->SetForegroundColour(wxColour(120, 120, 120));
197 pathLabel->SetFont(wxFont(8, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
198 entrySizer->Add(pathLabel, 0, wxLEFT | wxBOTTOM, 6);
200 entryPanel->SetSizer(entrySizer);
202 std::string path = projectPath;
203 entryPanel->SetCursor(wxCursor(wxCURSOR_HAND));
204 nameLabel->SetCursor(wxCursor(wxCURSOR_HAND));
205 pathLabel->SetCursor(wxCursor(wxCURSOR_HAND));
207 bindEntryHighlight(entryPanel);
209 auto clickHandler = [
this, path](wxMouseEvent &e) {
214 entryPanel->Bind(wxEVT_LEFT_UP, clickHandler);
215 nameLabel->Bind(wxEVT_LEFT_UP, clickHandler);
216 pathLabel->Bind(wxEVT_LEFT_UP, clickHandler);
219 nameLabel->Bind(wxEVT_ENTER_WINDOW, [entryPanel, entryHover](wxMouseEvent &e) {
220 entryPanel->SetBackgroundColour(entryHover);
221 entryPanel->Refresh();
224 nameLabel->Bind(wxEVT_LEAVE_WINDOW, [entryPanel, entryNormal](wxMouseEvent &e) {
225 wxPoint pos = entryPanel->ScreenToClient(wxGetMousePosition());
226 if (!entryPanel->GetRect().Contains(entryPanel->GetPosition() + pos))
227 entryPanel->SetBackgroundColour(entryNormal);
228 entryPanel->Refresh();
231 pathLabel->Bind(wxEVT_ENTER_WINDOW, [entryPanel, entryHover](wxMouseEvent &e) {
232 entryPanel->SetBackgroundColour(entryHover);
233 entryPanel->Refresh();
236 pathLabel->Bind(wxEVT_LEAVE_WINDOW, [entryPanel, entryNormal](wxMouseEvent &e) {
237 wxPoint pos = entryPanel->ScreenToClient(wxGetMousePosition());
238 if (!entryPanel->GetRect().Contains(entryPanel->GetPosition() + pos))
239 entryPanel->SetBackgroundColour(entryNormal);
240 entryPanel->Refresh();
244 centerSizer->Add(entryPanel, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, 4);
248 rootSizer->Add(centerSizer, 0, wxALIGN_CENTER_HORIZONTAL);
249 rootSizer->AddStretchSpacer(1);
252 auto *versionLabel =
new wxStaticText(panel, wxID_ANY,
"v1.0.0");
253 versionLabel->SetForegroundColour(wxColour(100, 100, 100));
254 versionLabel->SetFont(wxFont(9, wxFONTFAMILY_SWISS, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_NORMAL));
255 rootSizer->Add(versionLabel, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 10);
257 panel->SetSizer(rootSizer);