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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,7 +29,8 @@ const uint32 kApply = 'SAVE';
PreferencesWindow::PreferencesWindow()
: 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);
tabView->AddTab(new PreferencesAccounts());
@ -37,13 +38,34 @@ PreferencesWindow::PreferencesWindow()
tabView->AddTab(new PreferencesChatWindow());
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));
BLayoutBuilder::Group<>(this, B_VERTICAL)
.Add(tabView)
.AddGroup(B_HORIZONTAL)
.SetInsets(0, 0, B_USE_HALF_ITEM_SPACING, B_USE_HALF_ITEM_SPACING)
.AddGlue()
.Add(ok)
.End()
.End();
CenterOnScreen();