Skip to content

Commit

Permalink
Move gui/TextEditor to control/tools
Browse files Browse the repository at this point in the history
  • Loading branch information
bhennion committed Mar 20, 2023
1 parent 15361a6 commit 91f3d71
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 20 deletions.
4 changes: 3 additions & 1 deletion src/core/control/Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
#include "control/settings/SettingsEnums.h" // for Button
#include "control/settings/ViewModes.h" // for ViewM..
#include "control/tools/EditSelection.h" // for Edit...
#include "control/tools/TextEditor.h" // for Text...
#include "control/xojfile/LoadHandler.h" // for Load...
#include "control/zoom/ZoomControl.h" // for Zoom...
#include "gui/MainWindow.h" // for Main...
#include "gui/PageView.h" // for XojP...
#include "gui/PdfFloatingToolbox.h" // for PdfF...
#include "gui/SearchBar.h" // for Sear...
#include "gui/TextEditor.h" // for Text...
#include "gui/XournalView.h" // for Xour...
#include "gui/XournalppCursor.h" // for Xour...
#include "gui/dialog/AboutDialog.h" // for Abou...
Expand Down Expand Up @@ -1919,6 +1919,8 @@ void Control::selectDefaultTool() {
}
}

void Control::setFontSelected(const XojFont& font) { this->getWindow()->setFontButtonFont(font); }

void Control::toolChanged() {
ToolType type = toolHandler->getToolType();

Expand Down
4 changes: 4 additions & 0 deletions src/core/control/Control.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class TextEditor;
class XournalScheduler;
class ZoomControl;
class ToolMenuHandler;
class XojFont;

class Control:
public ActionHandler,
public ToolListener,
Expand Down Expand Up @@ -149,6 +151,8 @@ class Control:
void selectTool(ToolType type);
void selectDefaultTool();

void setFontSelected(const XojFont& font);

void updatePageNumbers(size_t page, size_t pdfPage);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#include "control/AudioController.h"
#include "control/Control.h" // for Control
#include "control/settings/Settings.h"
#include "model/Font.h" // for XojFont
#include "model/Text.h" // for Text
#include "model/XojPage.h" // for XojPage
#include "gui/XournalppCursor.h" // for XournalppCursor
#include "model/Font.h" // for XojFont
#include "model/Text.h" // for Text
#include "model/XojPage.h" // for XojPage
#include "undo/DeleteUndoAction.h"
#include "undo/InsertUndoAction.h"
#include "undo/TextBoxUndoAction.h"
Expand All @@ -24,11 +25,7 @@
#include "util/raii/CStringWrapper.h"
#include "view/overlays/TextEditionView.h"

#include "MainWindow.h"
#include "PageView.h" // for XojPageView
#include "TextEditorWidget.h" // for gtk_xoj_int_txt_new
#include "XournalView.h" // for XournalView
#include "XournalppCursor.h" // for XournalppCursor

class UndoAction;

Expand Down Expand Up @@ -1018,7 +1015,7 @@ void TextEditor::finalizeEdition() {
Layer* layer = this->page->getSelectedLayer();
UndoRedoHandler* undo = this->control->getUndoRedoHandler();

this->control->getWindow()->setFontButtonFont(this->control->getSettings()->getFont());
this->control->setFontSelected(this->control->getSettings()->getFont());

if (this->bufferEmpty()) {
// Delete the edited element from layer
Expand Down Expand Up @@ -1091,7 +1088,7 @@ void TextEditor::initializeEditionAt(double x, double y) {
}
this->originalTextElement = nullptr;
} else {
this->control->getWindow()->setFontButtonFont(text->getFont());
this->control->setFontSelected(text->getFont());
this->originalTextElement = text;

// The original code did not use clone here (but did the cloning by hand). Why?
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/core/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ void MainWindow::createToolbar() {
this->control->getScheduler()->unblockRerenderZoom();
}

void MainWindow::setFontButtonFont(XojFont& font) { toolbar->setFontButtonFont(font); }
void MainWindow::setFontButtonFont(const XojFont& font) { toolbar->setFontButtonFont(font); }

auto MainWindow::getFontButtonFont() const -> XojFont { return toolbar->getFontButtonFont(); }

Expand Down
2 changes: 1 addition & 1 deletion src/core/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class MainWindow: public GladeGui, public LayerCtrlListener {

void updatePageNumbers(size_t page, size_t pagecount, size_t pdfpage);

void setFontButtonFont(XojFont& font);
void setFontButtonFont(const XojFont& font);
XojFont getFontButtonFont() const;

void saveSidebarSize();
Expand Down
2 changes: 1 addition & 1 deletion src/core/gui/PageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "control/tools/Selection.h" // for RectSelection
#include "control/tools/SplineHandler.h" // for SplineHandler
#include "control/tools/StrokeHandler.h" // for StrokeHandler
#include "control/tools/TextEditor.h" // for TextEditor, TextE...
#include "control/tools/VerticalToolHandler.h" // for VerticalToolHandler
#include "gui/FloatingToolbox.h" // for FloatingToolbox
#include "gui/MainWindow.h" // for MainWindow
Expand Down Expand Up @@ -82,7 +83,6 @@

#include "PageViewFindObjectHelper.h" // for SelectObject, Pla...
#include "RepaintHandler.h" // for RepaintHandler
#include "TextEditor.h" // for TextEditor, TextE...
#include "XournalView.h" // for XournalView
#include "XournalppCursor.h" // for XournalppCursor
#include "filesystem.h" // for path
Expand Down
4 changes: 2 additions & 2 deletions src/core/gui/toolbarMenubar/FontButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ void FontButton::activated(GtkMenuItem* menuitem, GtkToolButton* toolbutton) {
handler->actionPerformed(ACTION_FONT_BUTTON_CHANGED, GROUP_NOGROUP, nullptr, true);
}

void FontButton::setFontFontButton(GtkWidget* fontButton, XojFont& font) {
void FontButton::setFontFontButton(GtkWidget* fontButton, const XojFont& font) {
GtkFontButton* button = GTK_FONT_BUTTON(fontButton);
auto fontSizeStream = serdes_stream<std::stringstream>();
fontSizeStream << font.getSize();
string name = font.getName() + " " + fontSizeStream.str();
gtk_font_button_set_font_name(button, name.c_str());
}

void FontButton::setFont(XojFont& font) {
void FontButton::setFont(const XojFont& font) {
this->font = font;
if (this->fontButton == nullptr) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/core/gui/toolbarMenubar/FontButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FontButton: public AbstractToolItem {

public:
void activated(GtkMenuItem* menuitem, GtkToolButton* toolbutton) override;
void setFont(XojFont& font);
void setFont(const XojFont& font);
XojFont getFont() const;
std::string getToolDisplayName() const override;
void showFontDialog();
Expand All @@ -45,7 +45,7 @@ class FontButton: public AbstractToolItem {
GtkToolItem* newItem() override;

static GtkWidget* newFontButton();
static void setFontFontButton(GtkWidget* fontButton, XojFont& font);
static void setFontFontButton(GtkWidget* fontButton, const XojFont& font);

GtkWidget* getNewToolIcon() const override;
GdkPixbuf* getNewToolPixbuf() const override;
Expand Down
2 changes: 1 addition & 1 deletion src/core/gui/toolbarMenubar/ToolMenuHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ void ToolMenuHandler::initToolItems() {
this);
}

void ToolMenuHandler::setFontButtonFont(XojFont& font) { this->fontButton->setFont(font); }
void ToolMenuHandler::setFontButtonFont(const XojFont& font) { this->fontButton->setFont(font); }

auto ToolMenuHandler::getFontButtonFont() -> XojFont { return this->fontButton->getFont(); }

Expand Down
2 changes: 1 addition & 1 deletion src/core/gui/toolbarMenubar/ToolMenuHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ToolMenuHandler {
SpinPageAdapter* getPageSpinner();
void setPageInfo(size_t pagecount, size_t pdfpage = 0);

void setFontButtonFont(XojFont& font);
void setFontButtonFont(const XojFont& font);
XojFont getFontButtonFont();

void showFontSelectionDlg();
Expand Down
2 changes: 1 addition & 1 deletion src/core/view/overlays/TextEditionView.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "TextEditionView.h"

#include "gui/TextEditor.h"
#include "control/tools/TextEditor.h"
#include "model/Text.h"
#include "util/Color.h"
#include "util/raii/CairoWrappers.h"
Expand Down

0 comments on commit 91f3d71

Please sign in to comment.