Merge pull request #782 from redtide/about-hover

Text for icons in the about dialog
This commit is contained in:
JP Cimalando 2021-04-05 21:46:04 +02:00 committed by GitHub
commit da9135b72c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 36 deletions

View file

@ -4,47 +4,47 @@ header_name {.h}
code_name {.cxx} code_name {.cxx}
widget_class aboutView { widget_class aboutView {
label {About sfizz} open selected label {About sfizz} open selected
xywh {536 183 800 475} type Double visible xywh {527 165 800 475} type Double visible
} { } {
Fl_Box {} { Fl_Box lblHover_ {
image {../resources/logo_orange.png} xywh {200 80 400 180} xywh {200 80 400 25} labelsize 10
class Logo class HoverBox
} }
Fl_Button {} { Fl_Button {} {
comment {tag=kTagButtonSfztools} comment {tag=kTagButtonSfztools}
xywh {235 45 50 50} labelsize 30 xywh {235 45 35 35} labelsize 30
class ButtonSfztools class ButtonSfztools
} }
Fl_Button {} { Fl_Button {} {
comment {tag=kTagButtonGithub} comment {tag=kTagButtonGithub}
xywh {305 45 50 50} labelsize 30 xywh {305 45 35 35} labelsize 30
class ButtonGithub class ButtonGithub
} }
Fl_Button {} { Fl_Button {} {
comment {tag=kTagButtonDiscord} comment {tag=kTagButtonDiscord}
xywh {375 45 50 50} labelsize 30 xywh {375 45 35 35} labelsize 30
class ButtonDiscord class ButtonDiscord
} }
Fl_Button {} { Fl_Button {} {
comment {tag=kTagButtonOpencollective} comment {tag=kTagButtonOpencollective}
xywh {445 45 50 50} labelsize 30 xywh {445 45 35 35} labelsize 30
class ButtonOpencollective class ButtonOpencollective
} }
Fl_Button {} { Fl_Button {} {
comment {tag=kTagButtonSfzformat} comment {tag=kTagButtonSfzformat}
xywh {515 45 50 50} labelsize 30 xywh {515 45 35 35} labelsize 30
class ButtonSfzformat class ButtonSfzformat
} }
Fl_Box {} { Fl_Box {} {
xywh {260 260 280 80} image {../resources/logo_orange.png} xywh {200 90 400 180}
class Logo
}
Fl_Box {} {
xywh {260 270 280 80}
class InfoBox class InfoBox
} }
Fl_Box {} { Fl_Box {} {
xywh {200 350 400 100} xywh {200 350 400 100}
class DescriptionBox class DescriptionBox
} }
Fl_Box lblHover_ {
xywh {320 10 160 25}
class HoverBox
}
} }

View file

