From 16e486eb4dd2d39b9a3eb65171106fd17d7e3fc0 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 29 Jun 2013 11:54:42 -0400 Subject: [PATCH] BTabView: minor optimization. Short circuit if asked to select the same index that's currently visible, to avoid unnecessary invalidation/flicker. Should fix last part of #9841. --- src/kits/interface/TabView.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/kits/interface/TabView.cpp b/src/kits/interface/TabView.cpp index 1b06aa05f5..d7a08f349b 100644 --- a/src/kits/interface/TabView.cpp +++ b/src/kits/interface/TabView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Haiku, Inc. All rights reserved. + * Copyright 2001-2013, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -7,6 +7,7 @@ * Jérôme Duval (korli@users.berlios.de) * Stephan Aßmus * Artur Wyszynski + * Rene Gollent (rene@gollent.com) */ @@ -746,6 +747,9 @@ BTabView::Pulse() void BTabView::Select(int32 index) { + if (index == Selection()) + return; + if (index < 0 || index >= CountTabs()) index = Selection(); @@ -1351,7 +1355,7 @@ BTabView::_InitObject(bool layouted, button_width width) fTabList = new BList; fTabWidthSetting = width; - fSelection = 0; + fSelection = -1; fFocus = -1; fTabOffset = 0.0f; fBorderStyle = B_FANCY_BORDER;