summaryrefslogtreecommitdiff
path: root/menuitem.c
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2013-02-12 16:37:59 +0100
committerlouis <louis.braun@gmx.de>2013-02-12 16:37:59 +0100
commit702f4d7795fa97d0cb716c7933f83225e85a35e0 (patch)
treee70b222b47e327ec46b3a332bb3043a315dd70b4 /menuitem.c
parentf04a7865cdab7a6a8d0aa5ec2f062e16bcd27e8e (diff)
downloadskin-nopacity-702f4d7795fa97d0cb716c7933f83225e85a35e0.tar.gz
skin-nopacity-702f4d7795fa97d0cb716c7933f83225e85a35e0.tar.bz2
Introduced rounded corners for menuitems and buttons
Diffstat (limited to 'menuitem.c')
-rw-r--r--menuitem.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/menuitem.c b/menuitem.c
index 6301457..4ca37d5 100644
--- a/menuitem.c
+++ b/menuitem.c
@@ -84,6 +84,8 @@ void cNopacityMenuItem::SetBackgrounds(int *handleBackgrounds) {
void cNopacityMenuItem::DrawDelimiter(const char *del, const char *icon, int handleBgrd) {
pixmap->Fill(Theme.Color(clrSeparatorBorder));
pixmap->DrawImage(cPoint(1, 1), handleBgrd);
+ if (config.roundedCorners)
+ DrawRoundedCorners(Theme.Color(clrSeparatorBorder));
cImageLoader imgLoader;
if (!drawn) {
if (imgLoader.LoadIcon(icon, config.iconHeight)) {
@@ -173,6 +175,22 @@ std::string cNopacityMenuItem::CutText(std::string *text, int width, const cFont
return cuttedText;
}
+void cNopacityMenuItem::DrawRoundedCorners(tColor borderColor) {
+ int radius = config.cornerRadius;
+
+ pixmap->DrawEllipse(cRect(0,0,radius,radius), borderColor, -2);
+ pixmap->DrawEllipse(cRect(-1,-1,radius,radius), clrTransparent, -2);
+
+ pixmap->DrawEllipse(cRect(width-radius,0,radius,radius), borderColor, -1);
+ pixmap->DrawEllipse(cRect(width-radius+1,-1,radius,radius), clrTransparent, -1);
+
+ pixmap->DrawEllipse(cRect(0,height-radius,radius,radius), borderColor, -3);
+ pixmap->DrawEllipse(cRect(-1,height-radius+1,radius,radius), clrTransparent, -3);
+
+ pixmap->DrawEllipse(cRect(width-radius,height-radius,radius,radius), borderColor, -4);
+ pixmap->DrawEllipse(cRect(width-radius+1,height-radius+1,radius,radius), clrTransparent, -4);
+}
+
// cNopacityMainMenuItem -------------
cNopacityMainMenuItem::cNopacityMainMenuItem(cOsd *osd, const char *text, bool sel) : cNopacityMenuItem (osd, text, sel) {
}
@@ -279,6 +297,8 @@ void cNopacityMainMenuItem::Render() {
pixmap->Fill(Theme.Color(clrMenuBorder));
int handleBgrd = (current)?handleBackgrounds[3]:handleBackgrounds[2];
pixmap->DrawImage(cPoint(1, 1), handleBgrd);
+ if (config.roundedCorners)
+ DrawRoundedCorners(Theme.Color(clrMenuBorder));
if (selectable) {
cString cIcon = GetIconName();
if (!drawn) {
@@ -442,6 +462,8 @@ void cNopacityScheduleMenuItem::DrawBackground(int textLeft) {
pixmap->Fill(Theme.Color(clrMenuBorder));
pixmap->DrawImage(cPoint(1, 1), handleBgrd);
pixmap->DrawText(cPoint(textLeft, 3), strDateTime.c_str(), Theme.Color(clrMenuFontMenuItem), clrTransparent, font);
+ if (config.roundedCorners)
+ DrawRoundedCorners(Theme.Color(clrMenuBorder));
if (TimerMatch == tmFull) {
cImageLoader imgLoader;
if (imgLoader.LoadIcon("activetimer", 64, 64)) {
@@ -550,6 +572,8 @@ void cNopacityChannelMenuItem::SetTextShort(void) {
void cNopacityChannelMenuItem::DrawBackground(int handleBackground) {
pixmap->Fill(Theme.Color(clrMenuBorder));
pixmap->DrawImage(cPoint(1, 1), handleBackground);
+ if (config.roundedCorners)
+ DrawRoundedCorners(Theme.Color(clrMenuBorder));
int encryptedSize = height/4-2;
int sourceX = config.menuItemLogoWidth + 15;
@@ -668,6 +692,8 @@ void cNopacityTimerMenuItem::SetTextShort(void) {
void cNopacityTimerMenuItem::DrawBackground(int handleBackground, int textLeft) {
pixmap->Fill(Theme.Color(clrMenuBorder));
pixmap->DrawImage(cPoint(1, 1), handleBackground);
+ if (config.roundedCorners)
+ DrawRoundedCorners(Theme.Color(clrMenuBorder));
int iconSize = height/2;
cString iconName("");
bool firstDay = false;
@@ -952,6 +978,8 @@ void cNopacityRecordingMenuItem::Render() {
if (selectable) {
pixmap->Fill(Theme.Color(clrMenuBorder));
pixmap->DrawImage(cPoint(1, 1), handleBgrd);
+ if (config.roundedCorners)
+ DrawRoundedCorners(Theme.Color(clrMenuBorder));
if (isFolder) {
DrawFolderNewSeen();
SetTextShort();
@@ -1038,6 +1066,8 @@ void cNopacityDefaultMenuItem::Render() {
int handleBgrd = (current)?handleBackgrounds[1]:handleBackgrounds[0];
tColor clrFont = (current)?Theme.Color(clrMenuFontMenuItemHigh):Theme.Color(clrMenuFontMenuItem);
pixmap->DrawImage(cPoint(1, 1), handleBgrd);
+ if (config.roundedCorners)
+ DrawRoundedCorners(Theme.Color(clrMenuBorder));
int colWidth = 0;
int colTextWidth = 0;
cString itemText("");
@@ -1055,7 +1085,9 @@ void cNopacityDefaultMenuItem::Render() {
} else {
itemText = itemTabs[i];
}
- pixmap->DrawText(cPoint(tabWidth[i], (height - font->Height()) / 2), *itemText, clrFont, clrTransparent, font);
+ int posX = tabWidth[i];
+ if (i==0) posX += 5;
+ pixmap->DrawText(cPoint(posX, (height - font->Height()) / 2), *itemText, clrFont, clrTransparent, font);
} else {
if (!Running())
SetTextShort();
@@ -1091,5 +1123,7 @@ void cNopacityTrackMenuItem::Render() {
pixmap->Fill(Theme.Color(clrMenuBorder));
int handleBgrd = (current)?handleBackgrounds[1]:handleBackgrounds[0];
pixmap->DrawImage(cPoint(1, 1), handleBgrd);
+ if (config.roundedCorners)
+ DrawRoundedCorners(Theme.Color(clrMenuBorder));
pixmap->DrawText(cPoint(5, (height - font->Height())/2), Text, Theme.Color(clrTracksFontButtons), clrTransparent, font);
}