beginning to check up on gui components:

* added a group of controls to access and manipulate colors (incomplete)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17917 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2006-06-23 23:14:12 +00:00
parent 5ca1108776
commit e57995449d
17 changed files with 206 additions and 29 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ CanvasView::CanvasView(BRect frame)
fBitmap(new BBitmap(BRect(0, 0, 63, 63), 0, B_RGB32)),
fIcon(NULL),
fRenderer(new IconRenderer(fBitmap)),
fDirtyIconArea(LONG_MAX, LONG_MAX, LONG_MIN, LONG_MIN),
fDirtyIconArea(fBitmap->Bounds()),
fCanvasOrigin(50.0, 50.0),
fZoomLevel(8.0),
-8
View File
@@ -15,9 +15,6 @@
#include "Document.h"
#include "MainWindow.h"
// testing:
#include "ColorPickerPanel.h"
using std::nothrow;
// constructor
@@ -71,11 +68,6 @@ IconEditorApp::ReadyToRun()
{
fMainWindow = new MainWindow(this, fDocument);
fMainWindow->Show();
ColorPickerPanel* panel = new ColorPickerPanel(
BRect(80, 80, 200, 200),
(rgb_color){ 100, 200, 150, 255 });
panel->Show();
}
+5
View File
@@ -17,6 +17,7 @@ local sourceDirs =
generic/listener
generic/selection
generic/support
gui
gradient
shape
shape/commands
@@ -43,6 +44,8 @@ Application Icon-O-Matic :
Selectable.cpp
Selection.cpp
# generic/gui
Group.cpp
SwatchView.cpp
# generic/gui/panel
Panel.cpp
# generic/gui/panel/color_picker
@@ -66,6 +69,8 @@ Application Icon-O-Matic :
RWLocker.cpp
support.cpp
support_ui.cpp
# gui
SwatchGroup.cpp
# gradient
Gradient.cpp
# shape
+11 -1
View File
@@ -15,6 +15,7 @@
#include "Document.h"
#include "CanvasView.h"
#include "IconEditorApp.h"
#include "SwatchGroup.h"
// TODO: just for testing
#include "AffineTransformer.h"
@@ -148,8 +149,17 @@ MainWindow::_Init()
BView*
MainWindow::_CreateGUI(BRect bounds)
{
BView* bg = new BView(bounds, "bg", B_FOLLOW_ALL, 0);
bg->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fSwatchGroup = new SwatchGroup(BRect(0, 0, 100, 100));
bounds.top = fSwatchGroup->Frame().bottom + 1;
fCanvasView = new CanvasView(bounds);
return fCanvasView;
bg->AddChild(fSwatchGroup);
bg->AddChild(fCanvasView);
return bg;
}
+2
View File
@@ -14,6 +14,7 @@
class CanvasView;
class Document;
class IconEditorApp;
class SwatchGroup;
class ViewState;
class MainWindow : public BWindow {
@@ -34,6 +35,7 @@ class MainWindow : public BWindow {
Document* fDocument;
CanvasView* fCanvasView;
SwatchGroup* fSwatchGroup;
// TODO: for testing only...
ViewState* fState;
};
@@ -50,6 +50,7 @@ SwatchView::~SwatchView()
delete fDroppedMessage;
}
#if LIB_LAYOUT
// layoutprefs
minimax
SwatchView::layoutprefs()
@@ -75,6 +76,7 @@ SwatchView::layout(BRect frame)
ResizeTo(frame.Width(), frame.Height());
return Frame();
}
#endif // LIB_LAYOUT
// Draw
void
@@ -11,13 +11,15 @@
#include <View.h>
#if LIB_LAYOUT
#include <layout.h>
#endif
enum {
MSG_COLOR_DROP = 'PSTE',
};
class SwatchView : public MView, public BView {
class SwatchView :
#if LIB_LAYOUT
public MView,
#endif
public BView {
public:
SwatchView(const char* name,
BMessage* message,
@@ -27,9 +29,11 @@ class SwatchView : public MView, public BView {
float height = 24.0);
virtual ~SwatchView();
#if LIB_LAYOUT
// MView
virtual minimax layoutprefs();
virtual BRect layout(BRect frame);
#endif
// BView
virtual void Draw(BRect updateRect);
@@ -9,8 +9,6 @@
#ifndef _COLOR_FIELD_H
#define _COLOR_FIELD_H
#include "ColorPickerDefs.h"
#include <Control.h>
#if LIB_LAYOUT
@@ -1,6 +0,0 @@
#ifndef COLOR_PICKER_COMMON_H
#define COLOR_PICKER_COMMON_H
#define LIB_LAYOUT 0
#endif // COLOR_PICKER_COMMON_H
@@ -10,8 +10,6 @@
#include <Application.h>
#include "ColorPickerDefs.h"
#if LIB_LAYOUT
# include <MBorder.h>
# include <HGroup.h>
@@ -9,8 +9,6 @@
#ifndef COLOR_PICKER_VIEW_H
#define COLOR_PICKER_VIEW_H
#include "ColorPickerDefs.h"
#include <View.h>
#if LIB_LAYOUT
@@ -9,8 +9,6 @@
#ifndef _COLOR_SLIDER_H
#define _COLOR_SLIDER_H
#include "ColorPickerDefs.h"
#include <Control.h>
#if LIB_LAYOUT
+20
View File
@@ -0,0 +1,20 @@
/*
* Copyright 2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <[email protected]>
*/
#include "StyleView.h"
StyleView::StyleView(BRect frame)
: BView(frame, "style view", B_FOLLOW_NONE, 0)
{
}
StyleView::~StyleView()
{
}
+22
View File
@@ -0,0 +1,22 @@
/*
* Copyright 2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <[email protected]>
*/
#ifndef STYLE_VIEW_H
#define STYLE_VIEW_H
#include <View.h>
class StyleView : public {
public:
StyleView(BRect frame);
virtual ~StyleView();
private:
};
#endif // STYLE_VIEW_H
+99
View File
@@ -0,0 +1,99 @@
/*
* Copyright 2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <[email protected]>
*/
#include "SwatchGroup.h"
#include "ui_defines.h"
#include "rgb_hsv.h"
#include "ColorField.h"
#include "ColorSlider.h"
#include "Group.h"
#include "SwatchView.h"
enum {
MSG_SET_COLOR = 'stcl',
};
// constructor
SwatchGroup::SwatchGroup(BRect frame)
: BView(frame, "style view", B_FOLLOW_NONE, 0)
{
frame = BRect(0, 0, 100, 15);
fTopSwatchViews = new Group(frame, "top swatch group");
fBottomSwatchViews = new Group(frame, "bottom swatch group");
// create swatch views with rainbow default palette
float h = 0;
float s = 1.0;
float v = 1.0;
rgb_color color;
color.alpha = 255;
float r, g, b;
for (int32 i = 0; i < 20; i++) {
if (i < 10) {
h = ((float)i / 9.0) * 6.0;
} else {
h = ((float)(i - 9) / 10.0) * 6.0;
v = 0.5;
}
HSV_to_RGB(h, s, v, r, g, b);
color.red = (uint8)(255.0 * r);
color.green = (uint8)(255.0 * g);
color.blue = (uint8)(255.0 * b);
fSwatchViews[i] = new SwatchView("swatch", new BMessage(MSG_SET_COLOR),
this, color, 17.0, 14.0);
if (i < 10)
fTopSwatchViews->AddChild(fSwatchViews[i]);
else
fBottomSwatchViews->AddChild(fSwatchViews[i]);
}
// create color field and slider
color = kBlack;
fColorField = new ColorField(BPoint(0.0, 0.0), H_SELECTED,
1.0, B_HORIZONTAL);
fColorSlider = new ColorSlider(BPoint(0.0, 0.0), H_SELECTED,
1.0, 1.0, B_HORIZONTAL);
fColorField->SetMarkerToColor(color);
fColorSlider->SetMarkerToColor(color);
// layout gui
fTopSwatchViews->SetSpacing(0, 0);
fTopSwatchViews->ResizeToPreferred();
fBottomSwatchViews->SetSpacing(0, 0);
fBottomSwatchViews->ResizeToPreferred();
float width = fTopSwatchViews->Frame().Width();
fColorField->ResizeTo(width, 40);
fColorField->FrameResized(width, 40);
fColorSlider->ResizeTo(width, 15);
fColorSlider->FrameResized(width, 40);
fTopSwatchViews->MoveTo(0, 4);
fBottomSwatchViews->MoveTo(0, fTopSwatchViews->Frame().bottom + 1);
fColorField->MoveTo(0, fBottomSwatchViews->Frame().bottom + 3);
fColorSlider->MoveTo(0, fColorField->Frame().bottom + 1);
// configure self
ResizeTo(width, fColorSlider->Frame().bottom + 4);
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// add views
AddChild(fTopSwatchViews);
AddChild(fBottomSwatchViews);
AddChild(fColorField);
AddChild(fColorSlider);
}
// destructor
SwatchGroup::~SwatchGroup()
{
}
+35
View File
@@ -0,0 +1,35 @@
/*
* Copyright 2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <[email protected]>
*/
#ifndef SWATCH_GROUP_H
#define SWATCH_GROUP_H
#include <View.h>
class ColorField;
class ColorSlider;
class Group;
class SwatchView;
class SwatchGroup : public BView {
public:
SwatchGroup(BRect frame);
virtual ~SwatchGroup();
private:
SwatchView* fCurrentColorSV;
SwatchView* fSwatchViews[20];
ColorField* fColorField;
ColorSlider* fColorSlider;
Group* fTopSwatchViews;
Group* fBottomSwatchViews;
};
#endif // SWATCH_GROUP_H