Cortex: use vector icons

Change-Id: I49f6bdf93366221330ca29281e3465d9b7452402
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4405
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Gerasim Troeglazov
2021-09-09 22:22:14 +00:00
committed by waddlesplash
parent b24faa52b4
commit c377d66126
5 changed files with 1001 additions and 1262 deletions
@@ -108,21 +108,8 @@ void DormantNodeListItem::DrawItem(
r.top += (frame.Height() / 2.0) - (B_MINI_ICON / 2.0); r.top += (frame.Height() / 2.0) - (B_MINI_ICON / 2.0);
r.right = r.left + B_MINI_ICON - 1.0; r.right = r.left + B_MINI_ICON - 1.0;
r.bottom = r.top + B_MINI_ICON - 1.0; r.bottom = r.top + B_MINI_ICON - 1.0;
if (IsSelected()) { owner->SetDrawingMode(B_OP_OVER);
owner->SetHighColor(255, 255, 255, 255); owner->DrawBitmap(m_icon, r.LeftTop());
owner->FillRect(r);
owner->SetDrawingMode(B_OP_INVERT);
owner->DrawBitmap(m_icon, r.LeftTop());
owner->SetDrawingMode(B_OP_ALPHA);
owner->SetHighColor(0, 0, 0, 180);
owner->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
owner->DrawBitmap(m_icon, r.LeftTop());
owner->SetDrawingMode(B_OP_OVER);
}
else {
owner->SetDrawingMode(B_OP_OVER);
owner->DrawBitmap(m_icon, r.LeftTop());
}
} }
// Draw label // Draw label
@@ -409,7 +409,7 @@ void MediaJack::_updateBitmap()
{ {
delete m_bitmap; delete m_bitmap;
} }
BBitmap *tempBitmap = new BBitmap(Frame().OffsetToCopy(0.0, 0.0), B_CMAP8, true); BBitmap *tempBitmap = new BBitmap(Frame().OffsetToCopy(0.0, 0.0), B_RGBA32, true);
tempBitmap->Lock(); tempBitmap->Lock();
{ {
BView *tempView = new BView(tempBitmap->Bounds(), "", B_FOLLOW_NONE, 0); BView *tempView = new BView(tempBitmap->Bounds(), "", B_FOLLOW_NONE, 0);
@@ -891,7 +891,8 @@ void MediaNodePanel::_updateBitmap()
{ {
delete m_bitmap; delete m_bitmap;
} }
BBitmap *tempBitmap = new BBitmap(Frame().OffsetToCopy(0.0, 0.0), B_CMAP8, true); BBitmap *tempBitmap = new BBitmap(Frame().OffsetToCopy(0.0, 0.0),
B_RGBA32, true);
tempBitmap->Lock(); tempBitmap->Lock();
{ {
BView *tempView = new BView(tempBitmap->Bounds(), "", B_FOLLOW_NONE, 0); BView *tempView = new BView(tempBitmap->Bounds(), "", B_FOLLOW_NONE, 0);
@@ -946,21 +947,8 @@ void MediaNodePanel::_drawInto(
{ {
p.x = m_bodyRect.left + m_bodyRect.Width() / 2.0 - B_LARGE_ICON / 2.0; p.x = m_bodyRect.left + m_bodyRect.Width() / 2.0 - B_LARGE_ICON / 2.0;
p.y = m_labelRect.bottom + m_bodyRect.Height() / 2.0 - B_LARGE_ICON / 2.0; p.y = m_labelRect.bottom + m_bodyRect.Height() / 2.0 - B_LARGE_ICON / 2.0;
if (isSelected()) target->SetDrawingMode(B_OP_OVER);
{ target->DrawBitmapAsync(m_icon, p);
target->SetDrawingMode(B_OP_INVERT);
target->DrawBitmapAsync(m_icon, p);
target->SetDrawingMode(B_OP_ALPHA);
target->SetHighColor(0, 0, 0, 180);
target->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
target->DrawBitmapAsync(m_icon, p);
target->SetDrawingMode(B_OP_OVER);
}
else
{
target->SetDrawingMode(B_OP_OVER);
target->DrawBitmapAsync(m_icon, p);
}
} }
// Draw label // Draw label
@@ -1012,21 +1000,8 @@ void MediaNodePanel::_drawInto(
{ {
p.x = m_bodyRect.left + M_BODY_H_MARGIN; p.x = m_bodyRect.left + M_BODY_H_MARGIN;
p.y = m_bodyRect.top + (m_bodyRect.Height() / 2.0) - (B_MINI_ICON / 2.0); p.y = m_bodyRect.top + (m_bodyRect.Height() / 2.0) - (B_MINI_ICON / 2.0);
if (isSelected()) target->SetDrawingMode(B_OP_OVER);
{ target->DrawBitmapAsync(m_icon, p);
target->SetDrawingMode(B_OP_INVERT);
target->DrawBitmapAsync(m_icon, p);
target->SetDrawingMode(B_OP_ALPHA);
target->SetHighColor(0, 0, 0, 180);
target->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
target->DrawBitmapAsync(m_icon, p);
target->SetDrawingMode(B_OP_OVER);
}
else
{
target->SetDrawingMode(B_OP_OVER);
target->DrawBitmapAsync(m_icon, p);
}
} }
// Draw label // Draw label
+61 -89
View File
@@ -47,6 +47,9 @@
#include <NodeInfo.h> #include <NodeInfo.h>
// Support Kit // Support Kit
#include <String.h> #include <String.h>
// Interface Kit
#include <IconUtils.h>
__USE_CORTEX_NAMESPACE __USE_CORTEX_NAMESPACE
@@ -61,7 +64,7 @@ __USE_CORTEX_NAMESPACE
MediaIcon::MediaIcon( MediaIcon::MediaIcon(
const live_node_info &nodeInfo, const live_node_info &nodeInfo,
icon_size size) icon_size size)
: BBitmap(BRect(0.0, 0.0, size - 1.0, size - 1.0), B_CMAP8), : BBitmap(BRect(0.0, 0.0, size - 1.0, size - 1.0), B_RGBA32),
m_size(size), m_size(size),
m_nodeKind(nodeInfo.node.kind) { m_nodeKind(nodeInfo.node.kind) {
D_ALLOC(("MediaIcon::MediaIcon(live_node_info '%s')\n", nodeInfo.name)); D_ALLOC(("MediaIcon::MediaIcon(live_node_info '%s')\n", nodeInfo.name));
@@ -72,7 +75,7 @@ MediaIcon::MediaIcon(
MediaIcon::MediaIcon( MediaIcon::MediaIcon(
const dormant_node_info &nodeInfo, const dormant_node_info &nodeInfo,
icon_size size) icon_size size)
: BBitmap(BRect(0.0, 0.0, size - 1.0, size - 1.0), B_CMAP8), : BBitmap(BRect(0.0, 0.0, size - 1.0, size - 1.0), B_RGBA32),
m_size(size), m_size(size),
m_nodeKind(0) { m_nodeKind(0) {
D_ALLOC(("MediaIcon::MediaIcon(dormant_node_info '%s')\n", nodeInfo.name)); D_ALLOC(("MediaIcon::MediaIcon(dormant_node_info '%s')\n", nodeInfo.name));
@@ -204,12 +207,13 @@ MediaIcon::_findIconFor(const dormant_node_info &nodeInfo)
bool videoIn = false, videoOut = false; bool videoIn = false, videoOut = false;
_getMediaTypesFor(flavorInfo, &audioIn, &audioOut, &videoIn, &videoOut); _getMediaTypesFor(flavorInfo, &audioIn, &audioOut, &videoIn, &videoOut);
_findDefaultIconFor(audioIn, audioOut, videoIn, videoOut); _findDefaultIconFor(audioIn, audioOut, videoIn, videoOut);
} else if (BString(nodeInfo.name).Compare("System clock") == 0) {
BIconUtils::GetVectorIcon(M_TIME_SOURCE_ICON,
sizeof(M_TIME_SOURCE_ICON), this);
} else { } else {
// use generic icon in case we couldn't get any info // use generic icon in case we couldn't get any info
if (m_size == B_LARGE_ICON) BIconUtils::GetVectorIcon(M_GENERIC_ICON,
SetBits(M_GENERIC_ICON.large, 1024, 0, B_CMAP8); sizeof(M_GENERIC_ICON), this);
else if (m_size == B_MINI_ICON)
SetBits(M_GENERIC_ICON.small, 256, 0, B_CMAP8);
} }
} }
@@ -228,7 +232,8 @@ MediaIcon::_getMediaTypesFor(const live_node_info &nodeInfo, bool *audioIn,
int32 numberOfFreeOutputs, numberOfConnectedOutputs; int32 numberOfFreeOutputs, numberOfConnectedOutputs;
media_output outputs[numberOfOutputs]; media_output outputs[numberOfOutputs];
BMediaRoster *roster = BMediaRoster::CurrentRoster(); BMediaRoster *roster = BMediaRoster::CurrentRoster();
if (roster->GetFreeInputsFor(nodeInfo.node, inputs, numberOfInputs, &numberOfFreeInputs) == B_OK) { if (roster->GetFreeInputsFor(nodeInfo.node, inputs, numberOfInputs,
&numberOfFreeInputs) == B_OK) {
for (int32 i = 0; i < numberOfFreeInputs; i++) { for (int32 i = 0; i < numberOfFreeInputs; i++) {
if ((inputs[i].format.type == B_MEDIA_RAW_AUDIO) if ((inputs[i].format.type == B_MEDIA_RAW_AUDIO)
|| (inputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) { || (inputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) {
@@ -241,7 +246,8 @@ MediaIcon::_getMediaTypesFor(const live_node_info &nodeInfo, bool *audioIn,
} }
} }
} }
if (roster->GetConnectedInputsFor(nodeInfo.node, inputs, numberOfInputs, &numberOfConnectedInputs) == B_OK) { if (roster->GetConnectedInputsFor(nodeInfo.node, inputs, numberOfInputs,
&numberOfConnectedInputs) == B_OK) {
for (int32 i = 0; i < numberOfConnectedInputs; i++) { for (int32 i = 0; i < numberOfConnectedInputs; i++) {
if ((inputs[i].format.type == B_MEDIA_RAW_AUDIO) if ((inputs[i].format.type == B_MEDIA_RAW_AUDIO)
|| (inputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) { || (inputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) {
@@ -254,7 +260,8 @@ MediaIcon::_getMediaTypesFor(const live_node_info &nodeInfo, bool *audioIn,
} }
} }
} }
if (roster->GetFreeOutputsFor(nodeInfo.node, outputs, numberOfOutputs, &numberOfFreeOutputs) == B_OK) { if (roster->GetFreeOutputsFor(nodeInfo.node, outputs, numberOfOutputs,
&numberOfFreeOutputs) == B_OK) {
for (int32 i = 0; i < numberOfFreeOutputs; i++) { for (int32 i = 0; i < numberOfFreeOutputs; i++) {
if ((outputs[i].format.type == B_MEDIA_RAW_AUDIO) if ((outputs[i].format.type == B_MEDIA_RAW_AUDIO)
|| (outputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) { || (outputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) {
@@ -267,7 +274,8 @@ MediaIcon::_getMediaTypesFor(const live_node_info &nodeInfo, bool *audioIn,
} }
} }
} }
if (roster->GetConnectedOutputsFor(nodeInfo.node, outputs, numberOfOutputs, &numberOfConnectedOutputs) == B_OK) { if (roster->GetConnectedOutputsFor(nodeInfo.node, outputs, numberOfOutputs,
&numberOfConnectedOutputs) == B_OK) {
for (int32 i = 0; i < numberOfConnectedOutputs; i++) { for (int32 i = 0; i < numberOfConnectedOutputs; i++) {
if ((outputs[i].format.type == B_MEDIA_RAW_AUDIO) if ((outputs[i].format.type == B_MEDIA_RAW_AUDIO)
|| (outputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) { || (outputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) {
@@ -322,133 +330,97 @@ void MediaIcon::_findDefaultIconFor(
D_INTERNAL(("MediaIcon::_findDefaultIcon()\n")); D_INTERNAL(("MediaIcon::_findDefaultIcon()\n"));
if (_isTimeSource()) { if (_isTimeSource()) {
if (m_size == B_LARGE_ICON) BIconUtils::GetVectorIcon(M_TIME_SOURCE_ICON,
SetBits(M_TIME_SOURCE_ICON.large, 1024, 0, B_CMAP8); sizeof(M_TIME_SOURCE_ICON), this);
else if (m_size == B_MINI_ICON)
SetBits(M_TIME_SOURCE_ICON.small, 256, 0, B_CMAP8);
return; return;
} }
if (_isSystemMixer()) { if (_isSystemMixer()) {
if (m_size == B_LARGE_ICON) BIconUtils::GetVectorIcon(M_AUDIO_MIXER_ICON,
SetBits(M_AUDIO_MIXER_ICON.large, 1024, 0, B_CMAP8); sizeof(M_AUDIO_MIXER_ICON), this);
else if (m_size == B_MINI_ICON)
SetBits(M_AUDIO_MIXER_ICON.small, 256, 0, B_CMAP8);
return; return;
} }
if (m_nodeKind & B_FILE_INTERFACE) { if (m_nodeKind & B_FILE_INTERFACE) {
if (_isProducer()) { if (_isProducer()) {
if (m_size == B_LARGE_ICON) BIconUtils::GetVectorIcon(M_FILE_READER_ICON,
SetBits(M_FILE_READER_ICON.large, 1024, 0, B_CMAP8); sizeof(M_FILE_READER_ICON), this);
else if (m_size == B_MINI_ICON)
SetBits(M_FILE_READER_ICON.small, 256, 0, B_CMAP8);
return; return;
} } else {
else { BIconUtils::GetVectorIcon(M_FILE_WRITER_ICON,
if (m_size == B_LARGE_ICON) sizeof(M_FILE_WRITER_ICON), this);
SetBits(M_FILE_WRITER_ICON.large, 1024, 0, B_CMAP8);
else if (m_size == B_MINI_ICON)
SetBits(M_FILE_WRITER_ICON.small, 256, 0, B_CMAP8);
return; return;
} }
} }
if (_isPhysicalInput()) { if (_isPhysicalInput()) {
if (audioOut) { if (audioIn) {
if (m_size == B_LARGE_ICON) BIconUtils::GetVectorIcon(M_AUDIO_DEVICE_ICON,
SetBits(M_AUDIO_INPUT_ICON.large, 1024, 0, B_CMAP8); sizeof(M_AUDIO_DEVICE_ICON), this);
else if (m_size == B_MINI_ICON)
SetBits(M_AUDIO_INPUT_ICON.small, 256, 0, B_CMAP8);
return; return;
} } else if (audioOut) {
else if (videoOut) { BIconUtils::GetVectorIcon(M_AUDIO_INPUT_ICON,
if (m_size == B_LARGE_ICON) sizeof(M_AUDIO_INPUT_ICON), this);
SetBits(M_VIDEO_INPUT_ICON.large, 1024, 0, B_CMAP8); return;
else if (m_size == B_MINI_ICON) } else if (videoOut) {
SetBits(M_VIDEO_INPUT_ICON.small, 256, 0, B_CMAP8); BIconUtils::GetVectorIcon(M_VIDEO_INPUT_ICON,
sizeof(M_VIDEO_INPUT_ICON), this);
return; return;
} }
} }
if (_isPhysicalOutput()) { if (_isPhysicalOutput()) {
if (audioIn) { if (audioIn) {
if (m_size == B_LARGE_ICON) BIconUtils::GetVectorIcon(M_AUDIO_OUTPUT_ICON,
SetBits(M_AUDIO_OUTPUT_ICON.large, 1024, 0, B_CMAP8); sizeof(M_AUDIO_OUTPUT_ICON), this);
else if (m_size == B_MINI_ICON)
SetBits(M_AUDIO_OUTPUT_ICON.small, 256, 0, B_CMAP8);
return; return;
} } else if (videoIn) {
else if (videoIn) { BIconUtils::GetVectorIcon(M_VIDEO_OUTPUT_ICON,
if (m_size == B_LARGE_ICON) sizeof(M_VIDEO_OUTPUT_ICON), this);
SetBits(M_VIDEO_OUTPUT_ICON.large, 1024, 0, B_CMAP8);
else if (m_size == B_MINI_ICON)
SetBits(M_VIDEO_OUTPUT_ICON.small, 256, 0, B_CMAP8);
return; return;
} }
} }
if (_isProducer()) { if (_isProducer()) {
if (audioOut) { if (audioOut) {
if (m_size == B_LARGE_ICON) BIconUtils::GetVectorIcon(M_AUDIO_PRODUCER_ICON,
SetBits(M_AUDIO_PRODUCER_ICON.large, 1024, 0, B_CMAP8); sizeof(M_AUDIO_PRODUCER_ICON), this);
else if (m_size == B_MINI_ICON)
SetBits(M_AUDIO_PRODUCER_ICON.small, 256, 0, B_CMAP8);
return; return;
} } else if (videoOut) {
else if (videoOut) { BIconUtils::GetVectorIcon(M_VIDEO_PRODUCER_ICON,
if (m_size == B_LARGE_ICON) sizeof(M_VIDEO_PRODUCER_ICON), this);
SetBits(M_VIDEO_PRODUCER_ICON.large, 1024, 0, B_CMAP8);
else if (m_size == B_MINI_ICON)
SetBits(M_VIDEO_PRODUCER_ICON.small, 256, 0, B_CMAP8);
return; return;
} }
} }
if (_isFilter()) { if (_isFilter()) {
if (audioIn && audioOut && !videoIn && !videoOut) { if (audioIn && audioOut && !videoIn && !videoOut) {
if (m_size == B_LARGE_ICON) BIconUtils::GetVectorIcon(M_AUDIO_FILTER_ICON,
SetBits(M_AUDIO_FILTER_ICON.large, 1024, 0, B_CMAP8); sizeof(M_AUDIO_FILTER_ICON), this);
else if (m_size == B_MINI_ICON)
SetBits(M_AUDIO_FILTER_ICON.small, 256, 0, B_CMAP8);
return; return;
} } else if (audioIn && !videoIn && videoOut) {
else if (audioIn && !videoIn && videoOut) { BIconUtils::GetVectorIcon(M_AUDIO_CONSUMER_ICON,
if (m_size == B_LARGE_ICON) sizeof(M_AUDIO_CONSUMER_ICON), this);
SetBits(M_AUDIO_CONSUMER_ICON.large, 1024, 0, B_CMAP8);
else if (m_size == B_MINI_ICON)
SetBits(M_AUDIO_CONSUMER_ICON.small, 256, 0, B_CMAP8);
return; return;
} } else if (!audioIn && !audioOut && videoIn && videoOut) {
else if (!audioIn && !audioOut && videoIn && videoOut) { BIconUtils::GetVectorIcon(M_VIDEO_FILTER_ICON,
if (m_size == B_LARGE_ICON) sizeof(M_VIDEO_FILTER_ICON), this);
SetBits(M_VIDEO_FILTER_ICON.large, 1024, 0, B_CMAP8);
else if (m_size == B_MINI_ICON)
SetBits(M_VIDEO_FILTER_ICON.small, 256, 0, B_CMAP8);
return; return;
} }
} }
if (_isConsumer()) { if (_isConsumer()) {
if (audioIn) { if (audioIn) {
if (m_size == B_LARGE_ICON) BIconUtils::GetVectorIcon(M_AUDIO_CONSUMER_ICON,
SetBits(M_AUDIO_CONSUMER_ICON.large, 1024, 0, B_CMAP8); sizeof(M_AUDIO_CONSUMER_ICON), this);
else if (m_size == B_MINI_ICON)
SetBits(M_AUDIO_CONSUMER_ICON.small, 256, 0, B_CMAP8);
return; return;
} } else if (videoIn) {
else if (videoIn) { BIconUtils::GetVectorIcon(M_VIDEO_CONSUMER_ICON,
if (m_size == B_LARGE_ICON) sizeof(M_VIDEO_CONSUMER_ICON), this);
SetBits(M_VIDEO_CONSUMER_ICON.large, 1024, 0, B_CMAP8);
else if (m_size == B_MINI_ICON)
SetBits(M_VIDEO_CONSUMER_ICON.small, 256, 0, B_CMAP8);
return; return;
} }
} }
// assign a default icon // assign a default icon
if (m_size == B_LARGE_ICON) BIconUtils::GetVectorIcon(M_GENERIC_ICON, sizeof(M_GENERIC_ICON), this);
SetBits(M_GENERIC_ICON.large, 1024, 0, B_CMAP8);
else if (m_size == B_MINI_ICON)
SetBits(M_GENERIC_ICON.small, 256, 0, B_CMAP8);
} }
File diff suppressed because it is too large Load Diff