mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +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.hpp"
|
||||||
#include "text/gemini.hpp"
|
#include "text/gemini.hpp"
|
||||||
#include "text/plain.hpp"
|
// #include "text/plain.hpp" @TODO
|
||||||
|
|
||||||
using namespace app::browser::main::tab::page::content;
|
using namespace app::browser::main::tab::page::content;
|
||||||
|
|
||||||
|
|
@ -8,31 +8,14 @@ Text::Text(
|
||||||
const Type & TYPE,
|
const Type & TYPE,
|
||||||
const Glib::ustring & VALUE
|
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)
|
switch (TYPE)
|
||||||
{
|
{
|
||||||
case GEMINI:
|
case GEMINI:
|
||||||
|
|
||||||
textGemini = new text::Gemini(
|
set_child(
|
||||||
VALUE
|
* Gtk::make_managed<text::Gemini>(
|
||||||
);
|
VALUE
|
||||||
|
)
|
||||||
viewport->set_child(
|
|
||||||
* textGemini
|
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -47,16 +30,4 @@ Text::Text(
|
||||||
|
|
||||||
throw _("Invalid text type enum"); // @TODO
|
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/i18n.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
#include <gtkmm/scrolledwindow.h>
|
#include <gtkmm/scrolledwindow.h>
|
||||||
#include <gtkmm/viewport.h>
|
|
||||||
|
|
||||||
namespace app::browser::main::tab::page::content
|
namespace app::browser::main::tab::page::content
|
||||||
{
|
{
|
||||||
namespace text
|
|
||||||
{
|
|
||||||
class Gemini;
|
|
||||||
class Plain;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Text : public Gtk::ScrolledWindow
|
class Text : public Gtk::ScrolledWindow
|
||||||
{
|
{
|
||||||
text::Gemini * textGemini;
|
|
||||||
text::Plain * textPlain;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum Type
|
enum Type
|
||||||
|
|
@ -32,8 +22,6 @@ namespace app::browser::main::tab::page::content
|
||||||
const Type & TYPE,
|
const Type & TYPE,
|
||||||
const Glib::ustring & VALUE
|
const Glib::ustring & VALUE
|
||||||
);
|
);
|
||||||
|
|
||||||
~Text();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,25 +4,36 @@ using namespace app::browser::main::tab::page::content::text;
|
||||||
|
|
||||||
Gemini::Gemini(
|
Gemini::Gemini(
|
||||||
const Glib::ustring & GEMTEXT
|
const Glib::ustring & GEMTEXT
|
||||||
|
) : Gtk::Viewport( // add scrolled window features support
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
) {
|
) {
|
||||||
// Init widget
|
set_scroll_to_focus(
|
||||||
set_valign(
|
false
|
||||||
Gtk::Align::START
|
|
||||||
);
|
);
|
||||||
|
|
||||||
set_wrap(
|
auto label = Gtk::make_managed<Gtk::Label>( // @TODO separated file?
|
||||||
true
|
GEMTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
set_selectable(
|
// Init widget
|
||||||
true
|
label->set_valign(
|
||||||
);
|
Gtk::Align::START
|
||||||
|
);
|
||||||
|
|
||||||
set_use_markup(
|
label->set_wrap(
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
set_markup(
|
label->set_selectable(
|
||||||
GEMTEXT//markup
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
label->set_use_markup(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
set_child(
|
||||||
|
* label
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -4,13 +4,12 @@
|
||||||
#include <glibmm/regex.h>
|
#include <glibmm/regex.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
#include <gtkmm/label.h>
|
#include <gtkmm/label.h>
|
||||||
|
#include <gtkmm/viewport.h>
|
||||||
|
|
||||||
namespace app::browser::main::tab::page::content::text
|
namespace app::browser::main::tab::page::content::text
|
||||||
{
|
{
|
||||||
class Gemini : public Gtk::Label
|
class Gemini : public Gtk::Viewport
|
||||||
{
|
{
|
||||||
Glib::ustring markup;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Gemini(
|
Gemini(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue