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:
@@ -23,7 +23,7 @@ CanvasView::CanvasView(BRect frame)
|
|||||||
fBitmap(new BBitmap(BRect(0, 0, 63, 63), 0, B_RGB32)),
|
fBitmap(new BBitmap(BRect(0, 0, 63, 63), 0, B_RGB32)),
|
||||||
fIcon(NULL),
|
fIcon(NULL),
|
||||||
fRenderer(new IconRenderer(fBitmap)),
|
fRenderer(new IconRenderer(fBitmap)),
|
||||||
fDirtyIconArea(LONG_MAX, LONG_MAX, LONG_MIN, LONG_MIN),
|
fDirtyIconArea(fBitmap->Bounds()),
|
||||||
|
|
||||||
fCanvasOrigin(50.0, 50.0),
|
fCanvasOrigin(50.0, 50.0),
|
||||||
fZoomLevel(8.0),
|
fZoomLevel(8.0),
|
||||||
|
|||||||
@@ -15,9 +15,6 @@
|
|||||||
#include "Document.h"
|
#include "Document.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
// testing:
|
|
||||||
#include "ColorPickerPanel.h"
|
|
||||||
|
|
||||||
using std::nothrow;
|
using std::nothrow;
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
@@ -71,11 +68,6 @@ IconEditorApp::ReadyToRun()
|
|||||||
{
|
{
|
||||||
fMainWindow = new MainWindow(this, fDocument);
|
fMainWindow = new MainWindow(this, fDocument);
|
||||||
fMainWindow->Show();
|
fMainWindow->Show();
|
||||||
|
|
||||||
ColorPickerPanel* panel = new ColorPickerPanel(
|
|
||||||
BRect(80, 80, 200, 200),
|
|
||||||
(rgb_color){ 100, 200, 150, 255 });
|
|
||||||
panel->Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ local sourceDirs =
|
|||||||
generic/listener
|
generic/listener
|
||||||
generic/selection
|
generic/selection
|
||||||
generic/support
|
generic/support
|
||||||
|
gui
|
||||||
gradient
|
gradient
|
||||||
shape
|
shape
|
||||||
shape/commands
|
shape/commands
|
||||||
@@ -43,6 +44,8 @@ Application Icon-O-Matic :
|
|||||||
Selectable.cpp
|
Selectable.cpp
|
||||||
Selection.cpp
|
Selection.cpp
|
||||||
# generic/gui
|
# generic/gui
|
||||||
|
Group.cpp
|
||||||
|
SwatchView.cpp
|
||||||
# generic/gui/panel
|
# generic/gui/panel
|
||||||
Panel.cpp
|
Panel.cpp
|
||||||
# generic/gui/panel/color_picker
|
# generic/gui/panel/color_picker
|
||||||
@@ -66,6 +69,8 @@ Application Icon-O-Matic :
|
|||||||
RWLocker.cpp
|
RWLocker.cpp
|
||||||
support.cpp
|
support.cpp
|
||||||
support_ui.cpp
|
support_ui.cpp
|
||||||
|
# gui
|
||||||
|
SwatchGroup.cpp
|
||||||
# gradient
|
# gradient
|
||||||
Gradient.cpp
|
Gradient.cpp
|
||||||
# shape
|
# shape
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "Document.h"
|
#include "Document.h"
|
||||||
#include "CanvasView.h"
|
#include "CanvasView.h"
|
||||||
#include "IconEditorApp.h"
|
#include "IconEditorApp.h"
|
||||||
|
#include "SwatchGroup.h"
|
||||||
|
|
||||||
// TODO: just for testing
|
// TODO: just for testing
|
||||||
#include "AffineTransformer.h"
|
#include "AffineTransformer.h"
|
||||||
@@ -148,8 +149,17 @@ MainWindow::_Init()
|
|||||||
BView*
|
BView*
|
||||||
MainWindow::_CreateGUI(BRect bounds)
|
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);
|
fCanvasView = new CanvasView(bounds);
|
||||||
|
|
||||||
return fCanvasView;
|
bg->AddChild(fSwatchGroup);
|
||||||
|
bg->AddChild(fCanvasView);
|
||||||
|
|
||||||
|
return bg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
class CanvasView;
|
class CanvasView;
|
||||||
class Document;
|
class Document;
|
||||||
class IconEditorApp;
|
class IconEditorApp;
|
||||||
|
class SwatchGroup;
|
||||||
class ViewState;
|
class ViewState;
|
||||||
|
|
||||||
class MainWindow : public BWindow {
|
class MainWindow : public BWindow {
|
||||||
@@ -34,6 +35,7 @@ class MainWindow : public BWindow {
|
|||||||
Document* fDocument;
|
Document* fDocument;
|
||||||
|
|
||||||
CanvasView* fCanvasView;
|
CanvasView* fCanvasView;
|
||||||
|
SwatchGroup* fSwatchGroup;
|
||||||
// TODO: for testing only...
|
// TODO: for testing only...
|
||||||
ViewState* fState;
|
ViewState* fState;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ SwatchView::~SwatchView()
|
|||||||
delete fDroppedMessage;
|
delete fDroppedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LIB_LAYOUT
|
||||||
// layoutprefs
|
// layoutprefs
|
||||||
minimax
|
minimax
|
||||||
SwatchView::layoutprefs()
|
SwatchView::layoutprefs()
|
||||||
@@ -75,6 +76,7 @@ SwatchView::layout(BRect frame)
|
|||||||
ResizeTo(frame.Width(), frame.Height());
|
ResizeTo(frame.Width(), frame.Height());
|
||||||
return Frame();
|
return Frame();
|
||||||
}
|
}
|
||||||
|
#endif // LIB_LAYOUT
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -11,13 +11,15 @@
|
|||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
|
#if LIB_LAYOUT
|
||||||
#include <layout.h>
|
#include <layout.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
class SwatchView :
|
||||||
MSG_COLOR_DROP = 'PSTE',
|
#if LIB_LAYOUT
|
||||||
};
|
public MView,
|
||||||
|
#endif
|
||||||
class SwatchView : public MView, public BView {
|
public BView {
|
||||||
public:
|
public:
|
||||||
SwatchView(const char* name,
|
SwatchView(const char* name,
|
||||||
BMessage* message,
|
BMessage* message,
|
||||||
@@ -27,9 +29,11 @@ class SwatchView : public MView, public BView {
|
|||||||
float height = 24.0);
|
float height = 24.0);
|
||||||
virtual ~SwatchView();
|
virtual ~SwatchView();
|
||||||
|
|
||||||
|
#if LIB_LAYOUT
|
||||||
// MView
|
// MView
|
||||||
virtual minimax layoutprefs();
|
virtual minimax layoutprefs();
|
||||||
virtual BRect layout(BRect frame);
|
virtual BRect layout(BRect frame);
|
||||||
|
#endif
|
||||||
|
|
||||||
// BView
|
// BView
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
#ifndef _COLOR_FIELD_H
|
#ifndef _COLOR_FIELD_H
|
||||||
#define _COLOR_FIELD_H
|
#define _COLOR_FIELD_H
|
||||||
|
|
||||||
#include "ColorPickerDefs.h"
|
|
||||||
|
|
||||||
#include <Control.h>
|
#include <Control.h>
|
||||||
|
|
||||||
#if LIB_LAYOUT
|
#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 <Application.h>
|
||||||
|
|
||||||
#include "ColorPickerDefs.h"
|
|
||||||
|
|
||||||
#if LIB_LAYOUT
|
#if LIB_LAYOUT
|
||||||
# include <MBorder.h>
|
# include <MBorder.h>
|
||||||
# include <HGroup.h>
|
# include <HGroup.h>
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
#ifndef COLOR_PICKER_VIEW_H
|
#ifndef COLOR_PICKER_VIEW_H
|
||||||
#define COLOR_PICKER_VIEW_H
|
#define COLOR_PICKER_VIEW_H
|
||||||
|
|
||||||
#include "ColorPickerDefs.h"
|
|
||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
#if LIB_LAYOUT
|
#if LIB_LAYOUT
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
#ifndef _COLOR_SLIDER_H
|
#ifndef _COLOR_SLIDER_H
|
||||||
#define _COLOR_SLIDER_H
|
#define _COLOR_SLIDER_H
|
||||||
|
|
||||||
#include "ColorPickerDefs.h"
|
|
||||||
|
|
||||||
#include <Control.h>
|
#include <Control.h>
|
||||||
|
|
||||||
#if LIB_LAYOUT
|
#if LIB_LAYOUT
|
||||||
|
|||||||
@@ -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()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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
|
||||||
@@ -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()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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
|
||||||
Reference in New Issue
Block a user