[prev in list] [next in list] [prev in thread] [next in thread]
List: haiku-commits
Subject: [haiku-commits] haiku: hrev53915 - src/preferences/keymap
From: waddlesplash <waddlesplash () gmail ! com>
Date: 2020-02-25 4:44:36
Message-ID: 20200225044436.E6B2D24286 () turing ! freelists ! org
[Download RAW message or body]
hrev53915 adds 1 changeset to branch 'master'
old head: 84195a491f613d96cb23b56782a5e5eab6ebb450
new head: 371b3b2b42188baf7b34be16f0891595014f5ef2
overview: https://git.haiku-os.org/haiku/log/?qt=range&q=371b3b2b4218+%5E84195a491f61
----------------------------------------------------------------------------
371b3b2b4218: Keymap: remove flickering workarounds, small fixes
Part of #15623.
Change-Id: I44d62a39efeaa25ecdc3b8a9aa27ca9fef33e5b9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2279
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
[ X512 <danger_mail@list.ru> ]
----------------------------------------------------------------------------
Revision: hrev53915
Commit: 371b3b2b42188baf7b34be16f0891595014f5ef2
URL: https://git.haiku-os.org/haiku/commit/?id=371b3b2b4218
Author: X512 <danger_mail@list.ru>
Date: Mon Feb 24 20:46:19 2020 UTC
Committer: waddlesplash <waddlesplash@gmail.com>
Commit-Date: Tue Feb 25 04:44:29 2020 UTC
Ticket: https://dev.haiku-os.org/ticket/15623
----------------------------------------------------------------------------
2 files changed, 8 insertions(+), 69 deletions(-)
src/preferences/keymap/KeyboardLayoutView.cpp | 73 +++--------------------
src/preferences/keymap/KeyboardLayoutView.h | 4 --
----------------------------------------------------------------------------
diff --git a/src/preferences/keymap/KeyboardLayoutView.cpp \
b/src/preferences/keymap/KeyboardLayoutView.cpp index 3b7234f226..42f60215ff 100644
--- a/src/preferences/keymap/KeyboardLayoutView.cpp
+++ b/src/preferences/keymap/KeyboardLayoutView.cpp
@@ -83,7 +83,6 @@ is_mappable_to_modifier(uint32 keyCode)
KeyboardLayoutView::KeyboardLayoutView(const char* name)
:
BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS),
- fOffscreenBitmap(NULL),
fKeymap(NULL),
fEditable(true),
fModifiers(0),
@@ -102,7 +101,6 @@ KeyboardLayoutView::KeyboardLayoutView(const char* name)
KeyboardLayoutView::~KeyboardLayoutView()
{
- delete fOffscreenBitmap;
}
@@ -110,7 +108,6 @@ void
KeyboardLayoutView::SetKeyboardLayout(KeyboardLayout* layout)
{
fLayout = layout;
- _InitOffscreen();
_LayoutKeyboard();
Invalidate();
}
@@ -159,7 +156,6 @@ KeyboardLayoutView::AttachedToWindow()
void
KeyboardLayoutView::FrameResized(float width, float height)
{
- _InitOffscreen();
_LayoutKeyboard();
}
@@ -502,32 +498,24 @@ void
KeyboardLayoutView::Draw(BRect updateRect)
{
if (fOldSize != BSize(Bounds().Width(), Bounds().Height())) {
- _InitOffscreen();
_LayoutKeyboard();
}
- BView* view;
- if (fOffscreenBitmap != NULL) {
- view = fOffscreenView;
- view->LockLooper();
- } else
- view = this;
-
// Draw background
if (Parent())
- view->SetLowColor(Parent()->ViewColor());
+ SetLowColor(Parent()->ViewColor());
else
- view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+ SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
- view->FillRect(updateRect, B_SOLID_LOW);
+ FillRect(updateRect, B_SOLID_LOW);
// Draw keys
for (int32 i = 0; i < fLayout->CountKeys(); i++) {
Key* key = fLayout->KeyAt(i);
- _DrawKey(view, updateRect, key, _FrameFor(key),
+ _DrawKey(this, updateRect, key, _FrameFor(key),
_IsKeyPressed(key->code));
}
@@ -536,16 +524,9 @@ KeyboardLayoutView::Draw(BRect updateRect)
for (int32 i = 0; i < fLayout->CountIndicators(); i++) {
Indicator* indicator = fLayout->IndicatorAt(i);
- _DrawIndicator(view, updateRect, indicator, _FrameFor(indicator->frame),
+ _DrawIndicator(this, updateRect, indicator, _FrameFor(indicator->frame),
(fModifiers & indicator->modifier) != 0);
}
-
- if (fOffscreenBitmap != NULL) {
- view->Sync();
- view->UnlockLooper();
-
- DrawBitmapAsync(fOffscreenBitmap, BPoint(0, 0));
- }
}
@@ -693,40 +674,6 @@ KeyboardLayoutView::MessageReceived(BMessage* message)
}
-void
-KeyboardLayoutView::_InitOffscreen()
-{
- delete fOffscreenBitmap;
- fOffscreenView = NULL;
-
- fOffscreenBitmap = new(std::nothrow) BBitmap(Bounds(),
- B_BITMAP_ACCEPTS_VIEWS, B_RGB32);
- if (fOffscreenBitmap != NULL && fOffscreenBitmap->IsValid()) {
- fOffscreenBitmap->Lock();
- fOffscreenView = new(std::nothrow) BView(Bounds(), "offscreen view",
- 0, 0);
- if (fOffscreenView != NULL) {
- if (Parent() != NULL) {
- fOffscreenView->SetViewColor(Parent()->ViewColor());
- } else {
- fOffscreenView->SetViewColor(
- ui_color(B_PANEL_BACKGROUND_COLOR));
- }
-
- fOffscreenView->SetLowColor(fOffscreenView->ViewColor());
- fOffscreenBitmap->AddChild(fOffscreenView);
- }
- fOffscreenBitmap->Unlock();
- }
-
- if (fOffscreenView == NULL) {
- // something went wrong
- delete fOffscreenBitmap;
- fOffscreenBitmap = NULL;
- }
-}
-
-
void
KeyboardLayoutView::_LayoutKeyboard()
{
@@ -734,9 +681,9 @@ KeyboardLayoutView::_LayoutKeyboard()
float factorY = Bounds().Height() / fLayout->Bounds().Height();
fFactor = min_c(factorX, factorY);
- fOffset = BPoint((Bounds().Width() - fLayout->Bounds().Width()
- * fFactor) / 2,
- (Bounds().Height() - fLayout->Bounds().Height() * fFactor) / 2);
+ fOffset = BPoint(floorf((Bounds().Width() - fLayout->Bounds().Width()
+ * fFactor) / 2),
+ floorf((Bounds().Height() - fLayout->Bounds().Height() * fFactor) / 2));
if (fLayout->DefaultKeySize().width < 11)
fGap = 1;
@@ -861,10 +808,6 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, \
const Key* key, region.Exclude(bottomLeft);
view->ConstrainClippingRegion(®ion);
- // Fill in the rect with the background color
- SetHighColor(background);
- FillRect(rect);
-
// draw the button background
BRect bgRect = rect.InsetByCopy(2, 2);
be_control_look->DrawButtonBackground(view, bgRect, updateRect,
diff --git a/src/preferences/keymap/KeyboardLayoutView.h \
b/src/preferences/keymap/KeyboardLayoutView.h index 7fcea71206..0d1d485732 100644
--- a/src/preferences/keymap/KeyboardLayoutView.h
+++ b/src/preferences/keymap/KeyboardLayoutView.h
@@ -60,7 +60,6 @@ private:
kIndicator
};
- void _InitOffscreen();
void _LayoutKeyboard();
void _DrawKeyButton(BView* view, BRect& rect,
BRect updateRect, rgb_color base,
@@ -103,9 +102,6 @@ private:
uint32 newCode);
const char* _NameForModifier(uint32 modifier, bool pretty);
- BBitmap* fOffscreenBitmap;
- BView* fOffscreenView;
-
KeyboardLayout* fLayout;
Keymap* fKeymap;
BMessenger fTarget;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic