Skip to content

Commit

Permalink
ColorControl: Implement keyboard navigation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jscipione committed Aug 17, 2013
1 parent 32af01e commit 7457783
Show file tree
Hide file tree
Showing 2 changed files with 202 additions and 95 deletions.
9 changes: 6 additions & 3 deletions headers/os/interface/ColorControl.h
Expand Up @@ -72,7 +72,7 @@ class BColorControl : public BControl {
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();

Expand All @@ -92,6 +92,8 @@ class BColorControl : public BControl {
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,
Expand Down Expand Up @@ -124,8 +126,9 @@ class BColorControl : public BControl {
BBitmap* fBitmap;
BView* fOffscreenView;

int32 fFocusedComponent;
uint32 _reserved[2];
int16 fFocusedRamp;
int16 fClickedRamp;
uint32 _reserved[2];
};

inline void
Expand Down

0 comments on commit 7457783

Please sign in to comment.