implement header subtitle widget

This commit is contained in:
yggverse 2024-08-27 14:46:13 +03:00
parent fe8845ae1a
commit c22b3a6b30
6 changed files with 86 additions and 9 deletions

View File

@ -9,6 +9,7 @@ SRCS = src/main.cpp\
src/app/browser.cpp\ src/app/browser.cpp\
src/app/browser/header.cpp\ src/app/browser/header.cpp\
src/app/browser/header/main.cpp\ src/app/browser/header/main.cpp\
src/app/browser/header/main/subtitle.cpp\
src/app/browser/header/main/title.cpp\ src/app/browser/header/main/title.cpp\
src/app/browser/header/menu.cpp\ src/app/browser/header/menu.cpp\
src/app/browser/header/tab.cpp\ src/app/browser/header/tab.cpp\

View File

@ -1,6 +1,7 @@
src/app/browser.cpp src/app/browser.cpp
src/app/browser/header.cpp src/app/browser/header.cpp
src/app/browser/header/main.cpp src/app/browser/header/main.cpp
src/app/browser/header/main/subtitle.cpp
src/app/browser/header/main/title.cpp src/app/browser/header/main/title.cpp
src/app/browser/header/menu.cpp src/app/browser/header/menu.cpp
src/app/browser/header/tab.cpp src/app/browser/header/tab.cpp

View File

@ -1,5 +1,6 @@
#include "main.hpp" #include "main.hpp"
#include "main/title.hpp" #include "main/title.hpp"
#include "main/subtitle.hpp"
using namespace app::browser::header; using namespace app::browser::header;
@ -11,26 +12,33 @@ Main::Main()
); );
set_homogeneous( set_homogeneous(
true HOMOGENEOUS
); );
// Init title // Init title
title = new main::Title(); mainTitle = new main::Title();
append( append(
* title * mainTitle
);
mainSubtitle = new main::Subtitle();
append(
* mainSubtitle
); );
} }
Main::~Main() Main::~Main()
{ {
delete title; delete mainTitle;
delete mainSubtitle;
} }
void Main::set_title( void Main::set_title(
const Glib::ustring value const Glib::ustring & TEXT
) { ) {
title->set( mainTitle->set(
value TEXT
); );
} }

View File

@ -9,11 +9,15 @@ namespace app::browser::header
namespace main namespace main
{ {
class Title; class Title;
class Subtitle;
} }
class Main : public Gtk::Box class Main : public Gtk::Box
{ {
main::Title * title; main::Title * mainTitle;
main::Subtitle * mainSubtitle;
const bool HOMOGENEOUS = true;
public: public:
@ -22,7 +26,7 @@ namespace app::browser::header
~Main(); ~Main();
void set_title( void set_title(
const Glib::ustring text const Glib::ustring & TEXT
); );
}; };
} }

View File

@ -0,0 +1,36 @@
#include "subtitle.hpp"
using namespace app::browser::header::main;
Subtitle::Subtitle()
{
add_css_class(
"subtitle"
);
set_single_line_mode(
true
);
set_ellipsize(
Pango::EllipsizeMode::END
);
set_valign(
Gtk::Align::CENTER
);
set_width_chars(
WIDTH_CHARS
);
}
Subtitle::~Subtitle() = default;
void Subtitle::set(
const Glib::ustring & TEXT
) {
set_text(
TEXT
);
}

View File

@ -0,0 +1,27 @@
#ifndef APP_BROWSER_HEADER_MAIN_SUBTITLE_HPP
#define APP_BROWSER_HEADER_MAIN_SUBTITLE_HPP
#include <glibmm/ustring.h>
#include <gtkmm/enums.h>
#include <gtkmm/label.h>
#include <pangomm/layout.h>
namespace app::browser::header::main
{
class Subtitle : public Gtk::Label
{
const int WIDTH_CHARS = 5;
public:
Subtitle();
~Subtitle();
void set(
const Glib::ustring & TEXT
);
};
}
#endif // APP_BROWSER_HEADER_MAIN_SUBTITLE_HPP