BitmapButton: move from WebPositive to libshared

Remove a currently unused copy of it from HaikuDepot.

Change-Id: Idb97fae8e7190da6bc1049b3c1f1df929ea91bab
Reviewed-on: https://review.haiku-os.org/c/1506
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Adrien Destugues
2019-06-16 14:51:01 +00:00
committed by waddlesplash
parent d689db1448
commit f74f860085
10 changed files with 24 additions and 207 deletions
@@ -6,26 +6,29 @@
#define BITMAP_BUTTON_H #define BITMAP_BUTTON_H
#include <Button.h> #include <Button.h>
#include <Size.h>
class BBitmap; class BBitmap;
class BitmapButton : public BButton { namespace BPrivate {
class BBitmapButton : public BButton {
public: public:
enum { enum {
BUTTON_BACKGROUND = 0, BUTTON_BACKGROUND = 0,
MENUBAR_BACKGROUND, MENUBAR_BACKGROUND,
}; };
BitmapButton(const char* resourceName, BBitmapButton(const char* resourceName,
BMessage* message); BMessage* message);
BitmapButton(const uint8* bits, uint32 width, BBitmapButton(const uint8* bits, uint32 width,
uint32 height, color_space format, uint32 height, color_space format,
BMessage* message); BMessage* message);
virtual ~BitmapButton(); virtual ~BBitmapButton();
virtual BSize MinSize(); virtual BSize MinSize();
virtual BSize MaxSize(); virtual BSize MaxSize();
@@ -40,5 +43,9 @@ private:
uint32 fBackgroundMode; uint32 fBackgroundMode;
}; };
};
using BPrivate::BBitmapButton;
#endif // BITMAP_BUTTON_H #endif // BITMAP_BUTTON_H
-1
View File
@@ -113,7 +113,6 @@ local textDocumentSources =
local applicationSources = local applicationSources =
App.cpp App.cpp
BarberPole.cpp BarberPole.cpp
BitmapButton.cpp
BitmapView.cpp BitmapView.cpp
DecisionProvider.cpp DecisionProvider.cpp
FeaturedPackagesView.cpp FeaturedPackagesView.cpp
+1 -2
View File
@@ -36,7 +36,6 @@
#include <package/hpkg/PackageContentHandler.h> #include <package/hpkg/PackageContentHandler.h>
#include <package/hpkg/PackageEntry.h> #include <package/hpkg/PackageEntry.h>
#include "BitmapButton.h"
#include "BitmapView.h" #include "BitmapView.h"
#include "LinkView.h" #include "LinkView.h"
#include "LinkedBitmapView.h" #include "LinkedBitmapView.h"
@@ -1446,4 +1445,4 @@ PackageInfoView::Clear()
fPackageListener->SetPackage(PackageInfoRef(NULL)); fPackageListener->SetPackage(PackageInfoRef(NULL));
fPackage.Unset(); fPackage.Unset();
} }
@@ -1,144 +0,0 @@
/*
* Copyright 2013, Stephan Aßmus <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "BitmapButton.h"
#include <ControlLook.h>
#include <LayoutUtils.h>
#include <Window.h>
BitmapButton::BitmapButton(const char* name, BMessage* message)
:
BitmapView(name),
BInvoker(message, NULL, NULL),
fMouseInside(false),
fMouseDown(false)
{
SetScaleBitmap(false);
}
BitmapButton::~BitmapButton()
{
}
void
BitmapButton::AttachedToWindow()
{
// TODO: Init fMouseInside
BitmapView::AttachedToWindow();
}
void
BitmapButton::MouseMoved(BPoint where, uint32 transit,
const BMessage* dragMessage)
{
int32 buttons = 0;
if (Window() != NULL && Window()->CurrentMessage() != NULL)
Window()->CurrentMessage()->FindInt32("buttons", &buttons);
bool ignoreEvent = dragMessage != NULL || (!fMouseDown && buttons != 0);
_SetMouseInside(!ignoreEvent && transit == B_INSIDE_VIEW);
}
void
BitmapButton::MouseDown(BPoint where)
{
if (fMouseInside) {
_SetMouseDown(true);
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
}
}
void
BitmapButton::MouseUp(BPoint where)
{
_SetMouseDown(false);
if (fMouseInside)
Invoke();
}
BSize
BitmapButton::MinSize()
{
BSize size = BitmapView::MinSize();
size.width += 6;
size.height += 6;
return BLayoutUtils::ComposeSize(ExplicitMinSize(), size);
}
BSize
BitmapButton::PreferredSize()
{
BSize size = MinSize();
return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), size);
}
BSize
BitmapButton::MaxSize()
{
BSize size = MinSize();
return BLayoutUtils::ComposeSize(ExplicitMaxSize(), size);
}
// #pragma mark -
void
BitmapButton::DrawBackground(BRect& bounds, BRect updateRect)
{
if (Message() != NULL && (fMouseInside || fMouseDown)) {
rgb_color color = LowColor();
uint32 flags = 0;
if (fMouseDown)
flags |= BControlLook::B_ACTIVATED;
be_control_look->DrawButtonFrame(this, bounds, updateRect,
color, color, flags);
be_control_look->DrawButtonBackground(this, bounds, updateRect,
color, flags);
} else {
BitmapView::DrawBackground(bounds, updateRect);
}
}
// #pragma mark -
void
BitmapButton::_SetMouseInside(bool inside)
{
if (fMouseInside == inside)
return;
fMouseInside = inside;
if (Message() != NULL)
Invalidate();
}
void
BitmapButton::_SetMouseDown(bool down)
{
if (fMouseDown == down)
return;
fMouseDown = down;
if (Message() != NULL)
Invalidate();
}
@@ -1,44 +0,0 @@
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef BITMAP_BUTTON_H
#define BITMAP_BUTTON_H
#include <Invoker.h>
#include "BitmapView.h"
class BitmapButton : public BitmapView, public BInvoker {
public:
BitmapButton(const char* name,
BMessage* message = NULL);
virtual ~BitmapButton();
virtual void AttachedToWindow();
virtual void MouseMoved(BPoint where, uint32 transit,
const BMessage* dragMessage);
virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where);
virtual BSize MinSize();
virtual BSize PreferredSize();
virtual BSize MaxSize();
protected:
virtual void DrawBackground(BRect& bounds,
BRect updateRect);
private:
void _SetMouseInside(bool inside);
void _SetMouseDown(bool down);
private:
bool fMouseInside;
bool fMouseDown;
};
#endif // BITMAP_VIEW_H
+2 -2
View File
@@ -605,10 +605,10 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
) )
; ;
BitmapButton* toggleFullscreenButton = new BitmapButton(kWindowIconBits, BBitmapButton* toggleFullscreenButton = new BBitmapButton(kWindowIconBits,
kWindowIconWidth, kWindowIconHeight, kWindowIconFormat, kWindowIconWidth, kWindowIconHeight, kWindowIconFormat,
new BMessage(TOGGLE_FULLSCREEN)); new BMessage(TOGGLE_FULLSCREEN));
toggleFullscreenButton->SetBackgroundMode(BitmapButton::MENUBAR_BACKGROUND); toggleFullscreenButton->SetBackgroundMode(BBitmapButton::MENUBAR_BACKGROUND);
BGroupLayout* menuBarGroup = BLayoutBuilder::Group<>(B_HORIZONTAL, 0.0) BGroupLayout* menuBarGroup = BLayoutBuilder::Group<>(B_HORIZONTAL, 0.0)
.Add(mainMenu) .Add(mainMenu)
-1
View File
@@ -18,7 +18,6 @@ local sources =
# support # support
BaseURL.cpp BaseURL.cpp
BitmapButton.cpp
BookmarkBar.cpp BookmarkBar.cpp
FontSelectionView.cpp FontSelectionView.cpp
SettingsMessage.cpp SettingsMessage.cpp
+1 -1
View File
@@ -609,7 +609,7 @@ URLInputGroup::URLInputGroup(BMessage* goMessage)
// TODO: Fix in Haiku, no in-built support for archived BBitmaps from // TODO: Fix in Haiku, no in-built support for archived BBitmaps from
// resources? // resources?
// fGoButton = new BitmapButton("kActionGo", NULL); // fGoButton = new BitmapButton("kActionGo", NULL);
fGoButton = new BitmapButton(kGoBitmapBits, kGoBitmapWidth, fGoButton = new BBitmapButton(kGoBitmapBits, kGoBitmapWidth,
kGoBitmapHeight, kGoBitmapFormat, goMessage); kGoBitmapHeight, kGoBitmapFormat, goMessage);
GroupLayout()->AddView(fGoButton, 0.0f); GroupLayout()->AddView(fGoButton, 0.0f);
@@ -15,7 +15,7 @@
static const float kFrameInset = 2; static const float kFrameInset = 2;
BitmapButton::BitmapButton(const char* resourceName, BMessage* message) BBitmapButton::BBitmapButton(const char* resourceName, BMessage* message)
: :
BButton("", message), BButton("", message),
fBitmap(BTranslationUtils::GetBitmap(resourceName)), fBitmap(BTranslationUtils::GetBitmap(resourceName)),
@@ -24,7 +24,7 @@ BitmapButton::BitmapButton(const char* resourceName, BMessage* message)
} }
BitmapButton::BitmapButton(const uint8* bits, uint32 width, uint32 height, BBitmapButton::BBitmapButton(const uint8* bits, uint32 width, uint32 height,
color_space format, BMessage* message) color_space format, BMessage* message)
: :
BButton("", message), BButton("", message),
@@ -35,14 +35,14 @@ BitmapButton::BitmapButton(const uint8* bits, uint32 width, uint32 height,
} }
BitmapButton::~BitmapButton() BBitmapButton::~BBitmapButton()
{ {
delete fBitmap; delete fBitmap;
} }
BSize BSize
BitmapButton::MinSize() BBitmapButton::MinSize()
{ {
BSize min(0, 0); BSize min(0, 0);
if (fBitmap) { if (fBitmap) {
@@ -56,21 +56,21 @@ BitmapButton::MinSize()
BSize BSize
BitmapButton::MaxSize() BBitmapButton::MaxSize()
{ {
return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED); return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
} }
BSize BSize
BitmapButton::PreferredSize() BBitmapButton::PreferredSize()
{ {
return MinSize(); return MinSize();
} }
void void
BitmapButton::Draw(BRect updateRect) BBitmapButton::Draw(BRect updateRect)
{ {
BRect bounds(Bounds()); BRect bounds(Bounds());
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
@@ -109,7 +109,7 @@ BitmapButton::Draw(BRect updateRect)
void void
BitmapButton::SetBackgroundMode(uint32 mode) BBitmapButton::SetBackgroundMode(uint32 mode)
{ {
if (fBackgroundMode != mode) { if (fBackgroundMode != mode) {
fBackgroundMode = mode; fBackgroundMode = mode;
+1
View File
@@ -29,6 +29,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
AboutMenuItem.cpp AboutMenuItem.cpp
ArgumentVector.cpp ArgumentVector.cpp
AttributeUtilities.cpp AttributeUtilities.cpp
BitmapButton.cpp
CalendarView.cpp CalendarView.cpp
ColorQuantizer.cpp ColorQuantizer.cpp
CommandPipe.cpp CommandPipe.cpp