diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-09 23:03:34 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-09 23:03:34 +0300 |
commit | cfcd6bd672829edfbb325e3d264570c034ccc0f1 (patch) | |
tree | d899e48469aa3a48a75e4ef8a31874608d61809a /src/ui/window.c | |
parent | a5407bb3026da0972be19dfc89bb59dac6d5ee0c (diff) |
Closing and duplicating tabs
Diffstat (limited to 'src/ui/window.c')
-rw-r--r-- | src/ui/window.c | 171 |
1 files changed, 21 insertions, 150 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index bc690426..296b8d05 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -140,6 +140,16 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | |||
140 | updateTextCStr_LabelWidget(findChild_Widget(navBar, "reload"), | 140 | updateTextCStr_LabelWidget(findChild_Widget(navBar, "reload"), |
141 | isRequestOngoing_DocumentWidget(doc) ? stopCStr_ : reloadCStr_); | 141 | isRequestOngoing_DocumentWidget(doc) ? stopCStr_ : reloadCStr_); |
142 | } | 142 | } |
143 | else if (equal_Command(cmd, "mouse.clicked")) { | ||
144 | iWidget *widget = pointer_Command(cmd); | ||
145 | iWidget *menu = findWidget_App("doctabs.menu"); | ||
146 | if (isTabButton_Widget(widget)) { | ||
147 | iWidget *tabs = findWidget_App("doctabs"); | ||
148 | showTabPage_Widget(tabs, | ||
149 | tabPage_Widget(tabs, childIndex_Widget(widget->parent, widget))); | ||
150 | openMenu_Widget(menu, coord_Command(cmd)); | ||
151 | } | ||
152 | } | ||
143 | else if (equal_Command(cmd, "navigate.reload")) { | 153 | else if (equal_Command(cmd, "navigate.reload")) { |
144 | iDocumentWidget *doc = document_Command(cmd); | 154 | iDocumentWidget *doc = document_Command(cmd); |
145 | if (isRequestOngoing_DocumentWidget(doc)) { | 155 | if (isRequestOngoing_DocumentWidget(doc)) { |
@@ -265,156 +275,17 @@ static void setupUserInterface_Window(iWindow *d) { | |||
265 | addChild_Widget(searchBar, iClob(newIcon_LabelWidget(" \u2b9d ", 'g', KMOD_PRIMARY | KMOD_SHIFT, "find.prev"))); | 275 | addChild_Widget(searchBar, iClob(newIcon_LabelWidget(" \u2b9d ", 'g', KMOD_PRIMARY | KMOD_SHIFT, "find.prev"))); |
266 | addChild_Widget(searchBar, iClob(newIcon_LabelWidget("\u2a2f", SDLK_ESCAPE, 0, "find.close"))); | 276 | addChild_Widget(searchBar, iClob(newIcon_LabelWidget("\u2a2f", SDLK_ESCAPE, 0, "find.close"))); |
267 | } | 277 | } |
268 | 278 | iWidget *tabsMenu = makeMenu_Widget(d->root, | |
269 | #if 0 | 279 | (iMenuItem[]){ |
270 | iWidget *mainDiv = makeHDiv_Widget(); | 280 | { "Close Tab", 0, 0, "tabs.close" }, |
271 | setId_Widget(mainDiv, "maindiv"); | 281 | { "Duplicate Tab", 0, 0, "tabs.new duplicate:1" }, |
272 | addChild_Widget(d->root, iClob(mainDiv)); | 282 | { "---", 0, 0, NULL }, |
273 | 283 | { "Close Other Tabs", 0, 0, "tabs.close toleft:1 toright:1" }, | |
274 | iWidget *sidebar = makeVDiv_Widget(); | 284 | { "Close Tabs To Left", 0, 0, "tabs.close toleft:1" }, |
275 | setFlags_Widget(sidebar, arrangeWidth_WidgetFlag, iTrue); | 285 | { "Close Tabs To Right", 0, 0, "tabs.close toright:1" }, |
276 | setId_Widget(sidebar, "sidebar"); | 286 | }, |
277 | addChild_Widget(mainDiv, iClob(sidebar)); | 287 | 6); |
278 | 288 | setId_Widget(tabsMenu, "doctabs.menu"); | |
279 | /* Menus. */ { | ||
280 | #if defined (iPlatformApple) && !defined (iPlatformIOS) | ||
281 | /* Use the native menus. */ | ||
282 | insertMenuItems_MacOS("File", fileMenuItems, iElemCount(fileMenuItems)); | ||
283 | insertMenuItems_MacOS("Edit", editMenuItems, iElemCount(editMenuItems)); | ||
284 | insertMenuItems_MacOS("View", viewMenuItems, iElemCount(viewMenuItems)); | ||
285 | #else | ||
286 | iWidget *menubar = new_Widget(); | ||
287 | setBackgroundColor_Widget(menubar, gray25_ColorId); | ||
288 | setFlags_Widget(menubar, arrangeHorizontal_WidgetFlag | arrangeHeight_WidgetFlag, iTrue); | ||
289 | addChild_Widget(menubar, iClob(makeMenuButton_LabelWidget("File", fileMenuItems, iElemCount(fileMenuItems)))); | ||
290 | addChild_Widget(menubar, iClob(makeMenuButton_LabelWidget("Edit", editMenuItems, iElemCount(editMenuItems)))); | ||
291 | addChild_Widget(menubar, iClob(makeMenuButton_LabelWidget("View", viewMenuItems, iElemCount(viewMenuItems)))); | ||
292 | addChild_Widget(sidebar, iClob(menubar)); | ||
293 | #endif | ||
294 | } | ||
295 | /* Tracker info. */ { | ||
296 | iWidget *trackerInfo = addChild_Widget(sidebar, iClob(new_Widget())); | ||
297 | setId_Widget(trackerInfo, "trackerinfo"); | ||
298 | trackerInfo->rect.size.y = lineHeight_Text(default_FontId) + 2 * gap_UI; | ||
299 | setFlags_Widget(trackerInfo, arrangeHorizontal_WidgetFlag | resizeChildren_WidgetFlag, iTrue); | ||
300 | setId_Widget( | ||
301 | addChild_Widget(trackerInfo, iClob(new_LabelWidget("", 'p', KMOD_PRIMARY, "pattern.goto arg:-1"))), | ||
302 | "trackerinfo.current"); | ||
303 | iLabelWidget *dims = new_LabelWidget("", 'r', KMOD_PRIMARY | KMOD_ALT, "pattern.resize"); | ||
304 | setId_Widget(addChild_Widget(trackerInfo, iClob(dims)), "trackerinfo.dims"); | ||
305 | } | ||
306 | |||
307 | iLibraryWidget *lib = new_LibraryWidget(); | ||
308 | setId_Widget(as_Widget(lib), "library"); | ||
309 | addChildFlags_Widget(sidebar, iClob(lib), expand_WidgetFlag); | ||
310 | |||
311 | iPlaybackWidget *play = new_PlaybackWidget(); | ||
312 | setId_Widget(as_Widget(play), "playback"); | ||
313 | addChild_Widget(sidebar, iClob(play)); | ||
314 | |||
315 | iWidget *mainTabs = makeTabs_Widget(mainDiv); | ||
316 | setId_Widget(mainTabs, "maintabs"); | ||
317 | setFlags_Widget(mainTabs, expand_WidgetFlag, iTrue); | ||
318 | |||
319 | /* Optional sidebar on the right. */ | ||
320 | iWidget *sidebar2 = new_Widget(); | ||
321 | setId_Widget(addChild_Widget(mainDiv, iClob(sidebar2)), "sidebar2"); | ||
322 | setFlags_Widget( | ||
323 | sidebar2, fixedWidth_WidgetFlag | frameless_WidgetFlag | resizeChildren_WidgetFlag, iTrue); | ||
324 | |||
325 | /* Pattern sequence. */ { | ||
326 | iSequenceWidget *seq = new_SequenceWidget(); | ||
327 | appendTabPage_Widget(mainTabs, iClob(seq), "SEQUENCE", 0, 0); | ||
328 | } | ||
329 | /* Tracker. */ { | ||
330 | iTrackerWidget *tracker = new_TrackerWidget(); | ||
331 | appendTabPage_Widget(mainTabs, as_Widget(tracker), "PATTERN", 0, 0); | ||
332 | } | ||
333 | /* Voice editor. */ { | ||
334 | iWidget *voice = as_Widget(new_VoiceWidget()); | ||
335 | setId_Widget(voice, "voicelayers"); | ||
336 | appendTabPage_Widget(mainTabs, iClob(voice), "VOICE", '3', KMOD_PRIMARY); | ||
337 | } | ||
338 | /* Song information. */ { | ||
339 | iWidget *songPage = new_Widget(); | ||
340 | setId_Widget(songPage, "songinfo"); | ||
341 | setFlags_Widget(songPage, arrangeHorizontal_WidgetFlag, iTrue); | ||
342 | iWidget *headings = | ||
343 | addChildFlags_Widget(songPage, | ||
344 | iClob(new_Widget()), | ||
345 | resizeToParentHeight_WidgetFlag | resizeChildren_WidgetFlag | | ||
346 | arrangeVertical_WidgetFlag | arrangeWidth_WidgetFlag); | ||
347 | iWidget *values = addChildFlags_Widget( | ||
348 | songPage, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); | ||
349 | |||
350 | setId_Widget(addChild_Widget(headings, iClob(makePadding_Widget(2 * gap_UI))), "headings.padding"); | ||
351 | setId_Widget(addChild_Widget(values, iClob(makePadding_Widget(2 * gap_UI))), "values.padding"); | ||
352 | |||
353 | addChild_Widget(headings, iClob(makeHeading_Widget(cyan_ColorEscape "SONG PROPERTIES"))); | ||
354 | addChild_Widget(values, iClob(makeHeading_Widget(""))); | ||
355 | |||
356 | const int fieldWidth = advance_Text(monospace_FontId, "A").x * 40; | ||
357 | iWidget *field; | ||
358 | |||
359 | addChild_Widget(headings, iClob(makeHeading_Widget("Title:"))); | ||
360 | setId_Widget(field = addChild_Widget(values, iClob(new_InputWidget(0))), "info.title"); | ||
361 | field->rect.size.x = fieldWidth; | ||
362 | |||
363 | addChild_Widget(headings, iClob(makeHeading_Widget("Author:"))); | ||
364 | setId_Widget(field = addChild_Widget(values, iClob(new_InputWidget(0))), "info.author"); | ||
365 | field->rect.size.x = fieldWidth; | ||
366 | |||
367 | addChild_Widget(headings, iClob(makeHeading_Widget("Tempo:"))); | ||
368 | setId_Widget(addChild_Widget(values, iClob(new_InputWidget(3))), "info.tempo"); | ||
369 | |||
370 | addChild_Widget(headings, iClob(makeHeading_Widget("Events per Beat:"))); | ||
371 | setId_Widget(addChild_Widget(values, iClob(new_InputWidget(2))), "info.eventsperbeat"); | ||
372 | |||
373 | addChild_Widget(headings, iClob(makeHeading_Widget("Num of Tracks:"))); | ||
374 | setId_Widget(addChild_Widget(values, iClob(new_InputWidget(2))), "info.numtracks"); | ||
375 | |||
376 | addChild_Widget(headings, iClob(makePadding_Widget(2 * gap_UI))); | ||
377 | addChild_Widget(values, iClob(makePadding_Widget(2 * gap_UI))); | ||
378 | |||
379 | addChild_Widget(headings, iClob(makeHeading_Widget(cyan_ColorEscape "SONG METADATA"))); | ||
380 | addChild_Widget(values, iClob(makeHeading_Widget(""))); | ||
381 | |||
382 | addChild_Widget(headings, iClob(makeHeading_Widget("Duration:"))); | ||
383 | setId_Widget(addChildFlags_Widget(values, iClob(newEmpty_LabelWidget()), | ||
384 | alignLeft_WidgetFlag | frameless_WidgetFlag), | ||
385 | "info.duration"); | ||
386 | addChild_Widget(headings, iClob(makeHeading_Widget("Statistics:\n\n "))); | ||
387 | setId_Widget(addChildFlags_Widget(values, | ||
388 | iClob(newEmpty_LabelWidget()), | ||
389 | alignLeft_WidgetFlag | frameless_WidgetFlag), | ||
390 | "info.statistics"); | ||
391 | addChild_Widget(headings, iClob(makeHeading_Widget("Created on:"))); | ||
392 | setId_Widget(addChildFlags_Widget(values, | ||
393 | iClob(newEmpty_LabelWidget()), | ||
394 | alignLeft_WidgetFlag | frameless_WidgetFlag), | ||
395 | "info.created"); | ||
396 | |||
397 | addChild_Widget(headings, iClob(makeHeading_Widget("Last Modified on:"))); | ||
398 | setId_Widget(addChildFlags_Widget(values, | ||
399 | iClob(newEmpty_LabelWidget()), | ||
400 | alignLeft_WidgetFlag | frameless_WidgetFlag), | ||
401 | "info.lastmodified"); | ||
402 | /* App info in the bottom. */ { | ||
403 | addChildFlags_Widget(headings, iClob(new_Widget()), expand_WidgetFlag); | ||
404 | addChildFlags_Widget( | ||
405 | headings, | ||
406 | iClob(new_LabelWidget(gray50_ColorEscape "Version " BWH_APP_VERSION, 0, 0, NULL)), | ||
407 | frameless_WidgetFlag | alignLeft_WidgetFlag); | ||
408 | } | ||
409 | appendTabPage_Widget(mainTabs, iClob(songPage), "INFO", '4', KMOD_PRIMARY); | ||
410 | } | ||
411 | /* Application status. */ { | ||
412 | iWidget *status = addChildFlags_Widget(d->root, iClob(newEmpty_LabelWidget()), 0); | ||
413 | setFont_LabelWidget((iLabelWidget *) status, monospace_FontId); | ||
414 | setFlags_Widget(status, frameless_WidgetFlag | alignRight_WidgetFlag, iTrue); | ||
415 | setId_Widget(status, "status"); | ||
416 | } | ||
417 | #endif | ||
418 | /* Glboal keyboard shortcuts. */ { | 289 | /* Glboal keyboard shortcuts. */ { |
419 | addAction_Widget(d->root, SDLK_LEFTBRACKET, KMOD_SHIFT | KMOD_PRIMARY, "tabs.prev"); | 290 | addAction_Widget(d->root, SDLK_LEFTBRACKET, KMOD_SHIFT | KMOD_PRIMARY, "tabs.prev"); |
420 | addAction_Widget(d->root, SDLK_RIGHTBRACKET, KMOD_SHIFT | KMOD_PRIMARY, "tabs.next"); | 291 | addAction_Widget(d->root, SDLK_RIGHTBRACKET, KMOD_SHIFT | KMOD_PRIMARY, "tabs.next"); |