2024-03-25 22:59:25 +08:00
|
|
|
// Aseprite
|
2025-03-04 09:36:11 +08:00
|
|
|
// Copyright (c) 2024-2025 Igara Studio S.A.
|
2024-03-25 22:59:25 +08:00
|
|
|
//
|
|
|
|
// This program is distributed under the terms of
|
|
|
|
// the End-User License Agreement for Aseprite.
|
|
|
|
|
|
|
|
#ifndef APP_UI_FONT_ENTRY_H_INCLUDED
|
|
|
|
#define APP_UI_FONT_ENTRY_H_INCLUDED
|
|
|
|
#pragma once
|
|
|
|
|
2025-03-04 09:36:11 +08:00
|
|
|
#include "app/fonts/font_info.h"
|
2024-04-16 05:52:36 +08:00
|
|
|
#include "app/ui/button_set.h"
|
2024-03-25 22:59:25 +08:00
|
|
|
#include "app/ui/search_entry.h"
|
|
|
|
#include "ui/box.h"
|
|
|
|
#include "ui/button.h"
|
|
|
|
#include "ui/combobox.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace app {
|
|
|
|
class FontPopup;
|
2024-12-17 01:52:19 +08:00
|
|
|
|
2024-03-25 22:59:25 +08:00
|
|
|
class FontEntry : public ui::HBox {
|
2024-12-17 01:52:19 +08:00
|
|
|
public:
|
2024-03-25 22:59:25 +08:00
|
|
|
enum class From {
|
2024-12-17 01:52:19 +08:00
|
|
|
Init,
|
|
|
|
Face,
|
|
|
|
Size,
|
|
|
|
Style,
|
|
|
|
Flags,
|
|
|
|
Popup,
|
|
|
|
};
|
2024-03-25 22:59:25 +08:00
|
|
|
|
|
|
|
FontEntry();
|
|
|
|
~FontEntry();
|
|
|
|
|
|
|
|
FontInfo info() { return m_info; }
|
2024-06-12 09:31:13 +08:00
|
|
|
void setInfo(const FontInfo& info, From from);
|
2024-03-25 22:59:25 +08:00
|
|
|
|
2024-10-23 01:32:33 +08:00
|
|
|
obs::signal<void(const FontInfo&, From)> FontChange;
|
2024-03-25 22:59:25 +08:00
|
|
|
|
2024-12-17 01:52:19 +08:00
|
|
|
private:
|
2024-03-25 22:59:25 +08:00
|
|
|
class FontFace : public SearchEntry {
|
2024-12-17 01:52:19 +08:00
|
|
|
public:
|
2024-03-25 22:59:25 +08:00
|
|
|
FontFace();
|
2024-10-23 01:32:33 +08:00
|
|
|
obs::signal<void(const FontInfo&, From)> FontChange;
|
2024-03-25 22:59:25 +08:00
|
|
|
|
|
|
|
protected:
|
2024-11-22 06:02:39 +08:00
|
|
|
void onInitTheme(ui::InitThemeEvent& ev) override;
|
2024-03-25 22:59:25 +08:00
|
|
|
bool onProcessMessage(ui::Message* msg) override;
|
|
|
|
void onChange() override;
|
2024-10-29 20:48:23 +08:00
|
|
|
os::Surface* onGetCloseIcon() const override;
|
|
|
|
void onCloseIconPressed() override;
|
2024-12-17 01:52:19 +08:00
|
|
|
|
2024-03-25 22:59:25 +08:00
|
|
|
private:
|
2024-10-23 01:32:33 +08:00
|
|
|
FontEntry* fontEntry() const { return static_cast<FontEntry*>(parent()); }
|
2024-12-17 01:52:19 +08:00
|
|
|
|
2024-03-25 22:59:25 +08:00
|
|
|
std::unique_ptr<FontPopup> m_popup;
|
2024-10-23 01:32:33 +08:00
|
|
|
bool m_fromEntryChange = false;
|
2024-12-17 01:52:19 +08:00
|
|
|
};
|
|
|
|
|
2024-03-25 22:59:25 +08:00
|
|
|
class FontSize : public ui::ComboBox {
|
2024-12-17 01:52:19 +08:00
|
|
|
public:
|
2024-03-25 22:59:25 +08:00
|
|
|
FontSize();
|
2025-03-19 00:43:04 +08:00
|
|
|
void updateForFont(const FontInfo& info);
|
2024-03-25 22:59:25 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void onEntryChange() override;
|
|
|
|
};
|
|
|
|
|
2024-04-16 05:52:36 +08:00
|
|
|
class FontStyle : public ButtonSet {
|
2024-12-17 01:52:19 +08:00
|
|
|
public:
|
2024-04-16 05:52:36 +08:00
|
|
|
FontStyle();
|
2024-12-17 01:52:19 +08:00
|
|
|
};
|
|
|
|
|
2024-09-26 03:37:41 +08:00
|
|
|
class FontLigatures : public ButtonSet {
|
2024-12-17 01:52:19 +08:00
|
|
|
public:
|
2024-09-26 03:37:41 +08:00
|
|
|
FontLigatures();
|
2024-12-17 01:52:19 +08:00
|
|
|
};
|
|
|
|
|
2024-03-25 22:59:25 +08:00
|
|
|
FontInfo m_info;
|
|
|
|
FontFace m_face;
|
|
|
|
FontSize m_size;
|
2024-04-16 05:52:36 +08:00
|
|
|
FontStyle m_style;
|
2024-09-26 03:37:41 +08:00
|
|
|
FontLigatures m_ligatures;
|
2024-03-25 22:59:25 +08:00
|
|
|
ui::CheckBox m_antialias;
|
2024-10-23 01:32:33 +08:00
|
|
|
bool m_lockFace = false;
|
2024-12-17 01:52:19 +08:00
|
|
|
};
|
|
|
|
|
2024-03-25 22:59:25 +08:00
|
|
|
} // namespace app
|
|
|
|
|
|
|
|
#endif
|