diff options
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 9d94f200..bbe5ccba 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -191,6 +191,7 @@ struct Impl_DocumentWidget { | |||
191 | iAnim outlineOpacity; | 191 | iAnim outlineOpacity; |
192 | iArray outline; | 192 | iArray outline; |
193 | iWidget * menu; | 193 | iWidget * menu; |
194 | iWidget * playerMenu; | ||
194 | iVisBuf * visBuf; | 195 | iVisBuf * visBuf; |
195 | iPtrSet * invalidRuns; | 196 | iPtrSet * invalidRuns; |
196 | }; | 197 | }; |
@@ -241,6 +242,7 @@ void init_DocumentWidget(iDocumentWidget *d) { | |||
241 | init_Click(&d->click, d, SDL_BUTTON_LEFT); | 242 | init_Click(&d->click, d, SDL_BUTTON_LEFT); |
242 | addChild_Widget(w, iClob(d->scroll = new_ScrollWidget())); | 243 | addChild_Widget(w, iClob(d->scroll = new_ScrollWidget())); |
243 | d->menu = NULL; /* created when clicking */ | 244 | d->menu = NULL; /* created when clicking */ |
245 | d->playerMenu = NULL; | ||
244 | #if !defined (iPlatformApple) /* in system menu */ | 246 | #if !defined (iPlatformApple) /* in system menu */ |
245 | addAction_Widget(w, reload_KeyShortcut, "navigate.reload"); | 247 | addAction_Widget(w, reload_KeyShortcut, "navigate.reload"); |
246 | addAction_Widget(w, SDLK_w, KMOD_PRIMARY, "tabs.close"); | 248 | addAction_Widget(w, SDLK_w, KMOD_PRIMARY, "tabs.close"); |
@@ -249,7 +251,10 @@ void init_DocumentWidget(iDocumentWidget *d) { | |||
249 | addAction_Widget(w, navigateForward_KeyShortcut, "navigate.forward"); | 251 | addAction_Widget(w, navigateForward_KeyShortcut, "navigate.forward"); |
250 | } | 252 | } |
251 | 253 | ||
254 | static void animatePlayingAudio_DocumentWidget_(void *); | ||
255 | |||
252 | void deinit_DocumentWidget(iDocumentWidget *d) { | 256 | void deinit_DocumentWidget(iDocumentWidget *d) { |
257 | removeTicker_App(animatePlayingAudio_DocumentWidget_, d); | ||
253 | delete_VisBuf(d->visBuf); | 258 | delete_VisBuf(d->visBuf); |
254 | delete_PtrSet(d->invalidRuns); | 259 | delete_PtrSet(d->invalidRuns); |
255 | deinit_Array(&d->outline); | 260 | deinit_Array(&d->outline); |
@@ -1626,7 +1631,7 @@ static void drawPlayerButton_(iPaint *p, iRect rect, const char *label) { | |||
1626 | adjusted_Rect(shrunk_Rect(frameRect, divi_I2(gap2_UI, 2)), zero_I2(), one_I2()), | 1631 | adjusted_Rect(shrunk_Rect(frameRect, divi_I2(gap2_UI, 2)), zero_I2(), one_I2()), |
1627 | frame); | 1632 | frame); |
1628 | } | 1633 | } |
1629 | const int fg = isPressed ? uiBackground_ColorId : frame; | 1634 | const int fg = isPressed ? (permanent_ColorId | uiBackground_ColorId) : uiHeading_ColorId; |
1630 | drawCentered_Text(uiContent_FontId, frameRect, iTrue, fg, "%s", label); | 1635 | drawCentered_Text(uiContent_FontId, frameRect, iTrue, fg, "%s", label); |
1631 | } | 1636 | } |
1632 | 1637 | ||
@@ -1704,6 +1709,11 @@ static iBool processAudioPlayerEvents_DocumentWidget_(iDocumentWidget *d, const | |||
1704 | ev->type != SDL_MOUSEMOTION) { | 1709 | ev->type != SDL_MOUSEMOTION) { |
1705 | return iFalse; | 1710 | return iFalse; |
1706 | } | 1711 | } |
1712 | if (ev->type == SDL_MOUSEBUTTONDOWN || ev->type == SDL_MOUSEBUTTONUP) { | ||
1713 | if (ev->button.button != SDL_BUTTON_LEFT) { | ||
1714 | return iFalse; | ||
1715 | } | ||
1716 | } | ||
1707 | const iInt2 mouse = init_I2(ev->button.x, ev->button.y); | 1717 | const iInt2 mouse = init_I2(ev->button.x, ev->button.y); |
1708 | iConstForEach(PtrArray, i, &d->visiblePlayers) { | 1718 | iConstForEach(PtrArray, i, &d->visiblePlayers) { |
1709 | const iGmRun *run = i.ptr; | 1719 | const iGmRun *run = i.ptr; |
@@ -1722,12 +1732,34 @@ static iBool processAudioPlayerEvents_DocumentWidget_(iDocumentWidget *d, const | |||
1722 | return iTrue; | 1732 | return iTrue; |
1723 | } | 1733 | } |
1724 | else if (contains_Rect(ui.rewindRect, mouse)) { | 1734 | else if (contains_Rect(ui.rewindRect, mouse)) { |
1725 | stop_Player(plr); | 1735 | if (isStarted_Player(plr) && time_Player(plr) > 0.5f) { |
1726 | start_Player(plr); | 1736 | stop_Player(plr); |
1727 | setPaused_Player(plr, iTrue); | 1737 | start_Player(plr); |
1738 | setPaused_Player(plr, iTrue); | ||
1739 | } | ||
1728 | refresh_Widget(d); | 1740 | refresh_Widget(d); |
1729 | return iTrue; | 1741 | return iTrue; |
1730 | } | 1742 | } |
1743 | else if (contains_Rect(ui.menuRect, mouse)) { | ||
1744 | /* TODO: Add menu items for: | ||
1745 | - output device | ||
1746 | - Save to Downloads | ||
1747 | */ | ||
1748 | if (d->playerMenu) { | ||
1749 | destroy_Widget(d->playerMenu); | ||
1750 | d->playerMenu = NULL; | ||
1751 | return iTrue; | ||
1752 | } | ||
1753 | d->playerMenu = makeMenu_Widget( | ||
1754 | as_Widget(d), | ||
1755 | (iMenuItem[]){ | ||
1756 | { cstrCollect_String(metadataLabel_Player(plr)), 0, 0, NULL }, | ||
1757 | }, | ||
1758 | 1); | ||
1759 | openMenu_Widget(d->playerMenu, | ||
1760 | localCoord_Widget(constAs_Widget(d), bottomLeft_Rect(ui.menuRect))); | ||
1761 | return iTrue; | ||
1762 | } | ||
1731 | } | 1763 | } |
1732 | } | 1764 | } |
1733 | return iFalse; | 1765 | return iFalse; |