About windows and replicant menu options
Gives the app and each replicant an "About" window. Also adds the "About…" and "Remove replicant" menu items from BDragger to the normal right-click menu.
This commit is contained in:
parent
bf02ce442e
commit
00f9ecb0cb
4
Makefile
4
Makefile
|
@ -38,6 +38,7 @@ SRCS = src/App.cpp \
|
|||
src/MediaPlayer.cpp \
|
||||
src/ReplicantView.cpp \
|
||||
src/Song.cpp \
|
||||
src/Util.cpp \
|
||||
src/VolumeView.cpp \
|
||||
src/thirdparty/PlayPauseButton.cpp \
|
||||
src/thirdparty/SymbolButton.cpp \
|
||||
|
@ -79,7 +80,8 @@ LIBPATHS =
|
|||
# Additional paths to look for system headers. These use the form
|
||||
# "#include <header>". Directories that contain the files in SRCS are
|
||||
# NOT auto-included here.
|
||||
SYSTEM_INCLUDE_PATHS =
|
||||
SYSTEM_INCLUDE_PATHS = \
|
||||
$(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY private/interface)
|
||||
|
||||
# Additional paths paths to look for local headers. These use the form
|
||||
# #include "header". Directories that contain the files in SRCS are
|
||||
|
|
12
src/App.cpp
12
src/App.cpp
|
@ -5,7 +5,10 @@
|
|||
|
||||
#include "App.h"
|
||||
|
||||
#include <AboutWindow.h>
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Util.h"
|
||||
|
||||
|
||||
App::App()
|
||||
|
@ -13,11 +16,18 @@ App::App()
|
|||
BApplication(APP_SIGNATURE)
|
||||
{
|
||||
MainWindow* win = new MainWindow();
|
||||
win->SetPulseRate(2500000);
|
||||
win->SetPulseRate(1250000);
|
||||
win->Show();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
App::AboutRequested()
|
||||
{
|
||||
show_about_window(NULL);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,8 @@ class App: public BApplication
|
|||
{
|
||||
public:
|
||||
App();
|
||||
|
||||
virtual void AboutRequested();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -14,12 +14,15 @@
|
|||
|
||||
|
||||
const uint32 COVER_MAKE_SQUARE = 'cvsq';
|
||||
const char* kCoverDesc = "CoverView is a replicant that shows a thumbnail for whatever is playing― often an album cover taken from a 'cover.jpg' or similar file.";
|
||||
|
||||
|
||||
CoverView::CoverView(BRect frame)
|
||||
:
|
||||
ReplicantView(frame, "Cover", B_FOLLOW_RIGHT, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
|
||||
{
|
||||
fDescription.SetTo(kCoverDesc);
|
||||
|
||||
SetViewColor(B_TRANSPARENT_COLOR);
|
||||
fCover = NULL;
|
||||
Pulse();
|
||||
|
@ -30,6 +33,8 @@ CoverView::CoverView(BMessage* data)
|
|||
:
|
||||
ReplicantView(data)
|
||||
{
|
||||
fDescription.SetTo(kCoverDesc);
|
||||
|
||||
SetViewColor(B_TRANSPARENT_COLOR);
|
||||
fCover = NULL;
|
||||
Pulse();
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
#include "MediaPlayer.h"
|
||||
|
||||
|
||||
const char* kLyricsDesc = "LyricsView is a replicant that shows a transcription for the playing media. Usually this means lyrics to a song, stored in 'songFile.mp3.txt' or similar.";
|
||||
|
||||
|
||||
LyricsTextView::LyricsTextView(BRect frame, const char* name, BRect textFrame,
|
||||
uint32 resize, uint32 flags)
|
||||
:
|
||||
|
@ -65,6 +68,8 @@ LyricsView::LyricsView(BRect frame)
|
|||
:
|
||||
ReplicantView(frame, "Lyrics", B_FOLLOW_LEFT)
|
||||
{
|
||||
fDescription.SetTo(kLyricsDesc);
|
||||
|
||||
BRect textRect(0, 0, Bounds().Width(), Bounds().Height() - 10);
|
||||
fTextView = new LyricsTextView(textRect, "lyricsText", textRect,
|
||||
B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
|
@ -89,6 +94,7 @@ LyricsView::LyricsView(BMessage* data)
|
|||
:
|
||||
ReplicantView(data)
|
||||
{
|
||||
fDescription.SetTo(kLyricsDesc);
|
||||
fAutoScroll = false;
|
||||
|
||||
fFgColor = ui_color(B_PANEL_TEXT_COLOR);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <Window.h>
|
||||
|
||||
#include "MediaPlayer.h"
|
||||
#include "Util.h"
|
||||
|
||||
|
||||
ReplicantView::ReplicantView(BRect frame, const char* name, uint32 draggerPlacement, uint32 resize,
|
||||
|
@ -29,9 +30,11 @@ ReplicantView::ReplicantView(BRect frame, const char* name, uint32 draggerPlacem
|
|||
fDragger->SetViewColor(B_TRANSPARENT_COLOR);
|
||||
AddChild(fDragger);
|
||||
|
||||
fInactive = true;
|
||||
fReplicated = false;
|
||||
|
||||
fTransparentInactivity = false;
|
||||
fTransparentDragger = false;
|
||||
fInactive = true;
|
||||
|
||||
fMediaPlayer = new MediaPlayer(0);
|
||||
}
|
||||
|
@ -49,7 +52,9 @@ ReplicantView::ReplicantView(BMessage* data)
|
|||
|
||||
fTransparentInactivity = data->GetBool("transparent_inactivity", true);
|
||||
fTransparentDragger = data->GetBool("transparent_dragger", false);
|
||||
|
||||
fInactive = true;
|
||||
fReplicated = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,6 +98,9 @@ ReplicantView::MessageReceived(BMessage* msg)
|
|||
SetInactive(fInactive);
|
||||
break;
|
||||
}
|
||||
case B_ABOUT_REQUESTED:
|
||||
show_about_window(fDescription.String());
|
||||
break;
|
||||
default:
|
||||
BView::MessageReceived(msg);
|
||||
break;
|
||||
|
@ -140,6 +148,20 @@ ReplicantView::RightClickPopUp(BPopUpMenu* menu)
|
|||
hideDragger->SetTarget(this);
|
||||
hideMenu->AddItem(hideDragger);
|
||||
|
||||
menu->AddSeparatorItem();
|
||||
|
||||
BString aboutLabel = "About %replicant" B_UTF8_ELLIPSIS;
|
||||
aboutLabel.ReplaceAll("%replicant", Name());
|
||||
BMenuItem* aboutItem = new BMenuItem(aboutLabel, new BMessage(B_ABOUT_REQUESTED));
|
||||
aboutItem->SetTarget(this);
|
||||
menu->AddItem(aboutItem);
|
||||
|
||||
if (fReplicated) {
|
||||
BMenuItem* removeItem = new BMenuItem("Remove replicant", new BMessage(B_TRASH_TARGET));
|
||||
removeItem->SetTarget(fDragger);
|
||||
menu->AddItem(removeItem);
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,10 +53,15 @@ public:
|
|||
// Set inactivity state, re-render accordingly
|
||||
virtual void SetInactive(bool inactive);
|
||||
|
||||
protected:
|
||||
MediaPlayer* fMediaPlayer;
|
||||
BDragger* fDragger;
|
||||
|
||||
BString fDescription;
|
||||
|
||||
bool fReplicated;
|
||||
bool fInactive;
|
||||
|
||||
bool fTransparentInactivity;
|
||||
bool fTransparentDragger;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright 2022, Jaidyn Levesque <jadedctrl@teknik.io>
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*/
|
||||
|
||||
#include "Util.h"
|
||||
|
||||
#include <AboutWindow.h>
|
||||
|
||||
|
||||
void
|
||||
show_about_window(const char* description)
|
||||
{
|
||||
const char* authors[] = {
|
||||
"Stephan Aßmus",
|
||||
"DarkWyrm",
|
||||
"Jaidyn Levesque",
|
||||
NULL
|
||||
};
|
||||
|
||||
BAboutWindow* about = new BAboutWindow(APP_NAME, APP_SIGNATURE);
|
||||
about->AddDescription("A collection of simple MediaPlayer replicants.");
|
||||
if (description != NULL)
|
||||
about->AddDescription(description);
|
||||
about->AddAuthors(authors);
|
||||
about->AddCopyright(2022, "Jaidyn Levesque");
|
||||
about->Show();
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright 2022, Jaidyn Levesque <jadedctrl@teknik.io>
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*/
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
void show_about_window(const char* description);
|
||||
|
||||
#endif // UTIL_H
|
|
@ -12,6 +12,9 @@
|
|||
#include "MediaPlayer.h"
|
||||
|
||||
|
||||
const char* kVolumeDesc = "VolumeView is a replicant that can monitor and change the volume of MediaPlayer.";
|
||||
|
||||
|
||||
// The same color MediaPlayer uses, interface/VolumeSlider
|
||||
static const rgb_color kVolumeGreen = (rgb_color){ 116, 224, 0, 255 };
|
||||
|
||||
|
@ -22,6 +25,8 @@ VolumeView::VolumeView(BRect frame)
|
|||
:
|
||||
ReplicantView(frame, "Volume", B_FOLLOW_RIGHT, B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS)
|
||||
{
|
||||
fDescription.SetTo(kVolumeDesc);
|
||||
|
||||
_InitInterface();
|
||||
Pulse();
|
||||
}
|
||||
|
@ -31,6 +36,8 @@ VolumeView::VolumeView(BMessage* data)
|
|||
:
|
||||
ReplicantView(data)
|
||||
{
|
||||
fDescription.SetTo(kVolumeDesc);
|
||||
|
||||
// For some reason, the BSlider gets archived with a wacko frame― better to just nuke it.
|
||||
fSlider = dynamic_cast<BSlider*>(FindView("volumeSlider"));
|
||||
delete fSlider;
|
||||
|
|
Ŝarĝante…
Reference in New Issue