Use floorf() on the calculations otherwise casting to an int could
truncate negative values to 0. Fixes bug #914. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23061 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
8d6c93fb2a
commit
956a0d199c
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
const uint8 K_COLOR_OFFSET = 32;
|
const uint8 K_COLOR_OFFSET = 32;
|
||||||
const float K_FONT_YPROP = 0.6f;
|
const float K_FONT_YPROP = 0.6f;
|
||||||
const float K_DISPLAY_YPROP = 0.2;
|
const float K_DISPLAY_YPROP = 0.2f;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
K_OPTIONS_REQUESTED = 'opts',
|
K_OPTIONS_REQUESTED = 'opts',
|
||||||
@ -404,7 +404,8 @@ void
|
|||||||
CalcView::MouseDown(BPoint point)
|
CalcView::MouseDown(BPoint point)
|
||||||
{
|
{
|
||||||
// ensure this view is the current focus
|
// ensure this view is the current focus
|
||||||
MakeFocus();
|
if (!IsFocus())
|
||||||
|
MakeFocus();
|
||||||
|
|
||||||
// read mouse buttons state
|
// read mouse buttons state
|
||||||
int32 buttons = 0;
|
int32 buttons = 0;
|
||||||
@ -427,8 +428,8 @@ CalcView::MouseDown(BPoint point)
|
|||||||
float sizeRow = (fHeight - sizeDisp) / (float)fRows;
|
float sizeRow = (fHeight - sizeDisp) / (float)fRows;
|
||||||
|
|
||||||
// calculate location within grid
|
// calculate location within grid
|
||||||
int gridCol = (int)(point.x / sizeCol);
|
int gridCol = (int)floorf(point.x / sizeCol);
|
||||||
int gridRow = (int)((point.y - sizeDisp) / sizeRow);
|
int gridRow = (int)floorf((point.y - sizeDisp) / sizeRow);
|
||||||
|
|
||||||
// check limits
|
// check limits
|
||||||
if ((gridCol >= 0) && (gridCol < fColums) &&
|
if ((gridCol >= 0) && (gridCol < fColums) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user