ColorControl: Implement keyboard navigation

Implements enhancement described in #9819

This feature works pretty much as it did on BeOS R5.

When you focus on the color control, the border is drawn blue and
the dot on the red ramp draws as an outline to show that it is
selected. You can push the up and down arrow keys to navigate to the
previous and next ramps respectively and can push right and left to
increment and decrement the color value of the selected ramp.

Clicking on the control no longer gives it focus.

In BeOS the left and right arrows would increment and decriment by 5,
on Haiku they increment and decrement by 1, but, by holding down the
key for a second or so the increment value increases to 5 allowing for
both course and fine adjustments.

On a technical note I split the int32 fFocusedComponent member variable
into 2 int16 member variables, fFocusedRamp and fClickedRamp. I did this
because I needed an entra variable, and can't  change the size of the
class without using up another reserved member variable slot. int16
should be more than enough for these variables as they store an index to
the currently focused or clicked on ramp (0-3). Please someone chime in
if this is not okay for FBC in some condition I didn't think about.
This commit is contained in:
John Scipione
2013-08-17 03:40:58 -04:00
parent 32af01e854
commit 74577830da
2 changed files with 202 additions and 95 deletions
+6 -3
View File
@@ -72,7 +72,7 @@ public:
int32 what, const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
virtual void MakeFocus(bool state = true);
virtual void MakeFocus(bool focused = true);
virtual void AllAttached();
virtual void AllDetached();
@@ -92,6 +92,8 @@ private:
BMessage* archive = NULL);
void _LayoutView();
void _InitOffscreen();
void _InvalidateSelector(int16 ramp,
rgb_color color, bool focused);
void _DrawColorArea(BView* target, BRect update);
void _DrawSelectors(BView* target);
void _DrawColorRamp(BRect rect, BView* target,
@@ -124,8 +126,9 @@ private:
BBitmap* fBitmap;
BView* fOffscreenView;
int32 fFocusedComponent;
uint32 _reserved[2];
int16 fFocusedRamp;
int16 fClickedRamp;
uint32 _reserved[2];
};
inline void