This commit is contained in:
hexlocation 2025-02-08 15:16:28 +00:00
parent 417bfa9c32
commit 43deda8646
2 changed files with 26 additions and 8 deletions

32
App.cpp
View file

@ -1,5 +1,6 @@
#include "App.h"
#include <Application.h>
#include <GridLayout.h>
#include <GroupLayout.h>
#include <InterfaceDefs.h>
#include <Layout.h>
@ -8,13 +9,14 @@
#include <Rect.h>
#include <String.h>
#include <StringView.h>
#include <GroupLayoutBuilder.h>
#include <Window.h>
#include <GroupLayoutBuilder.h>
#include <GridLayoutBuilder.h>
#include <Button.h>
#include <cstdio>
#include <format>
#include <iostream>
#include "Contacts.h"
#include <TextControl.h>
// quick and dirty function to quickly make text labels
BStringView *MakeText(const char* text)
@ -24,18 +26,21 @@ BStringView *MakeText(const char* text)
App::App(void) : BApplication(std::format("application/x-vnd.{}-{}", APP_AUTHOR, APP_NAME).c_str())
{
std::cout << "hello world!!\n";
// Initialize BRect frame for window
BRect frame(100, 100, 500, 400);
// Initialize parent group for all UI elements to sit in. This is so they all get grouped nicely together
BGroupLayout *pGroup = new BGroupLayout(B_HORIZONTAL);
// Create window
BWindow *window = new BWindow(frame, std::format("{} by {}", APP_NAME, APP_AUTHOR).c_str(), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS);
BWindow *window = new BWindow(frame, std::format("{}", APP_NAME).c_str(), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS);
// Set window layout to parent group created earlier
window->SetLayout(pGroup);
pGroup->View()->AdoptSystemColors();
/*
// Initialize special UI group for all of our "real" elements
BGroupLayout *uGroup = new BGroupLayout(B_HORIZONTAL, 100);
// Add label group to parent group
@ -45,10 +50,23 @@ App::App(void) : BApplication(std::format("application/x-vnd.{}-{}", APP_AUTHOR,
uGroup->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
// And finally, add a button!!
BButton *connectButton = new BButton(frame, "connect", "Connect to XMPP", new BMessage(msgConnectButtonClicked));
connectButton->SetTarget(this);
uGroup->AddView(connectButton);
*/
BGridLayout *uiElems = new BGridLayout(10, 0);
pGroup->AddItem(uiElems);
uiElems->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
BButton *connectButton = new BButton(frame, "connect", "Connect!", new BMessage(msgConnectButtonClicked));
connectButton->SetTarget(this);
BTextControl *jidInput = new BTextControl("jidinput", "JID:", "Placeholder", new BMessage(msgConnectButtonClicked));
BTextControl *pwInput = new BTextControl("jidinput", "JID:", "Placeholder", new BMessage(msgConnectButtonClicked));
uiElems->AddView(jidInput, 0, 0);
uiElems->AddView(MakeText("Password placeholder"), 0, 1);
uiElems->AddView(connectButton, 0, 2);
uiElems->SetMinRowHeight(2, 75);
window->Show();

2
App.h
View file

@ -7,7 +7,7 @@
#include <gloox/presencehandler.h>
#define APP_NAME "Renga"
#define APP_AUTHOR "hex_andre"
#define APP_AUTHOR "hex&andre"
const uint32 msgConnectButtonClicked = 'mCBC';