Preferences window-sizing, BBoxes for settings

This commit is contained in:
Jaidyn Ann 2021-07-24 13:25:44 -05:00
parent 43a7e7111d
commit c7c02e79c9
8 changed files with 108 additions and 129 deletions

View File

@ -1,9 +1,11 @@
/* /*
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved. * Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
* Copyright 2021, Jaidyn Levesque. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com * Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
* Jaidyn Levesque, jadedctrl@teknik.io
*/ */
#include <Button.h> #include <Button.h>
@ -92,10 +94,9 @@ PreferencesAccounts::PreferencesAccounts()
fToggleButton->SetEnabled(false); fToggleButton->SetEnabled(false);
BLayoutBuilder::Group<>(this, B_VERTICAL) BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(scrollView) .Add(scrollView)
.AddGroup(B_HORIZONTAL) .AddGroup(B_HORIZONTAL)
.SetInsets(0, 0, 0, 15) .SetInsets(B_USE_HALF_ITEM_SPACING)
.Add(proto) .Add(proto)
.Add(fDelButton) .Add(fDelButton)
.AddGlue() .AddGlue()

View File

@ -1,28 +1,20 @@
/* /*
* Copyright 2010, Oliver Ruiz Dorantes. All rights reserved. * Copyright 2010, Oliver Ruiz Dorantes. All rights reserved.
* Copyright 2012, Dario Casalinuovo. All rights reserved. * Copyright 2012, Dario Casalinuovo. All rights reserved.
* Copyright 2021, Jaidyn Levesque. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include <Button.h> #include "PreferencesBehavior.h"
#include <Box.h>
#include <Catalog.h> #include <Catalog.h>
#include <CheckBox.h> #include <CheckBox.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <Deskbar.h> #include <LayoutBuilder.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <ScrollView.h>
#include <StringView.h>
#include "AccountManager.h" #include "AccountManager.h"
#include "ChatProtocol.h"
#include "PreferencesBehavior.h"
#include "AppPreferences.h" #include "AppPreferences.h"
#include "ProtocolManager.h"
#include "ProtocolSettings.h"
#include "MainWindow.h"
#include "ReplicantStatusView.h"
#include "TheApp.h"
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
@ -43,11 +35,8 @@ const uint32 kDisablePrompt = 'DiPr';
PreferencesBehavior::PreferencesBehavior() PreferencesBehavior::PreferencesBehavior()
: BView(B_TRANSLATE("Behavior"), B_WILL_DRAW) : BView(B_TRANSLATE("Behavior"), B_WILL_DRAW)
{ {
BBox* incomingBox = new BBox("incoming");
fOnIncoming = new BStringView("onIncoming", B_TRANSLATE("On incoming " incomingBox->SetLabel(B_TRANSLATE("On incoming" B_UTF8_ELLIPSIS));
"message" B_UTF8_ELLIPSIS));
fOnIncoming->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
fOnIncoming->SetFont(be_bold_font);
fHideOffline = new BCheckBox("HideOfflineContacts", fHideOffline = new BCheckBox("HideOfflineContacts",
B_TRANSLATE("Hide offline contacts"), B_TRANSLATE("Hide offline contacts"),
@ -79,11 +68,8 @@ PreferencesBehavior::PreferencesBehavior()
fMarkUnreadReplicant->SetEnabled(false); fMarkUnreadReplicant->SetEnabled(false);
// not implemented // not implemented
fNotifications = new BStringView("notifications", BBox* notificationBox = new BBox("notificationBox");
B_TRANSLATE("Deskbar Notifications (experimental)")); notificationBox->SetLabel(B_TRANSLATE("Deskbar notifications"));
fNotifications->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
fNotifications->SetFont(be_bold_font);
fNotifyProtocols = new BCheckBox("EnableProtocolNotify", fNotifyProtocols = new BCheckBox("EnableProtocolNotify",
B_TRANSLATE("Enable protocol status notifications"), B_TRANSLATE("Enable protocol status notifications"),
@ -97,19 +83,22 @@ PreferencesBehavior::PreferencesBehavior()
B_TRANSLATE("Enable message notifications"), B_TRANSLATE("Enable message notifications"),
new BMessage(kNotifyNewMessage)); new BMessage(kNotifyNewMessage));
fGeneral = new BStringView("onGeneral", B_TRANSLATE("General")); BBox* generalBox = new BBox("general");
fGeneral->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); generalBox->SetLabel(B_TRANSLATE("General"));
fGeneral->SetFont(be_bold_font);
fDisableQuitConfirm = new BCheckBox("DisableQuitConfirm", fDisableQuitConfirm = new BCheckBox("DisableQuitConfirm",
B_TRANSLATE("Don't ask confirmation at Quit"), B_TRANSLATE("Don't ask confirmation at Quit"),
new BMessage(kDisablePrompt)); new BMessage(kDisablePrompt));
const float spacing = be_control_look->DefaultItemSpacing(); const float spacing = be_control_look->DefaultItemSpacing();
SetLayout(new BGroupLayout(B_HORIZONTAL, spacing));
AddChild(BGroupLayoutBuilder(B_VERTICAL) BLayoutBuilder::Group<>(generalBox, B_VERTICAL)
.Add(fOnIncoming) .SetInsets(spacing, spacing * 2, spacing, spacing)
.AddGroup(B_VERTICAL, spacing) .Add(fDisableQuitConfirm)
.End();
BLayoutBuilder::Group<>(incomingBox, B_VERTICAL)
.SetInsets(spacing, spacing * 2, spacing, spacing)
.Add(fHideOffline) .Add(fHideOffline)
.Add(fToCurrentWorkspace) .Add(fToCurrentWorkspace)
.Add(fRaiseOnMessageReceived) .Add(fRaiseOnMessageReceived)
@ -117,24 +106,22 @@ PreferencesBehavior::PreferencesBehavior()
.Add(fMarkUnreadWindow) .Add(fMarkUnreadWindow)
.Add(fMarkUnreadReplicant) .Add(fMarkUnreadReplicant)
.Add(fPlaySoundOnMessageReceived) .Add(fPlaySoundOnMessageReceived)
. SetInsets(spacing * 2, spacing, spacing, spacing) .End();
.End()
.Add(fGeneral) BLayoutBuilder::Group<>(notificationBox, B_VERTICAL)
.AddGroup(B_VERTICAL, spacing) .SetInsets(spacing, spacing * 2, spacing, spacing)
.Add(fDisableQuitConfirm)
. SetInsets(spacing * 2, spacing, spacing, spacing)
.End()
.Add(fNotifications)
.AddGroup(B_VERTICAL, spacing)
.Add(fNotifyProtocols) .Add(fNotifyProtocols)
.Add(fNotifyContactStatus) .Add(fNotifyContactStatus)
.Add(fNotifyNewMessage) .Add(fNotifyNewMessage)
. SetInsets(spacing * 2, spacing, spacing, spacing) .End();
.End()
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(generalBox)
.Add(incomingBox)
.Add(notificationBox)
.AddGlue() .AddGlue()
.SetInsets(spacing, spacing, spacing, spacing) .End();
.TopView()
);
} }

View File

@ -9,7 +9,6 @@
#include <View.h> #include <View.h>
class BCheckBox; class BCheckBox;
class BStringView;
class PreferencesBehavior : public BView { class PreferencesBehavior : public BView {
public: public:
@ -20,7 +19,6 @@ public:
private: private:
BStringView* fOnIncoming;
BCheckBox* fHideOffline; BCheckBox* fHideOffline;
BCheckBox* fToCurrentWorkspace; BCheckBox* fToCurrentWorkspace;
BCheckBox* fRaiseOnMessageReceived; BCheckBox* fRaiseOnMessageReceived;
@ -28,14 +26,12 @@ private:
BCheckBox* fPlaySoundOnMessageReceived; BCheckBox* fPlaySoundOnMessageReceived;
BCheckBox* fMarkUnreadWindow; BCheckBox* fMarkUnreadWindow;
BCheckBox* fMarkUnreadReplicant; BCheckBox* fMarkUnreadReplicant;
BStringView* fGeneral;
BCheckBox* fDisableQuitConfirm; BCheckBox* fDisableQuitConfirm;
BStringView* fNotifications;
BCheckBox* fNotifyProtocols; BCheckBox* fNotifyProtocols;
BCheckBox* fNotifyContactStatus; BCheckBox* fNotifyContactStatus;
BCheckBox* fNotifyNewMessage; BCheckBox* fNotifyNewMessage;
}; };
#endif // _PREFERENCES_BEHAVIOR_H #endif // _PREFERENCES_BEHAVIOR_H

View File

@ -1,23 +1,19 @@
/* /*
* Copyright 2010, Oliver Ruiz Dorantes. All rights reserved. * Copyright 2010, Oliver Ruiz Dorantes. All rights reserved.
* Copyright 2012, Dario Casalinuovo. All rights reserved. * Copyright 2012, Dario Casalinuovo. All rights reserved.
* Copyright 2021, Jaidyn Levesque. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include "PreferencesChatWindow.h"
#include <Box.h>
#include <Catalog.h> #include <Catalog.h>
#include <CheckBox.h> #include <CheckBox.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <GroupLayout.h> #include <LayoutBuilder.h>
#include <GroupLayoutBuilder.h>
#include <StringView.h>
#include "ChatProtocol.h"
#include "PreferencesChatWindow.h"
#include "AppPreferences.h" #include "AppPreferences.h"
#include "ProtocolManager.h"
#include "ProtocolSettings.h"
#include "MainWindow.h"
#include "TheApp.h"
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
@ -28,32 +24,28 @@ const uint32 kIgnoreEmoticons = 'CBhe';
PreferencesChatWindow::PreferencesChatWindow() PreferencesChatWindow::PreferencesChatWindow()
: BView(B_TRANSLATE("Chat display"), B_WILL_DRAW) : BView(B_TRANSLATE("Chat view"), B_WILL_DRAW)
{ {
BBox* chatBox = new BBox("chatBox");
fChatWindowString = new BStringView("ChatWindowString", chatBox->SetLabel(B_TRANSLATE("Chat settings"));
B_TRANSLATE("Chat settings"));
fChatWindowString->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
fChatWindowString->SetFont(be_bold_font);
fIgnoreEmoticons = new BCheckBox("IgnoreEmoticons", fIgnoreEmoticons = new BCheckBox("IgnoreEmoticons",
B_TRANSLATE("Ignore emoticons"), B_TRANSLATE("Ignore emoticons"), new BMessage(kIgnoreEmoticons));
new BMessage(kIgnoreEmoticons));
fIgnoreEmoticons->SetEnabled(true); fIgnoreEmoticons->SetEnabled(true);
const float spacing = be_control_look->DefaultItemSpacing(); const float spacing = be_control_look->DefaultItemSpacing();
SetLayout(new BGroupLayout(B_HORIZONTAL, spacing));
AddChild(BGroupLayoutBuilder(B_VERTICAL) BLayoutBuilder::Group<>(chatBox, B_VERTICAL)
.Add(fChatWindowString) .SetInsets(spacing, spacing * 2, spacing, spacing)
.AddGroup(B_VERTICAL, spacing)
.Add(fIgnoreEmoticons) .Add(fIgnoreEmoticons)
.SetInsets(spacing * 2, spacing, spacing, spacing) .End();
.End()
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(chatBox)
.AddGlue() .AddGlue()
.SetInsets(spacing, spacing, spacing, spacing) .End();
.TopView()
);
} }
@ -61,9 +53,7 @@ void
PreferencesChatWindow::AttachedToWindow() PreferencesChatWindow::AttachedToWindow()
{ {
fIgnoreEmoticons->SetTarget(this); fIgnoreEmoticons->SetTarget(this);
fIgnoreEmoticons->SetValue( fIgnoreEmoticons->SetValue(AppPreferences::Item()->IgnoreEmoticons);
AppPreferences::Item()->IgnoreEmoticons);
} }

View File

@ -9,7 +9,6 @@
#include <View.h> #include <View.h>
class BCheckBox; class BCheckBox;
class BStringView;
class PreferencesChatWindow : public BView { class PreferencesChatWindow : public BView {
public: public:
@ -19,9 +18,6 @@ public:
virtual void MessageReceived(BMessage* msg); virtual void MessageReceived(BMessage* msg);
private: private:
BStringView* fChatWindowString;
BCheckBox* fIgnoreEmoticons; BCheckBox* fIgnoreEmoticons;
}; };

View File

@ -1,26 +1,20 @@
/* /*
* Copyright 2010, Oliver Ruiz Dorantes. All rights reserved. * Copyright 2010, Oliver Ruiz Dorantes. All rights reserved.
* Copyright 2012, Dario Casalinuovo. All rights reserved. * Copyright 2012, Dario Casalinuovo. All rights reserved.
* Copyright 2021, Jaidyn Levesque. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include "PreferencesReplicant.h"
#include <Box.h>
#include <Catalog.h> #include <Catalog.h>
#include <CheckBox.h> #include <CheckBox.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <Deskbar.h> #include <LayoutBuilder.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <StringView.h>
#include "AccountManager.h"
#include "ChatProtocol.h"
#include "PreferencesReplicant.h"
#include "AppPreferences.h" #include "AppPreferences.h"
#include "ProtocolManager.h"
#include "ProtocolSettings.h"
#include "MainWindow.h"
#include "ReplicantStatusView.h" #include "ReplicantStatusView.h"
#include "TheApp.h"
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
@ -35,13 +29,8 @@ const uint32 kHideDeskbar = 'HCtk';
PreferencesReplicant::PreferencesReplicant() PreferencesReplicant::PreferencesReplicant()
: BView(B_TRANSLATE("Replicant"), B_WILL_DRAW) : BView(B_TRANSLATE("Replicant"), B_WILL_DRAW)
{ {
fReplicantString = new BStringView("ReplicantString", BBox* replicantBox = new BBox("replicantBox");
B_TRANSLATE("Deskbar replicant")); replicantBox->SetLabel(B_TRANSLATE("Deskbar replicant"));
fReplicantString->SetExplicitAlignment(
BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
fReplicantString->SetFont(be_bold_font);
fDisableReplicant = new BCheckBox("DisableReplicant", fDisableReplicant = new BCheckBox("DisableReplicant",
B_TRANSLATE("Disable deskbar replicant"), B_TRANSLATE("Disable deskbar replicant"),
@ -58,21 +47,21 @@ PreferencesReplicant::PreferencesReplicant()
B_TRANSLATE("Hide field in Deskbar"), new BMessage(kHideDeskbar)); B_TRANSLATE("Hide field in Deskbar"), new BMessage(kHideDeskbar));
fHideDeskbar->SetEnabled(false); fHideDeskbar->SetEnabled(false);
const float spacing = be_control_look->DefaultItemSpacing(); const float spacing = be_control_look->DefaultItemSpacing();
SetLayout(new BGroupLayout(B_HORIZONTAL, spacing)); BLayoutBuilder::Group<>(replicantBox, B_VERTICAL)
AddChild(BGroupLayoutBuilder(B_VERTICAL) .SetInsets(spacing, spacing * 2, spacing, spacing)
.Add(fReplicantString)
.AddGroup(B_VERTICAL, spacing)
.Add(fDisableReplicant) .Add(fDisableReplicant)
.Add(fPermanentReplicant) .Add(fPermanentReplicant)
.Add(fHideDeskbar) .Add(fHideDeskbar)
.SetInsets(spacing * 2, spacing, spacing, spacing) .End();
.End()
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(replicantBox)
.AddGlue() .AddGlue()
.SetInsets(spacing, spacing, spacing, spacing) .End();
.TopView()
);
} }

View File

@ -9,7 +9,6 @@
#include <View.h> #include <View.h>
class BCheckBox; class BCheckBox;
class BStringView;
class PreferencesReplicant : public BView { class PreferencesReplicant : public BView {
public: public:
@ -19,7 +18,6 @@ public:
virtual void MessageReceived(BMessage* msg); virtual void MessageReceived(BMessage* msg);
private: private:
BStringView* fReplicantString;
BCheckBox* fDisableReplicant; BCheckBox* fDisableReplicant;
BCheckBox* fPermanentReplicant; BCheckBox* fPermanentReplicant;
BCheckBox* fHideDeskbar; BCheckBox* fHideDeskbar;

View File

@ -29,7 +29,8 @@ const uint32 kApply = 'SAVE';
PreferencesWindow::PreferencesWindow() PreferencesWindow::PreferencesWindow()
: BWindow(BRect(0, 0, 500, 615), B_TRANSLATE("Preferences"), : BWindow(BRect(0, 0, 500, 615), B_TRANSLATE("Preferences"),
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE) B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_RESIZABLE
| B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE)
{ {
BTabView* tabView = new BTabView("tabView", B_WIDTH_AS_USUAL); BTabView* tabView = new BTabView("tabView", B_WIDTH_AS_USUAL);
tabView->AddTab(new PreferencesAccounts()); tabView->AddTab(new PreferencesAccounts());
@ -37,13 +38,34 @@ PreferencesWindow::PreferencesWindow()
tabView->AddTab(new PreferencesChatWindow()); tabView->AddTab(new PreferencesChatWindow());
tabView->AddTab(new PreferencesReplicant()); tabView->AddTab(new PreferencesReplicant());
// Tab resizing here is a bit wonky. We want each tab to be visible,
// but we don't want the tab-view to be too wide…
float charCount = 0;
for (int i = 0; i < tabView->CountTabs(); i++)
charCount += strlen(tabView->TabAt(i)->Label());
// These values account for the decreasing amount of padding within tabs,
// Ignucius forgive me.
float textWidth = be_plain_font->Size();
switch ((int)textWidth) {
case 8: case 9: charCount += 14; break;
case 10: case 11: charCount += 5; break;
case 12: break;
case 13: case 14: case 15:
charCount -= 4; break;
default: charCount -= 10;
}
tabView->SetExplicitMinSize(BSize(charCount * textWidth, B_SIZE_UNSET));
BButton* ok = new BButton(B_TRANSLATE("OK"), new BMessage(kApply)); BButton* ok = new BButton(B_TRANSLATE("OK"), new BMessage(kApply));
BLayoutBuilder::Group<>(this, B_VERTICAL) BLayoutBuilder::Group<>(this, B_VERTICAL)
.Add(tabView) .Add(tabView)
.AddGroup(B_HORIZONTAL) .AddGroup(B_HORIZONTAL)
.SetInsets(0, 0, B_USE_HALF_ITEM_SPACING, B_USE_HALF_ITEM_SPACING)
.AddGlue() .AddGlue()
.Add(ok) .Add(ok)
.End()
.End(); .End();
CenterOnScreen(); CenterOnScreen();