* relayout of the GUI, you can start to take it serious :-)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18077 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2006-07-09 10:21:18 +00:00
parent 8b97f0dcaf
commit 85623bad05
4 changed files with 144 additions and 46 deletions
+130 -43
View File
@@ -61,7 +61,7 @@ enum {
// constructor // constructor
MainWindow::MainWindow(IconEditorApp* app, Document* document) MainWindow::MainWindow(IconEditorApp* app, Document* document)
: BWindow(BRect(20, 50, 1010, 781), "Icon-O-Matic", : BWindow(BRect(50, 50, 900, 750), "Icon-O-Matic",
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS), B_ASYNCHRONOUS_CONTROLS),
fApp(app), fApp(app),
@@ -220,8 +220,7 @@ void
MainWindow::_Init() MainWindow::_Init()
{ {
// create the GUI // create the GUI
BView* topView = _CreateGUI(Bounds()); _CreateGUI(Bounds());
AddChild(topView);
fCanvasView->SetCatchAllEvents(true); fCanvasView->SetCatchAllEvents(true);
fCanvasView->SetCommandStack(fDocument->CommandStack()); fCanvasView->SetCommandStack(fDocument->CommandStack());
@@ -247,6 +246,7 @@ MainWindow::_Init()
fPropertyListView->SetCommandStack(fDocument->CommandStack()); fPropertyListView->SetCommandStack(fDocument->CommandStack());
fPropertyListView->SetSelection(fDocument->Selection()); fPropertyListView->SetSelection(fDocument->Selection());
fPropertyListView->SetMenu(fPropertyMenu);
fIconPreview16->SetIcon(fDocument->Icon()); fIconPreview16->SetIcon(fDocument->Icon());
fIconPreview32->SetIcon(fDocument->Icon()); fIconPreview32->SetIcon(fDocument->Icon());
@@ -319,26 +319,54 @@ MainWindow::_Init()
} }
// _CreateGUI // _CreateGUI
BView* void
MainWindow::_CreateGUI(BRect bounds) MainWindow::_CreateGUI(BRect bounds)
{ {
BRect menuFrame = bounds; const float splitWidth = 150;
menuFrame.bottom = menuFrame.top + 15;
BMenuBar* menuBar = _CreateMenuBar(menuFrame);
AddChild(menuBar);
menuBar->ResizeToPreferred();
bounds.top = menuBar->Frame().bottom + 1;
BView* bg = new BView(bounds, "bg", B_FOLLOW_ALL, 0); BView* bg = new BView(bounds, "bg", B_FOLLOW_ALL, 0);
bg->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); bg->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(bg);
fSwatchGroup = new SwatchGroup(BRect(0, 0, 100, 100)); BRect menuFrame = bounds;
menuFrame.bottom = menuFrame.top + 15;
BMenuBar* menuBar = _CreateMenuBar(menuFrame);
bg->AddChild(menuBar);
float menuWidth;
float menuHeight;
menuBar->GetPreferredSize(&menuWidth, &menuHeight);
menuBar->ResizeTo(splitWidth - 1, menuHeight);
menuBar->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
bounds.top = menuBar->Frame().bottom + 1;
// swatch group
fSwatchGroup = new SwatchGroup(bounds);
// SwatchGroup auto resizes itself
fSwatchGroup->MoveTo(bounds.right - fSwatchGroup->Bounds().Width(),
bounds.top);
fSwatchGroup->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
bounds.left = fSwatchGroup->Frame().left;
bounds.right = bg->Bounds().right;
bounds.top = bg->Bounds().top;
bounds.bottom = bounds.top + menuHeight;
menuBar = new BMenuBar(bounds, "swatches menu bar");
menuBar->AddItem(fSwatchMenu);
bg->AddChild(menuBar);
menuBar->ResizeTo(bounds.Width(), menuHeight);
// menu bars resize themselves to window width
menuBar->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
// canvas view
bounds.left = splitWidth;
bounds.top = fSwatchGroup->Frame().bottom + 1; bounds.top = fSwatchGroup->Frame().bottom + 1;
bounds.right = bg->Bounds().right;
bounds.bottom = bg->Bounds().bottom;
fCanvasView = new CanvasView(bounds); fCanvasView = new CanvasView(bounds);
bounds.left = fSwatchGroup->Frame().right + 5; // icon previews
bounds.left = 5;
bounds.top = fSwatchGroup->Frame().top + 5; bounds.top = fSwatchGroup->Frame().top + 5;
bounds.right = bounds.left + 15; bounds.right = bounds.left + 15;
bounds.bottom = bounds.top + 15; bounds.bottom = bounds.top + 15;
@@ -359,30 +387,92 @@ MainWindow::_CreateGUI(BRect bounds)
bounds.bottom = bounds.top + 63; bounds.bottom = bounds.top + 63;
fIconPreview64 = new IconView(bounds, "icon preview 64"); fIconPreview64 = new IconView(bounds, "icon preview 64");
// style list view
bounds.left = fCanvasView->Frame().left;
bounds.right = bounds.left + splitWidth;
bounds.top = bg->Bounds().top;
bounds.bottom = bounds.top + menuHeight;
menuBar = new BMenuBar(bounds, "style menu bar");
menuBar->AddItem(fStyleMenu);
bg->AddChild(menuBar);
menuBar->ResizeTo(bounds.Width(), menuHeight);
// menu bars resize themselves to window width
menuBar->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
bounds.right -= B_V_SCROLL_BAR_WIDTH + 1;
bounds.top = menuBar->Frame().bottom + 1;
bounds.bottom = fCanvasView->Frame().top - 1;
fStyleListView = new StyleListView(bounds, "style list view",
new BMessage(MSG_STYLE_SELECTED), this);
// path list view // path list view
bounds.OffsetBy(bounds.Width() + 6, 0); bounds.left = 0;
bounds.right = bounds.left + 100; bounds.right = fCanvasView->Frame().left - 1;
bounds.bottom = fCanvasView->Frame().top - 5.0; bounds.top = fCanvasView->Frame().top;
bounds.bottom = bounds.top + menuHeight;
menuBar = new BMenuBar(bounds, "path menu bar");
menuBar->AddItem(fPathMenu);
bg->AddChild(menuBar);
menuBar->ResizeTo(bounds.Width(), menuHeight);
// menu bars resize themselves to window width
menuBar->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
bounds.right -= B_V_SCROLL_BAR_WIDTH + 1;
bounds.top = menuBar->Frame().bottom + 1;
bounds.bottom = bounds.top + 130;
fPathListView = new PathListView(bounds, "path list view", fPathListView = new PathListView(bounds, "path list view",
new BMessage(MSG_PATH_SELECTED), this); new BMessage(MSG_PATH_SELECTED), this);
// style list view
bounds.OffsetBy(bounds.Width() + 6 + B_V_SCROLL_BAR_WIDTH, 0);
fStyleListView = new StyleListView(bounds, "style list view",
new BMessage(MSG_STYLE_SELECTED), this);
// shape list view // shape list view
bounds.OffsetBy(bounds.Width() + 6 + B_V_SCROLL_BAR_WIDTH, 0); bounds.right += B_V_SCROLL_BAR_WIDTH + 1;
bounds.top = fPathListView->Frame().bottom + 1;
bounds.bottom = bounds.top + menuHeight;
menuBar = new BMenuBar(bounds, "shape menu bar");
menuBar->AddItem(fShapeMenu);
bg->AddChild(menuBar);
menuBar->ResizeTo(bounds.Width(), menuHeight);
// menu bars resize themselves to window width
menuBar->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
bounds.right -= B_V_SCROLL_BAR_WIDTH + 1;
bounds.top = menuBar->Frame().bottom + 1;
bounds.bottom = bounds.top + 130;
fShapeListView = new ShapeListView(bounds, "shape list view", fShapeListView = new ShapeListView(bounds, "shape list view",
new BMessage(MSG_SHAPE_SELECTED), this); new BMessage(MSG_SHAPE_SELECTED), this);
// transformer list view // transformer list view
bounds.OffsetBy(bounds.Width() + 6 + B_V_SCROLL_BAR_WIDTH, 0); bounds.right += B_V_SCROLL_BAR_WIDTH + 1;
bounds.top = fShapeListView->Frame().bottom + 1;
bounds.bottom = bounds.top + menuHeight;
menuBar = new BMenuBar(bounds, "transformer menu bar");
menuBar->AddItem(fTransformerMenu);
bg->AddChild(menuBar);
menuBar->ResizeTo(bounds.Width(), bounds.Height());
// menu bars resize themselves to window width
menuBar->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
bounds.right -= B_V_SCROLL_BAR_WIDTH + 1;
bounds.top = menuBar->Frame().bottom + 1;
bounds.bottom = bounds.top + 80;
fTransformerListView = new TransformerListView(bounds, fTransformerListView = new TransformerListView(bounds,
"transformer list view"); "transformer list view");
// property list view // property list view
bounds.right += B_V_SCROLL_BAR_WIDTH + 1;
bounds.top = fTransformerListView->Frame().bottom + 1;
bounds.bottom = bounds.top + menuHeight;
menuBar = new BMenuBar(bounds, "property menu bar");
menuBar->AddItem(fPropertyMenu);
bg->AddChild(menuBar);
menuBar->ResizeTo(bounds.Width(), bounds.Height());
// menu bars resize themselves to window width
menuBar->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
fPropertyListView = new IconObjectListView(); fPropertyListView = new IconObjectListView();
bg->AddChild(fSwatchGroup); bg->AddChild(fSwatchGroup);
@@ -414,18 +504,16 @@ MainWindow::_CreateGUI(BRect bounds)
B_NO_BORDER)); B_NO_BORDER));
// scroll view around property list view // scroll view around property list view
bounds.OffsetBy(bounds.Width() + 6 + B_V_SCROLL_BAR_WIDTH, 0); bounds.top = menuBar->Frame().bottom + 1;
bounds.right = bg->Bounds().right - 5; bounds.bottom = bg->Bounds().bottom;
bg->AddChild(new ScrollView(fPropertyListView, bg->AddChild(new ScrollView(fPropertyListView,
SCROLL_VERTICAL | SCROLL_NO_FRAME, SCROLL_VERTICAL | SCROLL_NO_FRAME,
bounds, "property scroll view", bounds, "property scroll view",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM,
B_WILL_DRAW | B_FRAME_EVENTS)); B_WILL_DRAW | B_FRAME_EVENTS));
bg->AddChild(fCanvasView); bg->AddChild(fCanvasView);
return bg;
} }
// _CreateMenuBar // _CreateMenuBar
@@ -436,17 +524,15 @@ MainWindow::_CreateMenuBar(BRect frame)
BMenu* fileMenu = new BMenu("File"); BMenu* fileMenu = new BMenu("File");
BMenu* editMenu = new BMenu("Edit"); BMenu* editMenu = new BMenu("Edit");
BMenu* pathMenu = new BMenu("Path"); fPathMenu = new BMenu("Path");
BMenu* styleMenu = new BMenu("Style"); fStyleMenu = new BMenu("Style");
BMenu* shapeMenu = new BMenu("Shape"); fShapeMenu = new BMenu("Shape");
BMenu* transformerMenu = new BMenu("Transformer"); fTransformerMenu = new BMenu("Transformer");
fPropertyMenu = new BMenu("Property");
fSwatchMenu = new BMenu("Swatches");
menuBar->AddItem(fileMenu); menuBar->AddItem(fileMenu);
menuBar->AddItem(editMenu); menuBar->AddItem(editMenu);
menuBar->AddItem(pathMenu);
menuBar->AddItem(styleMenu);
menuBar->AddItem(shapeMenu);
menuBar->AddItem(transformerMenu);
// Edit // Edit
fUndoMI = new BMenuItem("<nothing to undo>", fUndoMI = new BMenuItem("<nothing to undo>",
@@ -461,26 +547,27 @@ MainWindow::_CreateMenuBar(BRect frame)
editMenu->AddItem(fRedoMI); editMenu->AddItem(fRedoMI);
// Path // Path
pathMenu->AddItem(new BMenuItem("New", new BMessage(MSG_NEW_PATH))); fPathMenu->AddItem(new BMenuItem("New", new BMessage(MSG_NEW_PATH)));
// Style // Style
styleMenu->AddItem(new BMenuItem("New", new BMessage(MSG_NEW_STYLE))); fStyleMenu->AddItem(new BMenuItem("New", new BMessage(MSG_NEW_STYLE)));
// Shape // Shape
shapeMenu->AddItem(new BMenuItem("New", new BMessage(MSG_NEW_SHAPE))); fShapeMenu->AddItem(new BMenuItem("New", new BMessage(MSG_NEW_SHAPE)));
// Transformer // Transformer
BMenu* addMenu = new BMenu("Add");
int32 cookie = 0; int32 cookie = 0;
uint32 type; uint32 type;
BString name; BString name;
while (TransformerFactory::NextType(&cookie, &type, &name)) { while (TransformerFactory::NextType(&cookie, &type, &name)) {
BMessage* message = new BMessage(MSG_ADD_TRANSFORMER); BMessage* message = new BMessage(MSG_ADD_TRANSFORMER);
message->AddInt32("type", type); message->AddInt32("type", type);
BString label("Add "); addMenu->AddItem(new BMenuItem(name.String(), message));
label << name;
transformerMenu->AddItem(new BMenuItem(label.String(), message));
} }
transformerMenu->SetTargetForItems(this); addMenu->SetTargetForItems(this);
fTransformerMenu->AddItem(addMenu);
return menuBar; return menuBar;
} }
+8 -1
View File
@@ -44,12 +44,19 @@ class MainWindow : public BWindow,
private: private:
void _Init(); void _Init();
BView* _CreateGUI(BRect frame); void _CreateGUI(BRect frame);
BMenuBar* _CreateMenuBar(BRect frame); BMenuBar* _CreateMenuBar(BRect frame);
IconEditorApp* fApp; IconEditorApp* fApp;
Document* fDocument; Document* fDocument;
BMenu* fPathMenu;
BMenu* fStyleMenu;
BMenu* fShapeMenu;
BMenu* fTransformerMenu;
BMenu* fPropertyMenu;
BMenu* fSwatchMenu;
BMenuItem* fUndoMI; BMenuItem* fUndoMI;
BMenuItem* fRedoMI; BMenuItem* fRedoMI;
+2 -2
View File
@@ -258,9 +258,9 @@ StyleListView::SelectionChanged()
StyleListItem* item StyleListItem* item
= dynamic_cast<StyleListItem*>(ItemAt(CurrentSelection(0))); = dynamic_cast<StyleListItem*>(ItemAt(CurrentSelection(0)));
if (item && fMessage) { if (fMessage) {
BMessage message(*fMessage); BMessage message(*fMessage);
message.AddPointer("style", (void*)item->style); message.AddPointer("style", item ? (void*)item->style : NULL);
Invoke(&message); Invoke(&message);
} }
@@ -68,6 +68,7 @@ SwatchGroup::SwatchGroup(BRect frame)
this, color, this, color,
SWATCH_VIEW_WIDTH, SWATCH_VIEW_WIDTH,
SWATCH_VIEW_HEIGHT); SWATCH_VIEW_HEIGHT);
fSwatchViews[i]->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
if (i < 10) if (i < 10)
fTopSwatchViews->AddChild(fSwatchViews[i]); fTopSwatchViews->AddChild(fSwatchViews[i]);
else else
@@ -87,8 +88,10 @@ SwatchGroup::SwatchGroup(BRect frame)
// layout gui // layout gui
fTopSwatchViews->SetSpacing(0, 0); fTopSwatchViews->SetSpacing(0, 0);
fTopSwatchViews->ResizeToPreferred(); fTopSwatchViews->ResizeToPreferred();
fTopSwatchViews->SetResizingMode(B_FOLLOW_ALL);
fBottomSwatchViews->SetSpacing(0, 0); fBottomSwatchViews->SetSpacing(0, 0);
fBottomSwatchViews->ResizeToPreferred(); fBottomSwatchViews->ResizeToPreferred();
fBottomSwatchViews->SetResizingMode(B_FOLLOW_ALL);
fTopSwatchViews->MoveTo(30, 4); fTopSwatchViews->MoveTo(30, 4);
fBottomSwatchViews->MoveTo(30, fTopSwatchViews->Frame().bottom + 1); fBottomSwatchViews->MoveTo(30, fTopSwatchViews->Frame().bottom + 1);
@@ -96,6 +99,7 @@ SwatchGroup::SwatchGroup(BRect frame)
fCurrentColorSV->MoveTo(0, fTopSwatchViews->Frame().top); fCurrentColorSV->MoveTo(0, fTopSwatchViews->Frame().top);
fCurrentColorSV->ResizeTo(28, fBottomSwatchViews->Frame().bottom fCurrentColorSV->ResizeTo(28, fBottomSwatchViews->Frame().bottom
- fTopSwatchViews->Frame().top); - fTopSwatchViews->Frame().top);
fCurrentColorSV->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
float width = fTopSwatchViews->Frame().right float width = fTopSwatchViews->Frame().right
- fCurrentColorSV->Frame().left; - fCurrentColorSV->Frame().left;