Start main window and feed tab

This commit is contained in:
Jaidyn Ann 2020-12-30 21:13:12 -06:00
parent 3c0725b272
commit f46a53fdc5
7 changed files with 183 additions and 90 deletions

View File

@ -9,7 +9,7 @@
#include "Config.h"
#include "Util.h"
#include "App.h"
#include "PrefWindow.h"
#include "MainWindow.h"
#include "Invocation.h"
@ -48,8 +48,8 @@ cliStart ( int argc, char** argv )
App::App ( )
: BApplication("application/x-vnd.Pogger")
{
// PrefWindow* prefWin = new PrefWindow();
// prefWin->Show();
MainWindow* mainWin = new MainWindow();
mainWin->Show();
}

42
src/FeedView.cpp Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright 2020, Jaidyn Levesque <jadedctrl@teknik.io>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "FeedView.h"
#include <Message.h>
#include <GroupView.h>
#include <LayoutBuilder.h>
FeedView::FeedView(const char* name)
:
BGroupView(name, B_VERTICAL, B_USE_DEFAULT_SPACING)
{
_InitInterface();
}
void
FeedView::MessageReceived(BMessage* msg)
{
}
void
FeedView::_InitInterface()
{
fTestButton = new BButton("stest", "Do Nothing!",
new BMessage('pppq'));
fTestButton->SetTarget(this);
fTestButton->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0)
.Add(fTestButton)
.SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING, B_USE_WINDOW_SPACING);
}

29
src/FeedView.h Normal file
View File

@ -0,0 +1,29 @@
/*
* Copyright 2020, Jaidyn Levesque <jadedctrl@teknik.io>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef FEEDVIEW_H
#define FEEDVIEW_H
#include <Button.h>
#include <SupportDefs.h>
#include <GroupView.h>
class BMessage;
class FeedView : public BGroupView {
public:
FeedView(const char* name);
void MessageReceived(BMessage* msg);
private:
void _InitInterface();
BButton* fTestButton;
};
#endif // FEEDVIEW_H

79
src/MainWindow.cpp Normal file
View File

@ -0,0 +1,79 @@
/*
* Copyright 2020, Jaidyn Levesque <jadedctrl@teknik.io>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "MainWindow.h"
#include <Button.h>
#include <GroupView.h>
#include <TabView.h>
#include <LayoutBuilder.h>
#include <SeparatorView.h>
#include <String.h>
#include "App.h"
enum { M_BUTTON_CLICKED = 'btcl' };
MainWindow::MainWindow (void)
:
BWindow(BRect(0,0,0,0), "Pogger", B_TITLED_WINDOW, B_NOT_RESIZABLE
| B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_QUIT_ON_WINDOW_CLOSE)
{
_InitInterface();
MoveTo(BPoint(-1000.0,-1000.0));
MoveOnScreen();
}
void
MainWindow::MessageReceived(BMessage *msg)
{
switch (msg->what)
{
case M_BUTTON_CLICKED:
{
BString labelString("Clicks: ");
labelString << "DAD";
SetTitle(labelString.String());
break;
}
default:
{
BWindow::MessageReceived(msg);
break;
}
}
}
void
MainWindow::_InitInterface()
{
fBaseView = new BGroupView("baseView");
fTabView = new BTabView("tabView", B_WIDTH_FROM_WIDEST);
fFeedView = new FeedView("Feeds");
fTabView->AddTab(fFeedView);
fTabView->SetBorder(B_NO_BORDER);
fBaseView->AddChild(fTabView);
fServiceToggleButton = new BButton("stoggle", "Start Service",
new BMessage('pppp'));
// fRevertButton->SetEnabled(false);
fServiceToggleButton->SetTarget(this);
fServiceToggleButton->SetExplicitAlignment(
BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0)
.Add(fBaseView)
.Add(new BSeparatorView(B_HORIZONTAL))
.AddGroup(B_HORIZONTAL)
.Add(fServiceToggleButton)
.SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING, B_USE_WINDOW_SPACING);
}

30
src/MainWindow.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef PREFWINDOW_H
#define PREFWINDOW_H
#include <Window.h>
#include "FeedView.h"
class BButton;
class BGroupView;
class BTabView;
class MainWindow : public BWindow {
public:
MainWindow();
void MessageReceived(BMessage*);
private:
void _InitInterface();
BGroupView* fBaseView;
BTabView* fTabView;
FeedView* fFeedView;
BButton* fServiceToggleButton;
};
#endif

View File

@ -1,66 +0,0 @@
#include "PrefWindow.h"
#include <Button.h>
#include <View.h>
#include <String.h>
enum
{
M_BUTTON_CLICKED = 'btcl'
};
PrefWindow::PrefWindow ( void )
: BWindow( BRect(100,100,300,200),"Pogger",B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE )
{
BButton *button = new BButton( BRect(10,10,11,11),"button", "Click Me!",
new BMessage(M_BUTTON_CLICKED) );
AddChild(button);
button->ResizeToPreferred();
BView *view = new BView(BRect(100,100,300,200), "colorview", B_FOLLOW_ALL, B_WILL_DRAW);
//view->AddChild(button);
//AddChild(view);
view->SetViewColor(255,255,255);
view->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
view->Invalidate();
}
void
PrefWindow::MessageReceived ( BMessage *msg )
{
// The way that BMessages are identified is by the public property
// 'what'.
switch (msg->what)
{
// If the message was the one sent to the window by the
// button
case M_BUTTON_CLICKED:
{
BString labelString("Clicks: ");
// This converts fCount to a string and appends it to
// the end of labelString. More on this next lesson.
labelString << "DAD";
// Set the window's title to the new string we've made
SetTitle(labelString.String());
break;
}
default:
{
// If the message doesn't match one of the ones we
// explicitly define, it must be some sort of system
// message, so we will call the BWindow version of
// MessageReceived() so that it can handle them. THIS
// IS REQUIRED if you want your window to act
// the way that you expect it to.
BWindow::MessageReceived(msg);
break;
}
}
}

View File

@ -1,21 +0,0 @@
#ifndef PREFWINDOW_H
#define PREFWINDOW_H
#include <Window.h>
class PrefWindow : public BWindow
{
public:
PrefWindow ( void );
// void MessageRecieved ( BMessage* );
void MessageReceived(BMessage*);
private:
BView* fMainView;
void _InitInterface ( void );
};
#endif