Files
fcitx5-m3ui/src/common.h
T
justmeandClaude Sonnet 5.5 0804634dc1 Add Material 3 candidate window addon for Fcitx5
Fork of the classicui addon (Fcitx5 5.1.23) with a Material 3 look, spring
based animations and a right click action menu for candidates.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-19 21:58:54 +08:00

47 lines
1.3 KiB
C++

/*
* SPDX-FileCopyrightText: 2020-2020 CSSlayer <wengxt@gmail.com>
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
*/
#ifndef _FCITX5_UI_CLASSIC_COMMON_H_
#define _FCITX5_UI_CLASSIC_COMMON_H_
#include <memory>
#include <glib-object.h>
#include <yoga/YGNode.h>
#include "fcitx-utils/log.h"
#include "fcitx-utils/misc.h"
namespace fcitx::m3ui {
template <typename T>
using GObjectUniquePtr = UniqueCPtr<T, g_object_unref>;
template <auto Getter>
float absolute(YGNodeRef node) {
float offset = 0.0F;
while (node) {
offset += Getter(node);
node = YGNodeGetParent(node);
}
return offset;
}
template <auto Getter, typename T, typename Deleter>
float absolute(const std::unique_ptr<T, Deleter> &node) {
return absolute<Getter>(node.get());
}
FCITX_DECLARE_LOG_CATEGORY(m3ui_logcategory);
#define CLASSICUI_DEBUG() \
FCITX_LOGC(::fcitx::m3ui::m3ui_logcategory, Debug)
#define CLASSICUI_ERROR() \
FCITX_LOGC(::fcitx::m3ui::m3ui_logcategory, Error)
#define CLASSICUI_INFO() \
FCITX_LOGC(::fcitx::m3ui::m3ui_logcategory, Info)
} // namespace fcitx::m3ui
#endif // _FCITX5_UI_CLASSIC_COMMON_H_