Support for vertically-oriented controls
This involved some restructuring: * Themes are now split into ./Horizontal and ./Vertical sections * DrawTiledImage() and DrawImage() work for any orientation * Better cleanup/initializing of the (now 3D) image arrays * Use named enums for state/side/orientation
|
@ -14,15 +14,17 @@ ImageControlLook::ImageControlLook(image_id id)
|
||||||
:
|
:
|
||||||
HaikuControlLook()
|
HaikuControlLook()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++)
|
for (int orient = 0; orient < 2; orient++) {
|
||||||
fButton[i].fill(NULL);
|
for (int side = 0; side < 3; side++)
|
||||||
|
fButton[orient][side].fill(NULL);
|
||||||
|
|
||||||
fCheckBox_Checked.fill(NULL);
|
fCheckBox_Checked[orient].fill(NULL);
|
||||||
fCheckBox_Unchecked.fill(NULL);
|
fCheckBox_Unchecked[orient].fill(NULL);
|
||||||
fRadioButton_Checked.fill(NULL);
|
fRadioButton_Checked[orient].fill(NULL);
|
||||||
fRadioButton_Unchecked.fill(NULL);
|
fRadioButton_Unchecked[orient].fill(NULL);
|
||||||
fSliderThumb.fill(NULL);
|
fSliderThumb[orient].fill(NULL);
|
||||||
fSliderTriangle.fill(NULL);
|
fSliderTriangle[orient].fill(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
fImageRoot = BPath("/boot/home/Desktop/projects/haiku/ImageControlLook/data/ImageThemes/Akva/");
|
fImageRoot = BPath("/boot/home/Desktop/projects/haiku/ImageControlLook/data/ImageThemes/Akva/");
|
||||||
}
|
}
|
||||||
|
@ -31,9 +33,18 @@ ImageControlLook::ImageControlLook(image_id id)
|
||||||
|
|
||||||
ImageControlLook::~ImageControlLook()
|
ImageControlLook::~ImageControlLook()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++)
|
for (int orient = 0; orient < 2; orient++)
|
||||||
for (int j = 0; j < 6; j++)
|
for (int state = 0; state < 5; state++) {
|
||||||
delete fButton[i][j];
|
for (int side = 0; side < 3; side++)
|
||||||
|
delete fButton[orient][side][state];
|
||||||
|
|
||||||
|
delete fCheckBox_Checked[orient][state];
|
||||||
|
delete fCheckBox_Unchecked[orient][state];
|
||||||
|
delete fRadioButton_Checked[orient][state];
|
||||||
|
delete fRadioButton_Unchecked[orient][state];
|
||||||
|
delete fSliderThumb[orient][state];
|
||||||
|
delete fSliderTriangle[orient][state];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +53,7 @@ void
|
||||||
ImageControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
|
ImageControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
|
||||||
const rgb_color& base, const rgb_color& background, uint32 flags, uint32 borders)
|
const rgb_color& base, const rgb_color& background, uint32 flags, uint32 borders)
|
||||||
{
|
{
|
||||||
if (_Image("Button", ICL_MIDDLE, ICL_NORMAL) == NULL)
|
if (_Image("Button", ICL_NORMAL, ICL_MIDDLE) == NULL)
|
||||||
HaikuControlLook::DrawButtonFrame(view, rect, updateRect, base, background, flags, borders);
|
HaikuControlLook::DrawButtonFrame(view, rect, updateRect, base, background, flags, borders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +62,7 @@ void
|
||||||
ImageControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect, float radius,
|
ImageControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect, float radius,
|
||||||
const rgb_color& base, const rgb_color& background, uint32 flags, uint32 borders)
|
const rgb_color& base, const rgb_color& background, uint32 flags, uint32 borders)
|
||||||
{
|
{
|
||||||
if (_Image("Button", ICL_MIDDLE, ICL_NORMAL) == NULL)
|
if (_Image("Button", ICL_NORMAL, ICL_MIDDLE) == NULL)
|
||||||
HaikuControlLook::DrawButtonFrame(view, rect, updateRect, radius, base, background, flags,
|
HaikuControlLook::DrawButtonFrame(view, rect, updateRect, radius, base, background, flags,
|
||||||
borders);
|
borders);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +73,7 @@ ImageControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateR
|
||||||
float leftTopRadius, float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
|
float leftTopRadius, float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
|
||||||
const rgb_color& base, const rgb_color& background, uint32 flags, uint32 borders)
|
const rgb_color& base, const rgb_color& background, uint32 flags, uint32 borders)
|
||||||
{
|
{
|
||||||
if (_Image("Button", ICL_MIDDLE, ICL_NORMAL) == NULL)
|
if (_Image("Button", ICL_NORMAL, ICL_MIDDLE) == NULL)
|
||||||
HaikuControlLook::DrawButtonFrame(view, rect, updateRect, leftTopRadius, rightTopRadius,
|
HaikuControlLook::DrawButtonFrame(view, rect, updateRect, leftTopRadius, rightTopRadius,
|
||||||
leftBottomRadius, rightBottomRadius, base, background, flags, borders);
|
leftBottomRadius, rightBottomRadius, base, background, flags, borders);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +83,7 @@ void
|
||||||
ImageControlLook::DrawButtonBackground(BView* view, BRect& rect, const BRect& updateRect,
|
ImageControlLook::DrawButtonBackground(BView* view, BRect& rect, const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags, uint32 borders, orientation orientation)
|
const rgb_color& base, uint32 flags, uint32 borders, orientation orientation)
|
||||||
{
|
{
|
||||||
if (!_DrawTiledImage("Button", _FlagsToState(flags), view, rect, updateRect, orientation))
|
if (!_DrawTiledImage("Button", flags, view, rect, updateRect, orientation))
|
||||||
HaikuControlLook::DrawButtonBackground(view, rect, updateRect, base, flags, borders,
|
HaikuControlLook::DrawButtonBackground(view, rect, updateRect, base, flags, borders,
|
||||||
orientation);
|
orientation);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +93,7 @@ void
|
||||||
ImageControlLook::DrawButtonBackground(BView* view, BRect& rect, const BRect& updateRect,
|
ImageControlLook::DrawButtonBackground(BView* view, BRect& rect, const BRect& updateRect,
|
||||||
float radius, const rgb_color& base, uint32 flags, uint32 borders, orientation orientation)
|
float radius, const rgb_color& base, uint32 flags, uint32 borders, orientation orientation)
|
||||||
{
|
{
|
||||||
if (!_DrawTiledImage("Button", _FlagsToState(flags), view, rect, updateRect, orientation))
|
if (!_DrawTiledImage("Button", flags, view, rect, updateRect, orientation))
|
||||||
HaikuControlLook::DrawButtonBackground(view, rect, updateRect, radius, base, flags, borders,
|
HaikuControlLook::DrawButtonBackground(view, rect, updateRect, radius, base, flags, borders,
|
||||||
orientation);
|
orientation);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +104,7 @@ ImageControlLook::DrawButtonBackground(BView* view, BRect& rect, const BRect& up
|
||||||
float leftTopRadius, float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
|
float leftTopRadius, float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
|
||||||
const rgb_color& base, uint32 flags, uint32 borders, orientation orientation)
|
const rgb_color& base, uint32 flags, uint32 borders, orientation orientation)
|
||||||
{
|
{
|
||||||
if (!_DrawTiledImage("Button", _FlagsToState(flags), view, rect, updateRect, orientation))
|
if (!_DrawTiledImage("Button", flags, view, rect, updateRect, orientation))
|
||||||
HaikuControlLook::DrawButtonBackground(view, rect, updateRect, leftTopRadius,
|
HaikuControlLook::DrawButtonBackground(view, rect, updateRect, leftTopRadius,
|
||||||
rightTopRadius,leftBottomRadius, rightBottomRadius, base, flags, borders, orientation);
|
rightTopRadius,leftBottomRadius, rightBottomRadius, base, flags, borders, orientation);
|
||||||
}
|
}
|
||||||
|
@ -105,9 +116,9 @@ ImageControlLook::DrawCheckBox(BView* view, BRect& rect, const BRect& updateRect
|
||||||
{
|
{
|
||||||
bool drawn = false;
|
bool drawn = false;
|
||||||
if (((BControl*)view)->Value() == B_CONTROL_ON)
|
if (((BControl*)view)->Value() == B_CONTROL_ON)
|
||||||
drawn = _DrawImage("CheckBox-Checked", _FlagsToState(flags & ~B_ACTIVATED), view, rect);
|
drawn = _DrawImage("CheckBox-Checked", flags & ~B_ACTIVATED, view, rect);
|
||||||
else
|
else
|
||||||
drawn = _DrawImage("CheckBox-Unchecked", _FlagsToState(flags), view, rect);
|
drawn = _DrawImage("CheckBox-Unchecked", flags, view, rect);
|
||||||
|
|
||||||
if (!drawn)
|
if (!drawn)
|
||||||
HaikuControlLook::DrawCheckBox(view, rect, updateRect, base, flags);
|
HaikuControlLook::DrawCheckBox(view, rect, updateRect, base, flags);
|
||||||
|
@ -120,9 +131,9 @@ ImageControlLook::DrawRadioButton(BView* view, BRect& rect, const BRect& updateR
|
||||||
{
|
{
|
||||||
bool drawn = false;
|
bool drawn = false;
|
||||||
if (((BControl*)view)->Value() == B_CONTROL_ON)
|
if (((BControl*)view)->Value() == B_CONTROL_ON)
|
||||||
drawn = _DrawImage("RadioButton-Checked", _FlagsToState(flags & ~B_ACTIVATED), view, rect);
|
drawn = _DrawImage("RadioButton-Checked", flags & ~B_ACTIVATED, view, rect);
|
||||||
else
|
else
|
||||||
drawn = _DrawImage("RadioButton-Unchecked", _FlagsToState(flags), view, rect);
|
drawn = _DrawImage("RadioButton-Unchecked", flags, view, rect);
|
||||||
|
|
||||||
if (!drawn)
|
if (!drawn)
|
||||||
HaikuControlLook::DrawRadioButton(view, rect, updateRect, base, flags);
|
HaikuControlLook::DrawRadioButton(view, rect, updateRect, base, flags);
|
||||||
|
@ -133,7 +144,7 @@ void
|
||||||
ImageControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect,
|
ImageControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags, orientation orientation)
|
const rgb_color& base, uint32 flags, orientation orientation)
|
||||||
{
|
{
|
||||||
if (!_DrawImage("SliderThumb", _FlagsToState(flags), view, rect, orientation))
|
if (!_DrawImage("SliderThumb", flags, view, rect, orientation))
|
||||||
HaikuControlLook::DrawSliderThumb(view, rect, updateRect, base, flags, orientation);
|
HaikuControlLook::DrawSliderThumb(view, rect, updateRect, base, flags, orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +153,7 @@ void
|
||||||
ImageControlLook::DrawSliderTriangle(BView* view, BRect& rect, const BRect& updateRect,
|
ImageControlLook::DrawSliderTriangle(BView* view, BRect& rect, const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags, orientation orientation)
|
const rgb_color& base, uint32 flags, orientation orientation)
|
||||||
{
|
{
|
||||||
if (!_DrawImage("SliderTriangle", _FlagsToState(flags), view, rect, orientation))
|
if (!_DrawImage("SliderTriangle", flags, view, rect, orientation))
|
||||||
HaikuControlLook::DrawSliderTriangle(view, rect, updateRect, base, flags, orientation);
|
HaikuControlLook::DrawSliderTriangle(view, rect, updateRect, base, flags, orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,18 +162,18 @@ void
|
||||||
ImageControlLook::DrawSliderTriangle(BView* view, BRect& rect, const BRect& updateRect,
|
ImageControlLook::DrawSliderTriangle(BView* view, BRect& rect, const BRect& updateRect,
|
||||||
const rgb_color& base, const rgb_color& fill, uint32 flags, orientation orientation)
|
const rgb_color& base, const rgb_color& fill, uint32 flags, orientation orientation)
|
||||||
{
|
{
|
||||||
if (!_DrawImage("SliderTriangle", _FlagsToState(flags), view, rect, orientation))
|
if (!_DrawImage("SliderTriangle", flags, view, rect, orientation))
|
||||||
HaikuControlLook::DrawSliderTriangle(view, rect, updateRect, base, fill, flags,
|
HaikuControlLook::DrawSliderTriangle(view, rect, updateRect, base, fill, flags,
|
||||||
orientation);
|
orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ImageControlLook::_DrawImage(const char* type, uint32 state, BView* view, BRect rect,
|
ImageControlLook::_DrawImage(const char* type, icl_state state, BView* view, BRect rect,
|
||||||
orientation orientation)
|
icl_orient orientation)
|
||||||
{
|
{
|
||||||
BBitmap* image = _Image(type, state);
|
BBitmap* image = _Image(type, state, ICL_NO_SIDE, orientation);
|
||||||
if (image != NULL && orientation == B_HORIZONTAL) {
|
if (image != NULL) {
|
||||||
view->SetDrawingMode(B_OP_ALPHA);
|
view->SetDrawingMode(B_OP_ALPHA);
|
||||||
view->DrawBitmap(image, rect);
|
view->DrawBitmap(image, rect);
|
||||||
return true;
|
return true;
|
||||||
|
@ -172,48 +183,86 @@ ImageControlLook::_DrawImage(const char* type, uint32 state, BView* view, BRect
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ImageControlLook::_DrawTiledImage(const char* type, uint32 state, BView* view, BRect rect,
|
ImageControlLook::_DrawImage(const char* type, uint32 flags, BView* view, BRect rect,
|
||||||
BRect updateRect, orientation orientation)
|
orientation orientation)
|
||||||
{
|
{
|
||||||
BBitmap* tile = _Image(type, state, ICL_MIDDLE);
|
return _DrawImage(type, _FlagsToState(flags), view, rect, _ICLOrientation(orientation));
|
||||||
BBitmap* left = _Image(type, state, ICL_LEFT);
|
}
|
||||||
BBitmap* right = _Image(type, state, ICL_RIGHT);
|
|
||||||
|
|
||||||
if (orientation == B_VERTICAL || tile == NULL)
|
|
||||||
|
bool
|
||||||
|
ImageControlLook::_DrawTiledImage(const char* type, icl_state state, BView* view, BRect rect,
|
||||||
|
BRect updateRect, icl_orient orientation)
|
||||||
|
{
|
||||||
|
BBitmap* tile = _Image(type, state, ICL_MIDDLE, orientation);
|
||||||
|
BBitmap* left = _Image(type, state, ICL_LEFT, orientation);
|
||||||
|
BBitmap* right = _Image(type, state, ICL_RIGHT, orientation);
|
||||||
|
|
||||||
|
if (tile == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
float minX = 0;
|
bool horiz = orientation == ICL_HORIZONTAL;
|
||||||
float maxX = rect.Width();
|
|
||||||
if (left != NULL)
|
|
||||||
minX = left->Bounds().Width();
|
|
||||||
if (right != NULL)
|
|
||||||
maxX = rect.Width() - right->Bounds().Width();
|
|
||||||
|
|
||||||
float heightRatio = rect.Height() / tile->Bounds().Height();
|
float min = 0;
|
||||||
float sliceWidth = heightRatio * tile->Bounds().Width();
|
float max = horiz ? rect.Width() : rect.Height();
|
||||||
|
if (left != NULL)
|
||||||
|
min = horiz ? left->Bounds().Width() : left->Bounds().Height();
|
||||||
|
if (right != NULL)
|
||||||
|
if (horiz)
|
||||||
|
max = rect.Width() - right->Bounds().Width();
|
||||||
|
else
|
||||||
|
max = rect.Height() - right->Bounds().Height();
|
||||||
|
|
||||||
|
float sliceRatio = rect.Height() / tile->Bounds().Height();
|
||||||
|
float sliceSize = sliceRatio * tile->Bounds().Width();
|
||||||
|
if (!horiz) {
|
||||||
|
sliceRatio = rect.Width() / tile->Bounds().Width();
|
||||||
|
sliceSize = sliceRatio * tile->Bounds().Height();
|
||||||
|
}
|
||||||
|
|
||||||
view->SetDrawingMode(B_OP_ALPHA);
|
view->SetDrawingMode(B_OP_ALPHA);
|
||||||
|
|
||||||
|
// This is repetitive and not done well (the horiz and vert blocks are pretty much identical)
|
||||||
BRect tileRect;
|
BRect tileRect;
|
||||||
tileRect.top = 0;
|
if (horiz) {
|
||||||
tileRect.bottom = rect.Height();
|
tileRect.top = 0;
|
||||||
for (float left = minX; left + sliceWidth < maxX; left += sliceWidth) {
|
tileRect.bottom = rect.Height();
|
||||||
tileRect.left = left;
|
for (float left = min; left + sliceSize < max; left += sliceSize) {
|
||||||
tileRect.right = left + sliceWidth;
|
tileRect.left = left;
|
||||||
|
tileRect.right = left + sliceSize;
|
||||||
|
if (tileRect.Intersects(updateRect))
|
||||||
|
view->DrawBitmap(tile, tileRect);
|
||||||
|
}
|
||||||
|
tileRect.right = max;
|
||||||
|
tileRect.left = max - sliceSize;
|
||||||
|
if (tileRect.Intersects(updateRect))
|
||||||
|
view->DrawBitmap(tile, tileRect);
|
||||||
|
} else {
|
||||||
|
tileRect.left = 0;
|
||||||
|
tileRect.right = rect.Width();
|
||||||
|
for (float top = min; top + sliceSize < max; top += sliceSize) {
|
||||||
|
tileRect.top = top;
|
||||||
|
tileRect.bottom = top + sliceSize;
|
||||||
|
if (tileRect.Intersects(updateRect))
|
||||||
|
view->DrawBitmap(tile, tileRect);
|
||||||
|
}
|
||||||
|
tileRect.bottom = max;
|
||||||
|
tileRect.top = max - sliceSize;
|
||||||
if (tileRect.Intersects(updateRect))
|
if (tileRect.Intersects(updateRect))
|
||||||
view->DrawBitmap(tile, tileRect);
|
view->DrawBitmap(tile, tileRect);
|
||||||
}
|
}
|
||||||
tileRect.right = maxX;
|
|
||||||
tileRect.left = maxX - sliceWidth;
|
|
||||||
if (tileRect.Intersects(updateRect))
|
|
||||||
view->DrawBitmap(tile, tileRect);
|
|
||||||
|
|
||||||
BRect sideRect(0, 0, minX, rect.Height());
|
BRect sideRect = horiz ? BRect(0, 0, min, rect.Height()) : BRect(0, 0, rect.Width(), min);
|
||||||
if (left != NULL && sideRect.Intersects(updateRect))
|
if (left != NULL && sideRect.Intersects(updateRect))
|
||||||
view->DrawBitmap(left, sideRect);
|
view->DrawBitmap(left, sideRect);
|
||||||
|
|
||||||
sideRect.left = maxX;
|
if (horiz) {
|
||||||
sideRect.right = view->Bounds().right;
|
sideRect.left = max;
|
||||||
|
sideRect.right = view->Bounds().right;
|
||||||
|
} else {
|
||||||
|
sideRect.top = max;
|
||||||
|
sideRect.bottom = view->Bounds().bottom;
|
||||||
|
}
|
||||||
if (right != NULL && sideRect.Intersects(updateRect))
|
if (right != NULL && sideRect.Intersects(updateRect))
|
||||||
view->DrawBitmap(right, sideRect);
|
view->DrawBitmap(right, sideRect);
|
||||||
|
|
||||||
|
@ -221,8 +270,17 @@ ImageControlLook::_DrawTiledImage(const char* type, uint32 state, BView* view, B
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
ImageControlLook::_DrawTiledImage(const char* type, uint32 flags, BView* view, BRect rect,
|
||||||
|
BRect updateRect, orientation orientation)
|
||||||
|
{
|
||||||
|
return _DrawTiledImage(type, _FlagsToState(flags), view, rect, updateRect,
|
||||||
|
_ICLOrientation(orientation));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
ImageControlLook::_Image(const char* type, uint32 state, uint32 side)
|
ImageControlLook::_Image(const char* type, icl_state state, icl_side side, icl_orient orientation)
|
||||||
{
|
{
|
||||||
SidedImages* sideList = NULL;
|
SidedImages* sideList = NULL;
|
||||||
UnsidedImages* nosideList = NULL;
|
UnsidedImages* nosideList = NULL;
|
||||||
|
@ -243,27 +301,33 @@ ImageControlLook::_Image(const char* type, uint32 state, uint32 side)
|
||||||
else if (strcmp(type, "SliderTriangle") == 0)
|
else if (strcmp(type, "SliderTriangle") == 0)
|
||||||
nosideList = &fSliderTriangle;
|
nosideList = &fSliderTriangle;
|
||||||
|
|
||||||
if (sideList != NULL && (*sideList)[side][state] == NULL)
|
if (sideList != NULL && (*sideList)[orientation][side][state] == NULL)
|
||||||
(*sideList)[side][state] = BTranslationUtils::GetBitmapFile(_ImagePath(type, state, side));
|
(*sideList)[orientation][side][state]
|
||||||
|
= BTranslationUtils::GetBitmapFile(_ImagePath(type, state, side, orientation));
|
||||||
if (sideList != NULL)
|
if (sideList != NULL)
|
||||||
image = (*sideList)[side][state];
|
image = (*sideList)[orientation][side][state];
|
||||||
|
|
||||||
if (nosideList != NULL && (*nosideList)[state] == NULL)
|
if (nosideList != NULL && (*nosideList)[orientation][state] == NULL)
|
||||||
(*nosideList)[state] = BTranslationUtils::GetBitmapFile(_ImagePath(type, state));
|
(*nosideList)[orientation][state]
|
||||||
|
= BTranslationUtils::GetBitmapFile(_ImagePath(type, state, ICL_NO_SIDE, orientation));
|
||||||
if (nosideList != NULL)
|
if (nosideList != NULL)
|
||||||
image = (*nosideList)[state];
|
image = (*nosideList)[orientation][state];
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
ImageControlLook::_ImagePath(const char* type, uint32 state, uint32 side)
|
ImageControlLook::_ImagePath(const char* type, icl_state state, icl_side side, icl_orient orientation)
|
||||||
{
|
{
|
||||||
BString leaf = kStates[state];
|
BString leaf = kStates[state];
|
||||||
leaf << kSides[side];
|
leaf << kSides[side];
|
||||||
|
|
||||||
BPath imgPath(fImageRoot.Path());
|
BPath imgPath(fImageRoot.Path());
|
||||||
|
if (orientation == ICL_VERTICAL)
|
||||||
|
imgPath.Append("Vertical");
|
||||||
|
else
|
||||||
|
imgPath.Append("Horizontal");
|
||||||
imgPath.Append(type);
|
imgPath.Append(type);
|
||||||
imgPath.Append(leaf);
|
imgPath.Append(leaf);
|
||||||
printf("[ImageControlLook] Searching for %s…\n", imgPath.Path());
|
printf("[ImageControlLook] Searching for %s…\n", imgPath.Path());
|
||||||
|
@ -271,10 +335,10 @@ ImageControlLook::_ImagePath(const char* type, uint32 state, uint32 side)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
icl_state
|
||||||
ImageControlLook::_FlagsToState(uint32 flags)
|
ImageControlLook::_FlagsToState(uint32 flags)
|
||||||
{
|
{
|
||||||
uint32 state = ICL_NORMAL;
|
icl_state state = ICL_NORMAL;
|
||||||
if (flags & B_DISABLED)
|
if (flags & B_DISABLED)
|
||||||
state = ICL_DISABLED;
|
state = ICL_DISABLED;
|
||||||
else if (flags & (B_ACTIVATED | B_PARTIALLY_ACTIVATED | B_CLICKED))
|
else if (flags & (B_ACTIVATED | B_PARTIALLY_ACTIVATED | B_CLICKED))
|
||||||
|
@ -285,6 +349,15 @@ ImageControlLook::_FlagsToState(uint32 flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
icl_orient
|
||||||
|
ImageControlLook::_ICLOrientation(orientation orientation)
|
||||||
|
{
|
||||||
|
if (orientation == B_VERTICAL)
|
||||||
|
return ICL_VERTICAL;
|
||||||
|
return ICL_HORIZONTAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" BControlLook* (instantiate_control_look)(image_id id)
|
extern "C" BControlLook* (instantiate_control_look)(image_id id)
|
||||||
{
|
{
|
||||||
return new (std::nothrow)ImageControlLook(id);
|
return new (std::nothrow)ImageControlLook(id);
|
||||||
|
|
|
@ -20,14 +20,19 @@ class BView;
|
||||||
|
|
||||||
using BPrivate::HaikuControlLook;
|
using BPrivate::HaikuControlLook;
|
||||||
|
|
||||||
enum {
|
enum icl_orient {
|
||||||
|
ICL_HORIZONTAL,
|
||||||
|
ICL_VERTICAL
|
||||||
|
};
|
||||||
|
|
||||||
|
enum icl_side {
|
||||||
ICL_MIDDLE,
|
ICL_MIDDLE,
|
||||||
ICL_LEFT,
|
ICL_LEFT,
|
||||||
ICL_RIGHT,
|
ICL_RIGHT,
|
||||||
ICL_NO_SIDE
|
ICL_NO_SIDE
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum icl_state {
|
||||||
ICL_NORMAL,
|
ICL_NORMAL,
|
||||||
ICL_INACTIVE,
|
ICL_INACTIVE,
|
||||||
ICL_HOVER,
|
ICL_HOVER,
|
||||||
|
@ -40,8 +45,8 @@ const char* kStates[] = { "Normal", "Inactive", "Hover", "Disabled", "Activated"
|
||||||
const char* kSides[] = { "Middle", "Left", "Right", "" };
|
const char* kSides[] = { "Middle", "Left", "Right", "" };
|
||||||
|
|
||||||
|
|
||||||
typedef std::array<std::array<BBitmap*, 5>, 3> SidedImages;
|
typedef std::array<std::array<std::array<BBitmap*, 5>, 3>, 2> SidedImages;
|
||||||
typedef std::array<BBitmap*, 5> UnsidedImages;
|
typedef std::array<std::array<BBitmap*, 5>, 2> UnsidedImages;
|
||||||
|
|
||||||
|
|
||||||
class ImageControlLook : public HaikuControlLook {
|
class ImageControlLook : public HaikuControlLook {
|
||||||
|
@ -123,17 +128,27 @@ public:
|
||||||
orientation orientation);
|
orientation orientation);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _DrawImage(const char* type, uint32 state, BView* view, BRect rect,
|
bool _DrawImage(const char* type, icl_state state, BView* view, BRect rect,
|
||||||
|
icl_orient orientation = ICL_HORIZONTAL);
|
||||||
|
bool _DrawImage(const char* type, uint32 flags, BView* view, BRect rect,
|
||||||
orientation orientation = B_HORIZONTAL);
|
orientation orientation = B_HORIZONTAL);
|
||||||
bool _DrawTiledImage(const char* type, uint32 state, BView* view,
|
|
||||||
|
bool _DrawTiledImage(const char* type, icl_state state, BView* view,
|
||||||
|
BRect rect, BRect updateRect,
|
||||||
|
icl_orient orientation = ICL_HORIZONTAL);
|
||||||
|
bool _DrawTiledImage(const char* type, uint32 flags, BView* view,
|
||||||
BRect rect, BRect updateRect,
|
BRect rect, BRect updateRect,
|
||||||
orientation orientation = B_HORIZONTAL);
|
orientation orientation = B_HORIZONTAL);
|
||||||
|
|
||||||
BBitmap* _Image(const char* type, uint32 state, uint32 side = ICL_NO_SIDE);
|
BBitmap* _Image(const char* type, icl_state state,
|
||||||
const char* _ImagePath(const char* type, uint32 state,
|
icl_side side = ICL_NO_SIDE,
|
||||||
uint32 side = ICL_NO_SIDE);
|
icl_orient orientation = ICL_HORIZONTAL);
|
||||||
|
const char* _ImagePath(const char* type, icl_state state,
|
||||||
|
icl_side side = ICL_NO_SIDE,
|
||||||
|
icl_orient orientation = ICL_HORIZONTAL);
|
||||||
|
|
||||||
uint32 _FlagsToState(uint32 flags);
|
icl_state _FlagsToState(uint32 flags);
|
||||||
|
icl_orient _ICLOrientation(orientation orientation);
|
||||||
|
|
||||||
BPath fImageRoot;
|
BPath fImageRoot;
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 612 B After Width: | Height: | Size: 612 B |
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 190 B |
Before Width: | Height: | Size: 691 B After Width: | Height: | Size: 691 B |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 606 B After Width: | Height: | Size: 606 B |
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 183 B |
Before Width: | Height: | Size: 697 B After Width: | Height: | Size: 697 B |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 632 B After Width: | Height: | Size: 632 B |
Before Width: | Height: | Size: 184 B After Width: | Height: | Size: 184 B |
Before Width: | Height: | Size: 644 B After Width: | Height: | Size: 644 B |
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 893 B |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 894 B After Width: | Height: | Size: 894 B |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 756 B After Width: | Height: | Size: 756 B |
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 648 B After Width: | Height: | Size: 648 B |
Before Width: | Height: | Size: 963 B After Width: | Height: | Size: 963 B |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 890 B After Width: | Height: | Size: 890 B |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 901 B After Width: | Height: | Size: 901 B |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 832 B After Width: | Height: | Size: 832 B |
Before Width: | Height: | Size: 136 B After Width: | Height: | Size: 136 B |
Before Width: | Height: | Size: 93 B After Width: | Height: | Size: 93 B |
Before Width: | Height: | Size: 135 B After Width: | Height: | Size: 135 B |
Before Width: | Height: | Size: 668 B After Width: | Height: | Size: 668 B |
Before Width: | Height: | Size: 657 B After Width: | Height: | Size: 657 B |
Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 670 B |
Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 670 B |
Before Width: | Height: | Size: 681 B After Width: | Height: | Size: 681 B |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 432 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 423 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 1003 B |
After Width: | Height: | Size: 330 B |
After Width: | Height: | Size: 906 B |
|
@ -0,0 +1 @@
|
||||||
|
These images were automatically generated from the Horizontal variants with util/RotateICLTheme.sh
|
After Width: | Height: | Size: 999 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 995 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 8.7 KiB |
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
||||||
|
# Name: RotateICLTheme.sh
|
||||||
|
# Desc: Creates vertical images from the horizontal versions of a theme's
|
||||||
|
# controls (for orientable controls).
|
||||||
|
# Reqs: ImageMagick
|
||||||
|
# Date: 2022-06
|
||||||
|
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
||||||
|
|
||||||
|
ORIENTABLES="Button SliderThumb SliderTriangle"
|
||||||
|
|
||||||
|
THEME_ROOT="$1"
|
||||||
|
if test -z "$THEME_ROOT" -o ! -d "$THEME_ROOT/Horizontal"; then
|
||||||
|
echo "Usage: $(basename $0) theme_root"
|
||||||
|
if test -n "$THEME_ROOT"; then
|
||||||
|
echo ""
|
||||||
|
echo "There is no 'Horizontal' directory under the given theme root, $THEME_ROOT."
|
||||||
|
echo "Please make sure you have your theme in the proper format."
|
||||||
|
fi
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
for orientable in $ORIENTABLES; do
|
||||||
|
mkdir -p "$THEME_ROOT/Vertical/$orientable"
|
||||||
|
for file in $THEME_ROOT/Horizontal/$orientable/*; do
|
||||||
|
convert -rotate "90" "$file" "$THEME_ROOT/Vertical/$orientable/$(basename "$file")"
|
||||||
|
done
|
||||||
|
done
|