@ -67,9 +67,10 @@ SAboutDialog::SAboutDialog(const CRect& bounds)
lbl->setBackColor(CColor(0x00, 0x00, 0x00, 0x00)); lbl->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setHoriAlign(align); lbl->setHoriAlign(align);
lbl->setText(absl::StrCat( lbl->setText(absl::StrCat(
u8"Maintainers: Paul Ferrand, Jean-Pierre Cimalando\n""" u8"Maintainers: Paul Ferrand, Jean-Pierre Cimalando\n"
u8"Contributors: Andrea Zanellato, Alexander Mitchell, Michael Willis,\n" u8"Contributors: Andrea Zanellato, Alexander Mitchell, Michael Willis,\n"
u8"Tobiasz \"unfa\" Karoń, Kinwie, Atsushi Eno, Dominique Würtz et al.")); u8"Tobiasz \"unfa\" Karoń, Kinwie, Atsushi Eno, Dominique Würtz,\n"
u8"Even Brenden et al."));
return lbl; return lbl;
}; };
@ -95,20 +96,35 @@ SAboutDialog::SAboutDialog(const CRect& bounds)
btn->setGradientHighlighted(nullptr); btn->setGradientHighlighted(nullptr);
return btn; return btn;
}; };
auto createButtonSfztools = [&createGlyphButton](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) { auto createButtonSfztools = [this, &createGlyphButton](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) {
return createGlyphButton(u8"\ue000", bounds, tag, fontsize); STextButton* btn = createGlyphButton(u8"\ue000", bounds, tag, fontsize);
btn->OnHoverEnter = [this]() { lblHover_->setText("SFZTools Website"); };
btn->OnHoverLeave = [this]() { lblHover_->setText(""); };
return btn;
}; };
auto createButtonGithub = [&createGlyphButton](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) { auto createButtonGithub = [this, &createGlyphButton](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) {
return createGlyphButton(u8"\ue001", bounds, tag, fontsize); STextButton* btn = createGlyphButton(u8"\ue001", bounds, tag, fontsize);
btn->OnHoverEnter = [this]() { lblHover_->setText("GitHub Repository"); };
btn->OnHoverLeave = [this]() { lblHover_->setText(""); };
return btn;
}; };
auto createButtonDiscord = [&createGlyphButton](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) { auto createButtonDiscord = [this, &createGlyphButton](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) {
return createGlyphButton(u8"\ue002", bounds, tag, fontsize); STextButton* btn = createGlyphButton(u8"\ue002", bounds, tag, fontsize);
btn->OnHoverEnter = [this]() { lblHover_->setText("Discord Chat"); };
btn->OnHoverLeave = [this]() { lblHover_->setText(""); };
return btn;
}; };
auto createButtonOpencollective = [&createGlyphButton](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) { auto createButtonOpencollective = [this, &createGlyphButton](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) {
return createGlyphButton(u8"\ue003", bounds, tag, fontsize); STextButton* btn = createGlyphButton(u8"\ue003", bounds, tag, fontsize);
btn->OnHoverEnter = [this]() { lblHover_->setText("Support Us"); };
btn->OnHoverLeave = [this]() { lblHover_->setText(""); };
return btn;
}; };
auto createButtonSfzformat = [&createGlyphButton](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) { auto createButtonSfzformat = [this, &createGlyphButton](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) {
return createGlyphButton(u8"\ue004", bounds, tag, fontsize); STextButton* btn = createGlyphButton(u8"\ue004", bounds, tag, fontsize);
btn->OnHoverEnter = [this]() { lblHover_->setText("SFZFormat Documentation"); };
btn->OnHoverLeave = [this]() { lblHover_->setText(""); };
return btn;
}; };
#include "layout/about.hpp" #include "layout/about.hpp"

View file

