Add ScrollView to lyrics replicant

This commit is contained in:
Jaidyn Ann 2022-04-16 19:02:10 -05:00
parent 810f57dd7f
commit 50914809b6
2 changed files with 20 additions and 9 deletions

View File

@ -9,6 +9,7 @@
#include <Dragger.h> #include <Dragger.h>
#include <Messenger.h> #include <Messenger.h>
#include <ScrollView.h>
#include <TextView.h> #include <TextView.h>
#include "Song.h" #include "Song.h"
@ -21,15 +22,22 @@ LyricsView::LyricsView(BRect frame)
fFgColor = ui_color(B_PANEL_TEXT_COLOR); fFgColor = ui_color(B_PANEL_TEXT_COLOR);
fBgColor = ui_color(B_PANEL_BACKGROUND_COLOR); fBgColor = ui_color(B_PANEL_BACKGROUND_COLOR);
BDragger* airdrag = new BDragger(frame, this, BRect dragRect(0, 0, 10, frame.Height());
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW); BDragger* airdrag = new BDragger(dragRect, this,
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
airdrag->SetViewColor(B_TRANSPARENT_COLOR);
AddChild(airdrag); AddChild(airdrag);
fTextView = new BTextView(Bounds(), "lyricsText", Bounds(), BRect textRect(0, 0, Bounds().Width(), Bounds().Height() - 10);
fTextView = new BTextView(textRect, "lyricsText", textRect,
B_FOLLOW_ALL, B_WILL_DRAW); B_FOLLOW_ALL, B_WILL_DRAW);
fTextView->MakeEditable(false); fTextView->MakeEditable(false);
fTextView->SetStylable(false); fTextView->SetStylable(false);
AddChild(fTextView);
fScrollView = new BScrollView("scrollView", fTextView, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW, false, true, B_NO_BORDER);
fScrollView->ScrollBar(B_VERTICAL)->Hide();
AddChild(fScrollView);
_Init(frame); _Init(frame);
} }
@ -43,6 +51,7 @@ LyricsView::LyricsView(BMessage* data)
fBgColor = ui_color(B_PANEL_BACKGROUND_COLOR); fBgColor = ui_color(B_PANEL_BACKGROUND_COLOR);
fTextView = dynamic_cast<BTextView*>(FindView("lyricsText")); fTextView = dynamic_cast<BTextView*>(FindView("lyricsText"));
fScrollView = dynamic_cast<BScrollView*>(FindView("scrollView"));
data->FindColor("background_color", &fBgColor); data->FindColor("background_color", &fBgColor);
data->FindColor("foreground_color", &fFgColor); data->FindColor("foreground_color", &fFgColor);
@ -87,10 +96,8 @@ LyricsView::MessageReceived(BMessage* msg)
if (found_color == B_OK && msg->FindInt32("buttons", &buttons) == B_OK) if (found_color == B_OK && msg->FindInt32("buttons", &buttons) == B_OK)
if (buttons & B_PRIMARY_MOUSE_BUTTON) if (buttons & B_PRIMARY_MOUSE_BUTTON)
fBgColor = *recv_color; fBgColor = *recv_color;
else if (buttons & B_SECONDARY_MOUSE_BUTTON) { else if (buttons & B_SECONDARY_MOUSE_BUTTON)
printf("MOM\n");
fFgColor = *recv_color; fFgColor = *recv_color;
}
_UpdateColors(); _UpdateColors();
break; break;
@ -133,12 +140,10 @@ LyricsView::_SetText(const char* text)
if (fTextView->IsHidden() == true) if (fTextView->IsHidden() == true)
fTextView->Show(); fTextView->Show();
fTextView->SetText(text); fTextView->SetText(text);
printf("NOT NULL\n");
} else if (text == NULL) { } else if (text == NULL) {
if (fTextView->IsHidden() == false) if (fTextView->IsHidden() == false)
fTextView->Hide(); fTextView->Hide();
fTextView->SetText(""); fTextView->SetText("");
printf("NULL\n");
} }
} }
@ -147,6 +152,7 @@ void
LyricsView::_UpdateColors() LyricsView::_UpdateColors()
{ {
SetViewColor(B_TRANSPARENT_COLOR); SetViewColor(B_TRANSPARENT_COLOR);
fScrollView->SetViewColor(B_TRANSPARENT_COLOR);
fTextView->SetViewColor(fBgColor); fTextView->SetViewColor(fBgColor);
text_run run; text_run run;

View File

@ -7,6 +7,7 @@
#include <View.h> #include <View.h>
class BScrollView;
class BTextView; class BTextView;
@ -24,12 +25,16 @@ public:
private: private:
void _Init(BRect frame); void _Init(BRect frame);
void _InitInterface();
void _SetText(const char* text); void _SetText(const char* text);
void _UpdateColors(); void _UpdateColors();
BString _GetCurrentPath(); BString _GetCurrentPath();
BTextView* fTextView; BTextView* fTextView;
BScrollView* fScrollView;
rgb_color fBgColor; rgb_color fBgColor;
rgb_color fFgColor; rgb_color fFgColor;
BString fCurrentPath; BString fCurrentPath;