2022-06-11 13:00:24 -05:00
|
|
|
/*
|
2022-06-11 21:26:46 -05:00
|
|
|
* Copyright 2009-2021 Haiku, Inc.
|
2022-06-11 13:00:24 -05:00
|
|
|
* Copyright 2022, Jaidyn Levesque <jadedctrl@teknik.io>
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT license.
|
|
|
|
*/
|
|
|
|
#ifndef IMAGE_CONTROL_LOOK_H
|
|
|
|
#define IMAGE_CONTROL_LOOK_H
|
|
|
|
|
2022-06-11 21:26:46 -05:00
|
|
|
#include <array>
|
|
|
|
|
|
|
|
#include <Bitmap.h>
|
2022-06-11 13:00:24 -05:00
|
|
|
#include <ControlLook.h>
|
|
|
|
#include <HaikuControlLook.h>
|
2022-06-11 21:26:46 -05:00
|
|
|
#include <Path.h>
|
2022-06-11 13:00:24 -05:00
|
|
|
|
|
|
|
class BControl;
|
|
|
|
class BGradientLinear;
|
|
|
|
class BView;
|
|
|
|
|
|
|
|
|
|
|
|
using BPrivate::HaikuControlLook;
|
|
|
|
|
2022-06-11 21:26:46 -05:00
|
|
|
enum {
|
|
|
|
ICL_MIDDLE,
|
|
|
|
ICL_LEFT,
|
2022-06-12 12:08:29 -05:00
|
|
|
ICL_RIGHT,
|
|
|
|
ICL_NO_SIDE
|
2022-06-11 21:26:46 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2022-06-12 10:15:17 -05:00
|
|
|
ICL_NORMAL,
|
2022-06-11 21:26:46 -05:00
|
|
|
ICL_INACTIVE,
|
|
|
|
ICL_HOVER,
|
|
|
|
ICL_DISABLED,
|
|
|
|
ICL_ACTIVATED
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-06-12 10:15:17 -05:00
|
|
|
const char* kStates[] = { "Normal", "Inactive", "Hover", "Disabled", "Activated" };
|
2022-06-12 12:08:29 -05:00
|
|
|
const char* kSides[] = { "Middle", "Left", "Right", "" };
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::array<std::array<BBitmap*, 5>, 3> SidedImages;
|
|
|
|
typedef std::array<BBitmap*, 5> UnsidedImages;
|
2022-06-11 21:26:46 -05:00
|
|
|
|
2022-06-11 13:00:24 -05:00
|
|
|
|
|
|
|
class ImageControlLook : public HaikuControlLook {
|
|
|
|
public:
|
|
|
|
ImageControlLook(image_id id);
|
|
|
|
virtual ~ImageControlLook();
|
2022-06-11 21:26:46 -05:00
|
|
|
|
|
|
|
virtual void DrawButtonFrame(BView* view, BRect& rect,
|
|
|
|
const BRect& updateRect,
|
|
|
|
const rgb_color& base,
|
|
|
|
const rgb_color& background,
|
|
|
|
uint32 flags = 0,
|
|
|
|
uint32 borders = B_ALL_BORDERS);
|
|
|
|
virtual void DrawButtonFrame(BView* view, BRect& rect,
|
|
|
|
const BRect& updateRect,
|
|
|
|
float radius,
|
|
|
|
const rgb_color& base,
|
|
|
|
const rgb_color& background,
|
|
|
|
uint32 flags = 0,
|
|
|
|
uint32 borders = B_ALL_BORDERS);
|
|
|
|
virtual void DrawButtonFrame(BView* view, BRect& rect,
|
|
|
|
const BRect& updateRect,
|
|
|
|
float leftTopRadius,
|
|
|
|
float rightTopRadius,
|
|
|
|
float leftBottomRadius,
|
|
|
|
float rightBottomRadius,
|
|
|
|
const rgb_color& base,
|
|
|
|
const rgb_color& background,
|
|
|
|
uint32 flags = 0,
|
|
|
|
uint32 borders = B_ALL_BORDERS);
|
|
|
|
|
|
|
|
virtual void DrawButtonBackground(BView* view, BRect& rect,
|
|
|
|
const BRect& updateRect,
|
|
|
|
const rgb_color& base,
|
|
|
|
uint32 flags = 0,
|
|
|
|
uint32 borders = B_ALL_BORDERS,
|
|
|
|
orientation orientation = B_HORIZONTAL);
|
|
|
|
virtual void DrawButtonBackground(BView* view, BRect& rect,
|
|
|
|
const BRect& updateRect,
|
|
|
|
float radius,
|
|
|
|
const rgb_color& base,
|
|
|
|
uint32 flags = 0,
|
|
|
|
uint32 borders = B_ALL_BORDERS,
|
|
|
|
orientation orientation = B_HORIZONTAL);
|
|
|
|
virtual void DrawButtonBackground(BView* view, BRect& rect,
|
|
|
|
const BRect& updateRect,
|
|
|
|
float leftTopRadius,
|
|
|
|
float rightTopRadius,
|
|
|
|
float leftBottomRadius,
|
|
|
|
float rightBottomRadius,
|
|
|
|
const rgb_color& base,
|
|
|
|
uint32 flags = 0,
|
|
|
|
uint32 borders = B_ALL_BORDERS,
|
|
|
|
orientation orientation = B_HORIZONTAL);
|
|
|
|
|
2022-06-12 12:08:29 -05:00
|
|
|
virtual void DrawCheckBox(BView* view, BRect& rect,
|
|
|
|
const BRect& updateRect,
|
|
|
|
const rgb_color& base,
|
|
|
|
uint32 flags = 0);
|
|
|
|
|
2022-06-12 19:42:01 -05:00
|
|
|
virtual void DrawRadioButton(BView* view, BRect& rect,
|
|
|
|
const BRect& updateRect,
|
|
|
|
const rgb_color& base,
|
|
|
|
uint32 flags = 0);
|
|
|
|
|
2022-06-12 12:49:11 -05:00
|
|
|
virtual void DrawSliderThumb(BView* view, BRect& rect,
|
|
|
|
const BRect& updateRect,
|
|
|
|
const rgb_color& base, uint32 flags,
|
|
|
|
orientation orientation);
|
|
|
|
|
|
|
|
virtual void DrawSliderTriangle(BView* view, BRect& rect,
|
|
|
|
const BRect& updateRect,
|
|
|
|
const rgb_color& base, uint32 flags,
|
|
|
|
orientation orientation);
|
|
|
|
virtual void DrawSliderTriangle(BView* view, BRect& rect,
|
|
|
|
const BRect& updateRect,
|
|
|
|
const rgb_color& base,
|
|
|
|
const rgb_color& fill, uint32 flags,
|
2022-06-12 10:15:17 -05:00
|
|
|
orientation orientation);
|
2022-06-11 21:26:46 -05:00
|
|
|
|
|
|
|
private:
|
2022-06-12 12:49:11 -05:00
|
|
|
bool _DrawImage(const char* type, uint32 state, BView* view, BRect rect,
|
|
|
|
orientation orientation = B_HORIZONTAL);
|
|
|
|
bool _DrawTiledImage(const char* type, uint32 state, BView* view,
|
|
|
|
BRect rect, BRect updateRect,
|
|
|
|
orientation orientation = B_HORIZONTAL);
|
|
|
|
|
2022-06-12 12:08:29 -05:00
|
|
|
BBitmap* _Image(const char* type, uint32 state, uint32 side = ICL_NO_SIDE);
|
|
|
|
const char* _ImagePath(const char* type, uint32 state,
|
|
|
|
uint32 side = ICL_NO_SIDE);
|
2022-06-11 21:26:46 -05:00
|
|
|
|
2022-06-12 12:49:11 -05:00
|
|
|
uint32 _FlagsToState(uint32 flags);
|
|
|
|
|
2022-06-11 21:26:46 -05:00
|
|
|
BPath fImageRoot;
|
|
|
|
|
2022-06-12 12:49:11 -05:00
|
|
|
SidedImages fButton;
|
2022-06-12 12:08:29 -05:00
|
|
|
UnsidedImages fCheckBox_Checked;
|
|
|
|
UnsidedImages fCheckBox_Unchecked;
|
2022-06-12 19:42:01 -05:00
|
|
|
UnsidedImages fRadioButton_Checked;
|
|
|
|
UnsidedImages fRadioButton_Unchecked;
|
2022-06-12 12:49:11 -05:00
|
|
|
UnsidedImages fSliderThumb;
|
|
|
|
UnsidedImages fSliderTriangle;
|
2022-06-11 13:00:24 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // IMAGE_CONTROL_LOOK_H
|