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 <waddlesplash@gmail.com>
This commit is contained in:
Adrien Destugues 2019-06-16 10:57:41 +02:00 committed by waddlesplash
parent d689db1448
commit f74f860085
10 changed files with 24 additions and 207 deletions

View File

@ -6,26 +6,29 @@
#define BITMAP_BUTTON_H
#include <Button.h>
#include <Size.h>
class BBitmap;
class BitmapButton : public BButton {
namespace BPrivate {
class BBitmapButton : public BButton {
public:
enum {
BUTTON_BACKGROUND = 0,
MENUBAR_BACKGROUND,
};
BitmapButton(const char* resourceName,
BBitmapButton(const char* resourceName,
BMessage* message);
BitmapButton(const uint8* bits, uint32 width,
BBitmapButton(const uint8* bits, uint32 width,
uint32 height, color_space format,
BMessage* message);
virtual ~BitmapButton();
virtual ~BBitmapButton();
virtual BSize MinSize();
virtual BSize MaxSize();
@ -40,5 +43,9 @@ private:
uint32 fBackgroundMode;
};
};
using BPrivate::BBitmapButton;
#endif // BITMAP_BUTTON_H

View File

@ -113,7 +113,6 @@ local textDocumentSources =
local applicationSources =
App.cpp
BarberPole.cpp
BitmapButton.cpp
BitmapView.cpp
DecisionProvider.cpp
FeaturedPackagesView.cpp

View File

@ -36,7 +36,6 @@
#include <package/hpkg/PackageContentHandler.h>
#include <package/hpkg/PackageEntry.h>
#include "BitmapButton.h"
#include "BitmapView.h"
#include "LinkView.h"
#include "LinkedBitmapView.h"
@ -1446,4 +1445,4 @@ PackageInfoView::Clear()
fPackageListener->SetPackage(PackageInfoRef(NULL));
fPackage.Unset();
}
}

View File

@ -1,144 +0,0 @@
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* 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();
}

View File

@ -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

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,
new BMessage(TOGGLE_FULLSCREEN));
toggleFullscreenButton->SetBackgroundMode(BitmapButton::MENUBAR_BACKGROUND);
toggleFullscreenButton->SetBackgroundMode(BBitmapButton::MENUBAR_BACKGROUND);
BGroupLayout* menuBarGroup = BLayoutBuilder::Group<>(B_HORIZONTAL, 0.0)
.Add(mainMenu)

View File

@ -18,7 +18,6 @@ local sources =
# support
BaseURL.cpp
BitmapButton.cpp
BookmarkBar.cpp
FontSelectionView.cpp
SettingsMessage.cpp

View File

@ -609,7 +609,7 @@ URLInputGroup::URLInputGroup(BMessage* goMessage)
// TODO: Fix in Haiku, no in-built support for archived BBitmaps from
// resources?
// fGoButton = new BitmapButton("kActionGo", NULL);
fGoButton = new BitmapButton(kGoBitmapBits, kGoBitmapWidth,
fGoButton = new BBitmapButton(kGoBitmapBits, kGoBitmapWidth,
kGoBitmapHeight, kGoBitmapFormat, goMessage);
GroupLayout()->AddView(fGoButton, 0.0f);

View File

@ -15,7 +15,7 @@
static const float kFrameInset = 2;
BitmapButton::BitmapButton(const char* resourceName, BMessage* message)
BBitmapButton::BBitmapButton(const char* resourceName, BMessage* message)
:
BButton("", message),
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)
:
BButton("", message),
@ -35,14 +35,14 @@ BitmapButton::BitmapButton(const uint8* bits, uint32 width, uint32 height,
}
BitmapButton::~BitmapButton()
BBitmapButton::~BBitmapButton()
{
delete fBitmap;
}
BSize
BitmapButton::MinSize()
BBitmapButton::MinSize()
{
BSize min(0, 0);
if (fBitmap) {
@ -56,21 +56,21 @@ BitmapButton::MinSize()
BSize
BitmapButton::MaxSize()
BBitmapButton::MaxSize()
{
return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
}
BSize
BitmapButton::PreferredSize()
BBitmapButton::PreferredSize()
{
return MinSize();
}
void
BitmapButton::Draw(BRect updateRect)
BBitmapButton::Draw(BRect updateRect)
{
BRect bounds(Bounds());
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
@ -109,7 +109,7 @@ BitmapButton::Draw(BRect updateRect)
void
BitmapButton::SetBackgroundMode(uint32 mode)
BBitmapButton::SetBackgroundMode(uint32 mode)
{
if (fBackgroundMode != mode) {
fBackgroundMode = mode;

View File

@ -29,6 +29,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
AboutMenuItem.cpp
ArgumentVector.cpp
AttributeUtilities.cpp
BitmapButton.cpp
CalendarView.cpp
ColorQuantizer.cpp
CommandPipe.cpp