diff --git a/Makefile b/Makefile index 77c7a55..2ebd54c 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,8 @@ RDEFS = \ src/Pogger.rdef \ art/FeedIcon.rdef \ art/EntryIcon.rdef \ + art/DownloadStatus.rdef \ + art/ErrorStatus.rdef \ # Specify the resource files to use. Full or relative paths can be used. diff --git a/TODO.txt b/TODO.txt index 8fe8557..89aed6c 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,5 +1,4 @@ Important Features: -* Show progress in FeedView's feedlist as icons * Show in desktray * Make archivable * Get menu working @@ -19,6 +18,7 @@ Important improvements: * General input sanitization * File error-handling * e.g., Utils.cpp's userFileError +* Fix background of Feeds List error status icon (it's black, not transparent) * Check if arg is a file or not (treat appropriately) * Make UI friendly to whatever font-size you throw at it * Give a max size to the progress label in FeedsView diff --git a/art/DownloadStatus b/art/DownloadStatus new file mode 100644 index 0000000..41dc104 Binary files /dev/null and b/art/DownloadStatus differ diff --git a/art/DownloadStatus.rdef b/art/DownloadStatus.rdef new file mode 100644 index 0000000..3b27163 --- /dev/null +++ b/art/DownloadStatus.rdef @@ -0,0 +1,8 @@ + +resource(3, "download-status") #'VICN' array { + $"6E6369660304006603BB5205020006020000003C6000C000000000004C000048" + $"A00000D58E05FFFFD27C010A07352248363E363E482C482C362236030A000100" + $"12C0A3232D8566AD8573C0A32D4BF6834BD6C801178322040A01010012C0A323" + $"2D8566AD8573C0A32D4BD0C34BD0ED01178322040A02010002C0A3232D8566AD" + $"8573C0A32D4BD0C34BD0ED" +}; diff --git a/art/EntryIcon.rdef b/art/EntryIcon.rdef index 059854b..088b59e 100644 --- a/art/EntryIcon.rdef +++ b/art/EntryIcon.rdef @@ -1,5 +1,5 @@ -resource(2, "entry-type-icon") #'VICN' array { +resource(2, "entry-type") #'VICN' array { $"6E636966090401740501020106023B32F3BB51843CAA363C91AA45272C4AD4C6" $"00FCFAF4FF808076020116023B32F3BB51843CAA363C91AA45272C4AD4C600AC" $"FF01020106023B32F3BB51843CAA363C91AA45272C4AD4C600FF90AAFB6D021B" diff --git a/art/ErrorStatus b/art/ErrorStatus new file mode 100644 index 0000000..f606af8 Binary files /dev/null and b/art/ErrorStatus differ diff --git a/art/ErrorStatus.rdef b/art/ErrorStatus.rdef new file mode 100644 index 0000000..a159907 --- /dev/null +++ b/art/ErrorStatus.rdef @@ -0,0 +1,7 @@ + +resource(4, "error-status") #'VICN' array { + $"6E6369660304006603800000020006020000003C2000C000000000004C000048" + $"E00000FFABABFFD90000010A0C482A4022352D2A22222A2D3522402A48353D40" + $"4848403D35030A000100302C2C01178322040A010100302A2A01178322040A02" + $"0100202A2A" +}; diff --git a/art/FeedIcon.rdef b/art/FeedIcon.rdef index 76b02ef..1b72b7e 100644 --- a/art/FeedIcon.rdef +++ b/art/FeedIcon.rdef @@ -1,5 +1,5 @@ -resource(1, "feed-type-icon") #'VICN' array { +resource(1, "feed-type") #'VICN' array { $"6E6369660603010000020006023CC7EE389BC0BA16573E39B04977C842ADC700" $"FFE2BAFFFF9500020016023CC7EE389BC0BA16573E39B04977C842ADC700FFFF" $"E7020006023C96323A4D3FBAFC013D5A974B57A549844D00992600FFBF500002" diff --git a/art/README.txt b/art/README.txt index 6d79cb6..03967e3 100644 --- a/art/README.txt +++ b/art/README.txt @@ -1,8 +1,9 @@ -These cons are copied over from Haiku's source tree at +The mimetype icons (FeedIcon and EntryIcon) and status icons (DownloadStatus, +ErrorStatus) are all copied over from Haiku's source tree at: haiku/data/artwork/icons/File_RSS_Feed haiku/data/artwork/icons/Server_NewsFeed + haiku/data/artwork/icons/Action_GoDown_3 + haiku/data/artwork/icons/Action_Stop_1 -As far as I can tell, they aren't included in base installs. We just use them -as the mimetype icons for application/x-feed-source and text/x-feed-entry. They're under the MIT license, as per haiku/data/artwork/ReadMe diff --git a/src/FeedListItem.cpp b/src/FeedListItem.cpp index e5387f6..82754ad 100644 --- a/src/FeedListItem.cpp +++ b/src/FeedListItem.cpp @@ -8,6 +8,7 @@ #include #include "Feed.h" +#include "Util.h" FeedListItem::FeedListItem(Feed* feed) @@ -25,22 +26,23 @@ FeedListItem::DrawItem(BView* owner, BRect frame, bool complete) { BStringItem::DrawItem(owner, frame, complete); - owner->MovePenTo(frame.right - 20, frame.top + BaselineOffset()); + font_height fontHeight; + owner->GetFontHeight(&fontHeight); + int16 imageHeight = int16(fontHeight.ascent + fontHeight.descent + 6); switch (fStatus) { case kDownloadingStatus: - { - owner->DrawString("…"); - break; - } case kParsingStatus: { - owner->DrawString("―"); + owner->MovePenTo(frame.right - 20, frame.top + BaselineOffset()); + owner->DrawString("…"); break; } case kErrorStatus: { - owner->DrawString("X"); + owner->MovePenTo(frame.right - imageHeight, frame.top); + owner->DrawBitmap(loadVectorIcon("error-status", imageHeight, + imageHeight)); break; } } diff --git a/src/Mimetypes.cpp b/src/Mimetypes.cpp index 9ac6fc6..efeace5 100644 --- a/src/Mimetypes.cpp +++ b/src/Mimetypes.cpp @@ -31,7 +31,7 @@ feedMimeType() BResources* res = BApplication::AppResources(); size_t length = 0; - const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, "feed-type-icon", &length); + const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, "feed-type", &length); mime.SetIcon((uint8*)data, length); mime.SetPreferredApp("application/x-vnd.Pogger"); @@ -61,7 +61,7 @@ feedEntryMimeType() BResources* res = BApplication::AppResources(); size_t length = 0; - const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, "entry-type-icon", &length); + const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, "entry-type", &length); mime.SetIcon((uint8*)data, length); mime.SetPreferredApp("application/x-vnd.Pogger"); diff --git a/src/Util.cpp b/src/Util.cpp index 4a737ba..e2e4a7c 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -1,5 +1,6 @@ /* * Copyright 2020, Jaidyn Levesque + * Copyight 2017 Akshay Agarwal, agarwal.akshay.akshay8@gmail.com * All rights reserved. Distributed under the terms of the MIT license. */ @@ -8,9 +9,13 @@ #include #include +#include +#include #include #include +#include #include +#include #include #include #include @@ -191,3 +196,28 @@ tempHtmlFile(entry_ref* ref, const char* title) } +BBitmap* +loadVectorIcon(const char* name, int32 iconSize, int32 cropSize) +{ + BResources* res = BApplication::AppResources(); + size_t length = 0; + const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, name, &length); + BBitmap* temp = new BBitmap(BRect(0, 0, iconSize - 1, iconSize - 1), + B_BITMAP_NO_SERVER_LINK, B_RGBA32); + BBitmap* dest = new BBitmap(BRect(0, 0, cropSize - 1, cropSize - 1), + B_RGBA32); + if (data != NULL + && BIconUtils::GetVectorIcon((uint8*)data, length, temp) + == B_OK + && dest->ImportBits(temp, BPoint(0, 0), BPoint(0, 0), + cropSize, cropSize) == B_OK) { + delete temp; + return dest; + } + + delete temp; + delete dest; + return NULL; +} + + diff --git a/src/Util.h b/src/Util.h index e135f03..2eea903 100644 --- a/src/Util.h +++ b/src/Util.h @@ -1,5 +1,6 @@ /* * Copyright 2020, Jaidyn Levesque + * Copyight 2017 Akshay Agarwal, agarwal.akshay.akshay8@gmail.com * All rights reserved. Distributed under the terms of the MIT license. */ #ifndef UTIL_H @@ -9,6 +10,7 @@ #include "ProtocolListener.h" +class BBitmap; class BUrl; @@ -34,6 +36,9 @@ void userFileError(status_t status, const char* path); // temporary copy. Returns an entry_ref to said temporary copy. entry_ref tempHtmlFile(entry_ref* ref, const char* title); +// Ripped from Calendar (utils/ResourceLoader.cpp) +BBitmap* loadVectorIcon(const char* name, int32 iconSize = 32, + int32 cropSize = 22); #endif // UTIL_H