@ -448,6 +448,8 @@ void STextButton::draw(CDrawContext* context)
CMouseEventResult STextButton::onMouseEntered (CPoint& where, const CButtonState& buttons) CMouseEventResult STextButton::onMouseEntered (CPoint& where, const CButtonState& buttons)
{ {
hovered_ = true; hovered_ = true;
if (OnHoverEnter)
OnHoverEnter();
invalid(); invalid();
return CTextButton::onMouseEntered(where, buttons); return CTextButton::onMouseEntered(where, buttons);
} }
@ -455,6 +457,8 @@ CMouseEventResult STextButton::onMouseEntered (CPoint& where, const CButtonState
CMouseEventResult STextButton::onMouseExited (CPoint& where, const CButtonState& buttons) CMouseEventResult STextButton::onMouseExited (CPoint& where, const CButtonState& buttons)
{ {
hovered_ = false; hovered_ = false;
if (OnHoverLeave)
OnHoverLeave();
invalid(); invalid();
return CTextButton::onMouseExited(where, buttons); return CTextButton::onMouseExited(where, buttons);
} }

View file

@ -196,6 +196,10 @@ public:
CMouseEventResult onMouseEntered (CPoint& where, const CButtonState& buttons) override; CMouseEventResult onMouseEntered (CPoint& where, const CButtonState& buttons) override;
CMouseEventResult onMouseExited (CPoint& where, const CButtonState& buttons) override; CMouseEventResult onMouseExited (CPoint& where, const CButtonState& buttons) override;
void draw(CDrawContext* context) override; void draw(CDrawContext* context) override;
std::function<void()> OnHoverEnter;
std::function<void()> OnHoverLeave;
private: private:
CColor hoverColor_; CColor hoverColor_;
bool hovered_ { false }; bool hovered_ { false };

View file

@ -1,22 +1,22 @@
/* This file is generated by the layout maker tool. */ /* This file is generated by the layout maker tool. */
auto* const view__0 = createaboutView(CRect(0, 0, 800, 475), -1, "About sfizz", kCenterText, 14); auto* const view__0 = createaboutView(CRect(0, 0, 800, 475), -1, "About sfizz", kCenterText, 14);
aboutView = view__0; aboutView = view__0;
auto* const view__1 = createLogo(CRect(200, 80, 600, 260), -1, "", kCenterText, 14); auto* const view__1 = createHoverBox(CRect(200, 80, 600, 105), -1, "", kCenterText, 10);
lblHover_ = view__1;
view__0->addView(view__1); view__0->addView(view__1);
auto* const view__2 = createButtonSfztools(CRect(235, 45, 285, 95), kTagButtonSfztools, "", kCenterText, 30); auto* const view__2 = createButtonSfztools(CRect(235, 45, 270, 80), kTagButtonSfztools, "", kCenterText, 30);
view__0->addView(view__2); view__0->addView(view__2);
auto* const view__3 = createButtonGithub(CRect(305, 45, 355, 95), kTagButtonGithub, "", kCenterText, 30); auto* const view__3 = createButtonGithub(CRect(305, 45, 340, 80), kTagButtonGithub, "", kCenterText, 30);
view__0->addView(view__3); view__0->addView(view__3);
auto* const view__4 = createButtonDiscord(CRect(375, 45, 425, 95), kTagButtonDiscord, "", kCenterText, 30); auto* const view__4 = createButtonDiscord(CRect(375, 45, 410, 80), kTagButtonDiscord, "", kCenterText, 30);
view__0->addView(view__4); view__0->addView(view__4);
auto* const view__5 = createButtonOpencollective(CRect(445, 45, 495, 95), kTagButtonOpencollective, "", kCenterText, 30); auto* const view__5 = createButtonOpencollective(CRect(445, 45, 480, 80), kTagButtonOpencollective, "", kCenterText, 30);
view__0->addView(view__5); view__0->addView(view__5);
auto* const view__6 = createButtonSfzformat(CRect(515, 45, 565, 95), kTagButtonSfzformat, "", kCenterText, 30); auto* const view__6 = createButtonSfzformat(CRect(515, 45, 550, 80), kTagButtonSfzformat, "", kCenterText, 30);
view__0->addView(view__6); view__0->addView(view__6);
auto* const view__7 = createInfoBox(CRect(260, 260, 540, 340), -1, "", kCenterText, 14); auto* const view__7 = createLogo(CRect(200, 90, 600, 270), -1, "", kCenterText, 14);
view__0->addView(view__7); view__0->addView(view__7);
auto* const view__8 = createDescriptionBox(CRect(200, 350, 600, 450), -1, "", kCenterText, 14); auto* const view__8 = createInfoBox(CRect(260, 270, 540, 350), -1, "", kCenterText, 14);
view__0->addView(view__8); view__0->addView(view__8);
auto* const view__9 = createHoverBox(CRect(320, 10, 480, 35), -1, "", kCenterText, 14); auto* const view__9 = createDescriptionBox(CRect(200, 350, 600, 450), -1, "", kCenterText, 14);
lblHover_ = view__9;
view__0->addView(view__9); view__0->addView(view__9);