mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
update viewport level, make managed
This commit is contained in:
parent
3ce19b8160
commit
b71eec6944
4 changed files with 31 additions and 62 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#include "text.hpp"
|
||||
#include "text/gemini.hpp"
|
||||
#include "text/plain.hpp"
|
||||
// #include "text/plain.hpp" @TODO
|
||||
|
||||
using namespace app::browser::main::tab::page::content;
|
||||
|
||||
|
|
@ -8,31 +8,14 @@ Text::Text(
|
|||
const Type & TYPE,
|
||||
const Glib::ustring & VALUE
|
||||
) {
|
||||
// Init components
|
||||
textGemini = nullptr;
|
||||
textPlain = nullptr;
|
||||
|
||||
// GtkLabel does not support ScrolledWindow features, create GtkViewport
|
||||
auto viewport = new Gtk::Viewport( // @TODO manage
|
||||
NULL, //Gtk::Adjustment::H
|
||||
NULL //Gtk::Adjustment::V
|
||||
); // @TODO manage, optimize
|
||||
|
||||
viewport->set_scroll_to_focus(
|
||||
false
|
||||
);
|
||||
|
||||
// Detect text driver by text type requested
|
||||
switch (TYPE)
|
||||
{
|
||||
case GEMINI:
|
||||
|
||||
textGemini = new text::Gemini(
|
||||
VALUE
|
||||
);
|
||||
|
||||
viewport->set_child(
|
||||
* textGemini
|
||||
set_child(
|
||||
* Gtk::make_managed<text::Gemini>(
|
||||
VALUE
|
||||
)
|
||||
);
|
||||
|
||||
break;
|
||||
|
|
@ -47,16 +30,4 @@ Text::Text(
|
|||
|
||||
throw _("Invalid text type enum"); // @TODO
|
||||
}
|
||||
|
||||
set_child(
|
||||
* viewport
|
||||
);
|
||||
}
|
||||
|
||||
Text::~Text()
|
||||
{
|
||||
delete textGemini;
|
||||
delete textPlain;
|
||||
|
||||
// @TODO
|
||||
}
|
||||
|
|
@ -5,21 +5,11 @@
|
|||
#include <glibmm/i18n.h>
|
||||
#include <glibmm/ustring.h>
|
||||
#include <gtkmm/scrolledwindow.h>
|
||||
#include <gtkmm/viewport.h>
|
||||
|
||||
namespace app::browser::main::tab::page::content
|
||||
{
|
||||
namespace text
|
||||
{
|
||||
class Gemini;
|
||||
class Plain;
|
||||
}
|
||||
|
||||
class Text : public Gtk::ScrolledWindow
|
||||
{
|
||||
text::Gemini * textGemini;
|
||||
text::Plain * textPlain;
|
||||
|
||||
public:
|
||||
|
||||
enum Type
|
||||
|
|
@ -32,8 +22,6 @@ namespace app::browser::main::tab::page::content
|
|||
const Type & TYPE,
|
||||
const Glib::ustring & VALUE
|
||||
);
|
||||
|
||||
~Text();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,25 +4,36 @@ using namespace app::browser::main::tab::page::content::text;
|
|||
|
||||
Gemini::Gemini(
|
||||
const Glib::ustring & GEMTEXT
|
||||
) : Gtk::Viewport( // add scrolled window features support
|
||||
NULL,
|
||||
NULL
|
||||
) {
|
||||
// Init widget
|
||||
set_valign(
|
||||
Gtk::Align::START
|
||||
set_scroll_to_focus(
|
||||
false
|
||||
);
|
||||
|
||||
set_wrap(
|
||||
true
|
||||
auto label = Gtk::make_managed<Gtk::Label>( // @TODO separated file?
|
||||
GEMTEXT
|
||||
);
|
||||
|
||||
set_selectable(
|
||||
true
|
||||
);
|
||||
// Init widget
|
||||
label->set_valign(
|
||||
Gtk::Align::START
|
||||
);
|
||||
|
||||
set_use_markup(
|
||||
true
|
||||
);
|
||||
label->set_wrap(
|
||||
true
|
||||
);
|
||||
|
||||
set_markup(
|
||||
GEMTEXT//markup
|
||||
label->set_selectable(
|
||||
true
|
||||
);
|
||||
|
||||
label->set_use_markup(
|
||||
true
|
||||
);
|
||||
|
||||
set_child(
|
||||
* label
|
||||
);
|
||||
}
|
||||
|
|
@ -4,13 +4,12 @@
|
|||
#include <glibmm/regex.h>
|
||||
#include <glibmm/ustring.h>
|
||||
#include <gtkmm/label.h>
|
||||
#include <gtkmm/viewport.h>
|
||||
|
||||
namespace app::browser::main::tab::page::content::text
|
||||
{
|
||||
class Gemini : public Gtk::Label
|
||||
class Gemini : public Gtk::Viewport
|
||||
{
|
||||
Glib::ustring markup;
|
||||
|
||||
public:
|
||||
|
||||
Gemini(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue