Skip to content

Commit

Permalink
Merge branch 'master' into stages
Browse files Browse the repository at this point in the history
  • Loading branch information
ouwou committed Jun 22, 2024
2 parents 3dc8fa8 + 7af15b3 commit e65174f
Show file tree
Hide file tree
Showing 29 changed files with 413 additions and 197 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ if (ENABLE_QRCODE_LOGIN)
target_compile_definitions(abaddon PRIVATE WITH_QRLOGIN)
endif ()

target_precompile_headers(abaddon PRIVATE <gtkmm.h> src/abaddon.hpp src/util.hpp)
if (NOT (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
target_precompile_headers(abaddon PRIVATE <gtkmm.h> src/abaddon.hpp src/util.hpp)
endif ()

if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
Expand Down Expand Up @@ -113,11 +115,12 @@ target_link_libraries(abaddon spdlog::spdlog)

target_link_libraries(abaddon ${SQLite3_LIBRARIES})
target_link_libraries(abaddon ${GTKMM_LIBRARIES})
target_link_libraries(abaddon ${CURL_LIBRARIES})
target_link_libraries(abaddon ${ZLIB_LIBRARY})
target_link_libraries(abaddon ${NLOHMANN_JSON_LIBRARIES})
target_link_libraries(abaddon ${CMAKE_DL_LIBS})

target_link_libraries(abaddon CURL::libcurl)

include(CheckAtomic)
if (NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
target_link_libraries(abaddon atomic)
Expand Down Expand Up @@ -146,6 +149,7 @@ if (APPLE)
target_link_libraries(abaddon "-framework CoreFoundation")
target_link_libraries(abaddon "-framework CoreAudio")
target_link_libraries(abaddon "-framework AudioToolbox")
target_link_libraries(abaddon "-framework AudioUnit")
endif ()

if (ENABLE_VOICE)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ For example, memory_db would be set by adding `memory_db = true` under the line
| Setting | Type | Default | Description |
|---------------|---------|---------|-------------------------|
| `hideconsole` | boolean | true | Hide console on startup |
| `hideconsole` | boolean | false | Hide console on startup |
### Environment variables
Expand Down
1 change: 1 addition & 0 deletions ci/msys-deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
/bin/libjpeg-8.dll
/bin/liblzma-5.dll
/bin/libnghttp2-14.dll
/bin/libnghttp3-9.dll
/bin/libopus-0.dll
/bin/libpango-1.0-0.dll
/bin/libpangocairo-1.0-0.dll
Expand Down
9 changes: 9 additions & 0 deletions res/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@
min-height: 0px;
}

.classic-mention-overlay:selected {
color: @theme_selected_color;
background-color: @theme_selected_bg_color;
}

.channel-list .view:selected {
background-color: @theme_selected_bg_color;
}
Expand All @@ -176,6 +181,10 @@
background: radial-gradient(7px circle at left, @theme_selected_bg_color 50%, transparent 20%);
}

.classic-guild-list-folder.has-unread stack {
background: radial-gradient(7px circle at left, @theme_selected_bg_color 50%, transparent 20%);
}

.classic-guild-list-guild box, .classic-guild-list-folder stack {
padding-left: 10px;
}
26 changes: 26 additions & 0 deletions src/abaddon.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "abaddon.hpp"
#include <cstdlib>
#include <memory>
#include <spdlog/spdlog.h>
#include <spdlog/cfg/env.h>
Expand Down Expand Up @@ -1153,7 +1154,32 @@ void Abaddon::on_window_hide() {
}
}

// clang-format off

#ifdef __GLIBC__
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#include <features.h>
#ifndef __USE_GNU
#define __MUSL__
#endif
#undef _GNU_SOURCE
#else
#include <features.h>
#ifndef __USE_GNU
#define __MUSL__
#endif
#endif
#endif

// clang-format on

int main(int argc, char **argv) {
#ifdef __MUSL__
char env[] = "LANG=C";
putenv(env);
#endif

if (std::getenv("ABADDON_NO_FC") == nullptr)
Platform::SetupFonts();

Expand Down
48 changes: 20 additions & 28 deletions src/components/channellist/cellrendererchannels.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#include "cellrendererchannels.hpp"

#include <gdkmm/general.h>

#include "misc/cairo.hpp"

#include "abaddon.hpp"

constexpr static int MentionsRightPad = 7;
#ifndef M_PI
constexpr static double M_PI = 3.14159265358979;
#endif
constexpr static double M_PI_H = M_PI / 2.0;
constexpr static double M_PI_3_2 = M_PI * 3.0 / 2.0;

void AddUnreadIndicator(const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &widget, const Gdk::Rectangle &background_area) {
static const auto color_setting = Gdk::RGBA(Abaddon::Get().GetSettings().UnreadIndicatorColor);
Expand Down Expand Up @@ -120,13 +122,11 @@ void CellRendererChannels::get_preferred_width_vfunc(Gtk::Widget &widget, int &m
return get_preferred_width_vfunc_channel(widget, minimum_width, natural_width);
case RenderType::Thread:
return get_preferred_width_vfunc_thread(widget, minimum_width, natural_width);
#ifdef WITH_VOICE
case RenderType::VoiceChannel:
case RenderType::VoiceStage:
return get_preferred_width_vfunc_voice_channel(widget, minimum_width, natural_width);
case RenderType::VoiceParticipant:
return get_preferred_width_vfunc_voice_participant(widget, minimum_width, natural_width);
#endif
case RenderType::DMHeader:
return get_preferred_width_vfunc_dmheader(widget, minimum_width, natural_width);
case RenderType::DM:
Expand All @@ -146,13 +146,11 @@ void CellRendererChannels::get_preferred_width_for_height_vfunc(Gtk::Widget &wid
return get_preferred_width_for_height_vfunc_channel(widget, height, minimum_width, natural_width);
case RenderType::Thread:
return get_preferred_width_for_height_vfunc_thread(widget, height, minimum_width, natural_width);
#ifdef WITH_VOICE
case RenderType::VoiceChannel:
case RenderType::VoiceStage:
return get_preferred_width_for_height_vfunc_voice_channel(widget, height, minimum_width, natural_width);
case RenderType::VoiceParticipant:
return get_preferred_width_for_height_vfunc_voice_participant(widget, height, minimum_width, natural_width);
#endif
case RenderType::DMHeader:
return get_preferred_width_for_height_vfunc_dmheader(widget, height, minimum_width, natural_width);
case RenderType::DM:
Expand All @@ -172,13 +170,11 @@ void CellRendererChannels::get_preferred_height_vfunc(Gtk::Widget &widget, int &
return get_preferred_height_vfunc_channel(widget, minimum_height, natural_height);
case RenderType::Thread:
return get_preferred_height_vfunc_thread(widget, minimum_height, natural_height);
#ifdef WITH_VOICE
case RenderType::VoiceChannel:
case RenderType::VoiceStage:
return get_preferred_height_vfunc_voice_channel(widget, minimum_height, natural_height);
case RenderType::VoiceParticipant:
return get_preferred_height_vfunc_voice_participant(widget, minimum_height, natural_height);
#endif
case RenderType::DMHeader:
return get_preferred_height_vfunc_dmheader(widget, minimum_height, natural_height);
case RenderType::DM:
Expand All @@ -198,13 +194,11 @@ void CellRendererChannels::get_preferred_height_for_width_vfunc(Gtk::Widget &wid
return get_preferred_height_for_width_vfunc_channel(widget, width, minimum_height, natural_height);
case RenderType::Thread:
return get_preferred_height_for_width_vfunc_thread(widget, width, minimum_height, natural_height);
#ifdef WITH_VOICE
case RenderType::VoiceChannel:
case RenderType::VoiceStage:
return get_preferred_height_for_width_vfunc_voice_channel(widget, width, minimum_height, natural_height);
case RenderType::VoiceParticipant:
return get_preferred_height_for_width_vfunc_voice_participant(widget, width, minimum_height, natural_height);
#endif
case RenderType::DMHeader:
return get_preferred_height_for_width_vfunc_dmheader(widget, width, minimum_height, natural_height);
case RenderType::DM:
Expand All @@ -224,14 +218,12 @@ void CellRendererChannels::render_vfunc(const Cairo::RefPtr<Cairo::Context> &cr,
return render_vfunc_channel(cr, widget, background_area, cell_area, flags);
case RenderType::Thread:
return render_vfunc_thread(cr, widget, background_area, cell_area, flags);
#ifdef WITH_VOICE
case RenderType::VoiceChannel:
return render_vfunc_voice_channel(cr, widget, background_area, cell_area, flags, "\U0001F50A");
case RenderType::VoiceStage:
return render_vfunc_voice_channel(cr, widget, background_area, cell_area, flags, "\U0001F4E1");
case RenderType::VoiceParticipant:
return render_vfunc_voice_participant(cr, widget, background_area, cell_area, flags);
#endif
case RenderType::DMHeader:
return render_vfunc_dmheader(cr, widget, background_area, cell_area, flags);
case RenderType::DM:
Expand Down Expand Up @@ -567,8 +559,6 @@ void CellRendererChannels::render_vfunc_thread(const Cairo::RefPtr<Cairo::Contex
}
}

#ifdef WITH_VOICE

// voice channel

void CellRendererChannels::get_preferred_width_vfunc_voice_channel(Gtk::Widget &widget, int &minimum_width, int &natural_width) const {
Expand Down Expand Up @@ -616,6 +606,21 @@ void CellRendererChannels::render_vfunc_voice_channel(const Cairo::RefPtr<Cairo:
layout->show_in_cairo_context(cr);

RenderExpander(24, cr, widget, background_area, property_expanded());

// unread
if (!Abaddon::Get().GetSettings().Unreads) return;

const auto id = m_property_id.get_value();
const auto unread_state = Abaddon::Get().GetDiscordClient().GetUnreadStateForChannel(id);

if (unread_state < 1) return;

auto *paned = dynamic_cast<Gtk::Paned *>(widget.get_ancestor(Gtk::Paned::get_type()));
if (paned != nullptr) {
const auto edge = std::min(paned->get_position(), cell_area.get_width());

unread_render_mentions(cr, widget, unread_state, edge, cell_area);
}
}

// voice participant
Expand Down Expand Up @@ -718,8 +723,6 @@ void CellRendererChannels::render_vfunc_voice_participant(const Cairo::RefPtr<Ca
}
}

#endif

// dm header

void CellRendererChannels::get_preferred_width_vfunc_dmheader(Gtk::Widget &widget, int &minimum_width, int &natural_width) const {
Expand Down Expand Up @@ -838,17 +841,6 @@ void CellRendererChannels::render_vfunc_dm(const Cairo::RefPtr<Cairo::Context> &
}
}

void CellRendererChannels::cairo_path_rounded_rect(const Cairo::RefPtr<Cairo::Context> &cr, double x, double y, double w, double h, double r) {
const double degrees = M_PI / 180.0;

cr->begin_new_sub_path();
cr->arc(x + w - r, y + r, r, -M_PI_H, 0);
cr->arc(x + w - r, y + h - r, r, 0, M_PI_H);
cr->arc(x + r, y + h - r, r, M_PI_H, M_PI);
cr->arc(x + r, y + r, r, M_PI, M_PI_3_2);
cr->close_path();
}

void CellRendererChannels::unread_render_mentions(const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &widget, int mentions, int edge, const Gdk::Rectangle &cell_area) {
Pango::FontDescription font;
font.set_family("sans 14");
Expand All @@ -869,7 +861,7 @@ void CellRendererChannels::unread_render_mentions(const Cairo::RefPtr<Cairo::Con

const auto x = cell_area.get_x() + edge - width - MentionsRightPad;
const auto y = cell_area.get_y() + cell_area.get_height() / 2.0 - height / 2.0 - 1;
cairo_path_rounded_rect(cr, x - 4, y + 2, width + 8, height, 5);
CairoUtil::PathRoundedRect(cr, x - 4, y + 2, width + 8, height, 5);
cr->set_source_rgb(bg.get_red(), bg.get_green(), bg.get_blue());
cr->fill();
cr->set_source_rgb(text.get_red(), text.get_green(), text.get_blue());
Expand Down
7 changes: 0 additions & 7 deletions src/components/channellist/cellrendererchannels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ enum class RenderType : uint8_t {
Category,
TextChannel,
Thread,

// TODO: maybe enable anyways but without ability to join if no voice support
#ifdef WITH_VOICE
VoiceChannel,
VoiceStage, // identical to non-stage except for icon
VoiceParticipant,
#endif

DMHeader,
DM,
Expand Down Expand Up @@ -108,7 +104,6 @@ class CellRendererChannels : public Gtk::CellRenderer {
const Gdk::Rectangle &cell_area,
Gtk::CellRendererState flags);

#ifdef WITH_VOICE
// voice channel
void get_preferred_width_vfunc_voice_channel(Gtk::Widget &widget, int &minimum_width, int &natural_width) const;
void get_preferred_width_for_height_vfunc_voice_channel(Gtk::Widget &widget, int height, int &minimum_width, int &natural_width) const;
Expand All @@ -131,7 +126,6 @@ class CellRendererChannels : public Gtk::CellRenderer {
const Gdk::Rectangle &background_area,
const Gdk::Rectangle &cell_area,
Gtk::CellRendererState flags);
#endif

// dm header
void get_preferred_width_vfunc_dmheader(Gtk::Widget &widget, int &minimum_width, int &natural_width) const;
Expand All @@ -155,7 +149,6 @@ class CellRendererChannels : public Gtk::CellRenderer {
const Gdk::Rectangle &cell_area,
Gtk::CellRendererState flags);

static void cairo_path_rounded_rect(const Cairo::RefPtr<Cairo::Context> &cr, double x, double y, double w, double h, double r);
static void unread_render_mentions(const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &widget, int mentions, int edge, const Gdk::Rectangle &cell_area);

private:
Expand Down
Loading

0 comments on commit e65174f

Please sign in to comment.