mirror of
https://github.com/uowuo/abaddon.git
synced 2024-11-10 14:10:10 +00:00
mobile layout (#24)
This commit is contained in:
parent
2065ef4940
commit
a7bf9a2404
@ -57,7 +57,7 @@ ChannelListRowDMChannel::ChannelListRowDMChannel(const ChannelData *data) {
|
||||
if (recipients.size() > 0)
|
||||
top_recipient = recipients[0];
|
||||
|
||||
const static bool alt = Abaddon::Get().GetSettings().GetAltChannelWidget();
|
||||
const static bool alt = Abaddon::Get().GetSettings().GetUseMobileLayout();
|
||||
if (alt) {
|
||||
auto *tmp = Gtk::manage(new Gtk::Label);
|
||||
m_lbl = tmp;
|
||||
@ -131,7 +131,7 @@ ChannelListRowGuild::ChannelListRowGuild(const GuildData *data) {
|
||||
m_ev = Gtk::manage(new Gtk::EventBox);
|
||||
m_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
|
||||
|
||||
const static bool alt = Abaddon::Get().GetSettings().GetAltChannelWidget();
|
||||
const static bool alt = Abaddon::Get().GetSettings().GetUseMobileLayout();
|
||||
if (alt) {
|
||||
m_lbl = Gtk::manage(new Gtk::Label(data->Name));
|
||||
} else {
|
||||
@ -219,7 +219,7 @@ ChannelListRowCategory::ChannelListRowCategory(const ChannelData *data) {
|
||||
m_ev = Gtk::manage(new Gtk::EventBox);
|
||||
m_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
|
||||
|
||||
const static bool alt = Abaddon::Get().GetSettings().GetAltChannelWidget();
|
||||
const static bool alt = Abaddon::Get().GetSettings().GetUseMobileLayout();
|
||||
if (alt) {
|
||||
m_lbl = Gtk::manage(new Gtk::Label(*data->Name));
|
||||
} else {
|
||||
@ -274,7 +274,7 @@ ChannelListRowChannel::ChannelListRowChannel(const ChannelData *data) {
|
||||
m_ev = Gtk::manage(new Gtk::EventBox);
|
||||
m_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
|
||||
|
||||
const static bool alt = Abaddon::Get().GetSettings().GetAltChannelWidget();
|
||||
const static bool alt = Abaddon::Get().GetSettings().GetUseMobileLayout();
|
||||
if (alt) {
|
||||
m_lbl = Gtk::manage(new Gtk::Label("#" + *data->Name));
|
||||
} else {
|
||||
|
@ -82,6 +82,7 @@ bool SettingsManager::GetShowOwnerCrown() const {
|
||||
return GetSettingBool("gui", "owner_crown", true);
|
||||
}
|
||||
|
||||
bool SettingsManager::GetAltChannelWidget() const {
|
||||
return GetSettingBool("gui", "alt_channel_widget", false);
|
||||
bool SettingsManager::GetUseMobileLayout() const {
|
||||
// todo: see if there's some sort of preprocessor directive to default this to true on mobile platforms
|
||||
return GetSettingBool("gui", "mobile", false);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
std::string GetMainCSS() const;
|
||||
bool GetShowAnimations() const;
|
||||
bool GetShowOwnerCrown() const;
|
||||
bool GetAltChannelWidget() const;
|
||||
bool GetUseMobileLayout() const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
#include "mainwindow.hpp"
|
||||
#include "../abaddon.hpp"
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: m_main_box(Gtk::ORIENTATION_VERTICAL)
|
||||
, m_content_box(Gtk::ORIENTATION_HORIZONTAL)
|
||||
, m_chan_chat_paned(Gtk::ORIENTATION_HORIZONTAL)
|
||||
, m_chat_members_paned(Gtk::ORIENTATION_HORIZONTAL) {
|
||||
MainWindow::MainWindow() {
|
||||
const bool use_mobile = Abaddon::Get().GetSettings().GetUseMobileLayout();
|
||||
|
||||
set_default_size(1200, 800);
|
||||
get_style_context()->add_class("app-window");
|
||||
|
||||
@ -79,26 +77,10 @@ MainWindow::MainWindow()
|
||||
m_signal_action_add_recipient.emit(GetChatActiveChannel());
|
||||
});
|
||||
|
||||
m_content_box.set_hexpand(true);
|
||||
m_content_box.set_vexpand(true);
|
||||
m_content_box.show();
|
||||
|
||||
m_main_box.add(m_menu_bar);
|
||||
m_main_box.add(m_content_box);
|
||||
m_main_box.show();
|
||||
|
||||
auto *channel_list = m_channel_list.GetRoot();
|
||||
auto *member_list = m_members.GetRoot();
|
||||
auto *chat = m_chat.GetRoot();
|
||||
|
||||
m_members.signal_action_show_user_menu().connect([this](const GdkEvent *event, Snowflake id, Snowflake guild_id) {
|
||||
m_signal_action_show_user_menu.emit(event, id, guild_id);
|
||||
});
|
||||
|
||||
m_chat.signal_action_open_user_menu().connect([this](const GdkEvent *event, Snowflake id, Snowflake guild_id) {
|
||||
m_signal_action_show_user_menu.emit(event, id, guild_id);
|
||||
});
|
||||
|
||||
chat->set_vexpand(true);
|
||||
chat->set_hexpand(true);
|
||||
chat->show();
|
||||
@ -110,24 +92,76 @@ MainWindow::MainWindow()
|
||||
member_list->set_vexpand(true);
|
||||
member_list->show();
|
||||
|
||||
m_chan_chat_paned.pack1(*channel_list);
|
||||
m_chan_chat_paned.pack2(m_chat_members_paned);
|
||||
m_chan_chat_paned.child_property_shrink(*channel_list) = false;
|
||||
m_chan_chat_paned.child_property_resize(*channel_list) = false;
|
||||
m_chan_chat_paned.set_position(200);
|
||||
m_chan_chat_paned.show();
|
||||
m_content_box.add(m_chan_chat_paned);
|
||||
if (use_mobile) {
|
||||
m_main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
|
||||
|
||||
m_chat_members_paned.pack1(*chat);
|
||||
m_chat_members_paned.pack2(*member_list);
|
||||
m_chat_members_paned.child_property_shrink(*member_list) = false;
|
||||
m_chat_members_paned.child_property_resize(*member_list) = false;
|
||||
int w, h;
|
||||
get_default_size(w, h); // :s
|
||||
m_chat_members_paned.set_position(w - m_chan_chat_paned.get_position() - 150);
|
||||
m_chat_members_paned.show();
|
||||
m_stack = Gtk::manage(new Gtk::Stack);
|
||||
m_switcher = Gtk::manage(new Gtk::StackSwitcher);
|
||||
|
||||
add(m_main_box);
|
||||
m_stack->set_transition_type(Gtk::STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
|
||||
|
||||
m_stack->add(*m_channel_list.GetRoot(), "Channels");
|
||||
m_stack->add(*m_chat.GetRoot(), "Chat");
|
||||
m_stack->add(*m_members.GetRoot(), "Members");
|
||||
m_stack->child_property_icon_name(*m_channel_list.GetRoot()) = "format-justify-fill-symbolic";
|
||||
m_stack->child_property_icon_name(*m_chat.GetRoot()) = "user-invisible-symbolic";
|
||||
m_stack->child_property_icon_name(*m_members.GetRoot()) = "avatar-default-symbolic";
|
||||
|
||||
m_switcher->set_hexpand(true);
|
||||
m_switcher->set_halign(Gtk::ALIGN_FILL);
|
||||
m_switcher->set_homogeneous(true);
|
||||
|
||||
m_main_box->add(m_menu_bar);
|
||||
m_main_box->add(*m_stack);
|
||||
m_main_box->add(*m_switcher);
|
||||
m_switcher->set_stack(*m_stack);
|
||||
|
||||
m_stack->show();
|
||||
m_switcher->show_all();
|
||||
m_main_box->show();
|
||||
|
||||
add(*m_main_box);
|
||||
} else {
|
||||
m_main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
|
||||
m_content_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
|
||||
m_chan_chat_paned = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_HORIZONTAL));
|
||||
m_chat_members_paned = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_HORIZONTAL));
|
||||
|
||||
m_content_box->set_hexpand(true);
|
||||
m_content_box->set_vexpand(true);
|
||||
m_content_box->show();
|
||||
|
||||
m_main_box->add(m_menu_bar);
|
||||
m_main_box->add(*m_content_box);
|
||||
m_main_box->show();
|
||||
|
||||
m_chan_chat_paned->pack1(*channel_list);
|
||||
m_chan_chat_paned->pack2(*m_chat_members_paned);
|
||||
m_chan_chat_paned->child_property_shrink(*channel_list) = false;
|
||||
m_chan_chat_paned->child_property_resize(*channel_list) = false;
|
||||
m_chan_chat_paned->set_position(200);
|
||||
m_chan_chat_paned->show();
|
||||
m_content_box->add(*m_chan_chat_paned);
|
||||
|
||||
m_chat_members_paned->pack1(*chat);
|
||||
m_chat_members_paned->pack2(*member_list);
|
||||
m_chat_members_paned->child_property_shrink(*member_list) = false;
|
||||
m_chat_members_paned->child_property_resize(*member_list) = false;
|
||||
int w, h;
|
||||
get_default_size(w, h); // :s
|
||||
m_chat_members_paned->set_position(w - m_chan_chat_paned->get_position() - 150);
|
||||
m_chat_members_paned->show();
|
||||
|
||||
add(*m_main_box);
|
||||
}
|
||||
|
||||
m_members.signal_action_show_user_menu().connect([this](const GdkEvent *event, Snowflake id, Snowflake guild_id) {
|
||||
m_signal_action_show_user_menu.emit(event, id, guild_id);
|
||||
});
|
||||
|
||||
m_chat.signal_action_open_user_menu().connect([this](const GdkEvent *event, Snowflake id, Snowflake guild_id) {
|
||||
m_signal_action_show_user_menu.emit(event, id, guild_id);
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::UpdateComponents() {
|
||||
@ -202,6 +236,10 @@ void MainWindow::UpdateChatActiveChannel(Snowflake id) {
|
||||
m_chat.SetActiveChannel(id);
|
||||
m_members.SetActiveChannel(id);
|
||||
m_channel_list.SetActiveChannel(id);
|
||||
|
||||
if (m_stack != nullptr) {
|
||||
m_stack->set_visible_child("Chat");
|
||||
}
|
||||
}
|
||||
|
||||
Snowflake MainWindow::GetChatActiveChannel() const {
|
||||
|
@ -66,10 +66,15 @@ protected:
|
||||
type_signal_action_add_recipient m_signal_action_add_recipient;
|
||||
|
||||
protected:
|
||||
Gtk::Box m_main_box;
|
||||
Gtk::Box m_content_box;
|
||||
Gtk::Paned m_chan_chat_paned;
|
||||
Gtk::Paned m_chat_members_paned;
|
||||
Gtk::Box *m_main_box;
|
||||
// normal
|
||||
Gtk::Box *m_content_box = nullptr;
|
||||
Gtk::Paned *m_chan_chat_paned = nullptr;
|
||||
Gtk::Paned *m_chat_members_paned = nullptr;
|
||||
|
||||
// mobile
|
||||
Gtk::StackSwitcher *m_switcher = nullptr;
|
||||
Gtk::Stack *m_stack = nullptr;
|
||||
|
||||
ChannelList m_channel_list;
|
||||
ChatWindow m_chat;
|
||||
|
Loading…
Reference in New Issue
Block a user