Skip to content

Commit

Permalink
Added Categorization Panel
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhmurali committed Aug 8, 2017
1 parent c53e365 commit d406727
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 7 deletions.
1 change: 1 addition & 0 deletions App.cpp
Expand Up @@ -18,6 +18,7 @@ App::App()
{
fMainWindow = new MainWindow();
fMainWindow->Show();
fMainWindow->Activate();
}

void
Expand Down
3 changes: 1 addition & 2 deletions App.h
Expand Up @@ -21,9 +21,8 @@ class App: public BApplication
public:
App();
void AboutRequested();

private:
MainWindow* fMainWindow;
MainWindow* fMainWindow;
};

#endif
57 changes: 57 additions & 0 deletions CategorySettingWindow.cpp
@@ -0,0 +1,57 @@
/*
* Copyright 2015 Your Name <your@email.address>
* All rights reserved. Distributed under the terms of the MIT license.
*/


#include "CategorySettingWindow.h"

CategorySettingWindow::CategorySettingWindow(vector<BString> vCustomApps)
: BWindow(BRect(),"Category Settings"
,B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS ) {

ResizeTo(400,400);
CenterOnScreen();
buildLayout(vCustomApps);
}
void
CategorySettingWindow::buildLayout(vector<BString> vCustomApps) {

fCategoryMenu = new BPopUpMenu("Select Category..");

fCategoryMenu->AddItem(new BMenuItem("Appearance",
new BMessage(kSetCategory)));
fCategoryMenu->AddItem(new BMenuItem("Input/Output",
new BMessage(kSetCategory)));
fCategoryMenu->AddItem(new BMenuItem("Connectivity",
new BMessage(kSetCategory)));
fCategoryMenu->AddItem(new BMenuItem("System",
new BMessage(kSetCategory)));
fCategoryMenu->AddItem(new BMenuItem("Uncategorized",
new BMessage(kSetCategory)));

for(int i = 0; i<vCustomApps.size(); i++) {

string* str = new string(vCustomApps[i]);
*str += string(": ");
CategoryField = new BMenuField("Category",
str->c_str(), fCategoryMenu);
CategoryField->SetAlignment(B_ALIGN_RIGHT);
}

BButton* bUpdate = new BButton("Apply Changes");

fWindowView = new BView("Main Window View", 0);
BLayoutBuilder::Group<>(fWindowView, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
.Add(CategoryField)
.End()
.Add(bUpdate)
.End();

BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.Add(fWindowView)
.End();
}

28 changes: 28 additions & 0 deletions CategorySettingWindow.h
@@ -0,0 +1,28 @@
/*
* Copyright 2015 Your Name <your@email.address>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef CATEGORYSETTINGWINDOW_H
#define CATEGORYSETTINGWINDOW_H


#include <Window.h>
#include "MainWindow.h"

class CategorySettingWindow: public BWindow {

static const uint32 kSetCategory = 'mnpl';

public:
CategorySettingWindow(vector<BString> vCustomApps);
void buildLayout(vector<BString> vCustomApps);
private:
BView* fWindowView;
BPopUpMenu* fCategoryMenu;
BMenuField* CategoryField;


};


#endif // CATEGORYSETTINGWINDOW_H
17 changes: 13 additions & 4 deletions MainWindow.cpp
Expand Up @@ -22,7 +22,8 @@ MainWindow::MainWindow()
fetchPreflets();
populateLayout();
mergeLayouts();
mergeLayoutsCategory();
mergeLayoutsCategory();
tSearch->MakeFocus(true);
}

void
Expand Down Expand Up @@ -130,6 +131,7 @@ MainWindow::populateLayout() {
BButton* button = new BButton(fAppName, fAppName, mButton);
button->SetFlat(true);
button->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
vCustomApps.push_back(fAppName);
NameButton[fAppName] = button;
bSetIcon(button, vSign[i]);
layout = CustomLayout->AddView(button);
Expand Down Expand Up @@ -243,7 +245,10 @@ MainWindow::buildMenubar() {
mAlphabetical = new BMenuItem("Sort Alphabetically", new BMessage(kAlphabeticalwise));
fAppMenu->AddItem(mAlphabetical);
mAlphabetical->SetMarked(false);


mAlphabetical = new BMenuItem("Set Categories..", new BMessage(kCategoryLaunch));
fAppMenu->AddItem(mAlphabetical);

fMenuBar->AddItem(fAppMenu);
fAppMenu = new BMenu("Help..");
BMenuItem* item = new BMenuItem("About..", new BMessage(B_ABOUT_REQUESTED));
Expand Down Expand Up @@ -349,8 +354,7 @@ MainWindow::buildLayout() {
.Layout();

tSearch = new BTextControl("Search:", "Enter query here: ", NULL, NULL);
tSearch->SetModificationMessage(new BMessage(QUERY));
tSearch->MakeFocus(true);
tSearch->SetModificationMessage(new BMessage(QUERY));
}

void
Expand Down Expand Up @@ -638,6 +642,11 @@ MainWindow::MessageReceived(BMessage* message)
if(!mAlphabetical->IsMarked() && checked % 2 ==0)
mergeLayoutsAlphabetical();
break;
}
case kCategoryLaunch:
{
fCategorySettingWindow = new CategorySettingWindow(vCustomApps);
fCategorySettingWindow->Show();
}
}
}
6 changes: 6 additions & 0 deletions MainWindow.h
Expand Up @@ -51,6 +51,9 @@
#include <GroupView.h>
#include <Roster.h>
#include <IconButton.h>
#include "CategorySettingWindow.h"

class CategorySettingWindow;

enum {
MSG_SIGN = 'axyz',
Expand All @@ -60,6 +63,7 @@ enum {
kMenuAppQuit = 0000,
kAlphabeticalwise = 0001,
kCategorywise = 0002,
kCategoryLaunch = 0003,
};

class MainWindow : public BWindow {
Expand All @@ -82,6 +86,7 @@ class MainWindow : public BWindow {
void mergeLayoutsApps();
void FlatTrue();
void FlatFalse(vector<BString>& vTemp);
vector<BString> vCustomApps;
private:
BMessage* mMenu;
BMessage* mButton;
Expand Down Expand Up @@ -141,6 +146,7 @@ class MainWindow : public BWindow {
map<BString, BButton*> NameButtonApps;
char* fAppSig;
int checked;
CategorySettingWindow* fCategorySettingWindow;
};

#endif
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -28,7 +28,7 @@ APP_MIME_SIG = x-vnd.SuperPrefs
# means this Makefile will not work correctly if two source files with the
# same name (source.c or source.cpp) are included from different directories.
# Also note that spaces in folder names do not work well with this Makefile.
SRCS = MainWindow.cpp App.cpp
SRCS = MainWindow.cpp App.cpp CategorySettingWindow.cpp

# Specify the resource definition files to use. Full or relative paths can be
# used.
Expand Down

1 comment on commit d406727

@anirudhmurali
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom Categories Panel - WIP

image

Please sign in to comment.