id
int64 0
755k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
65
| repo_stars
int64 100
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 9
values | repo_extraction_date
stringclasses 92
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
12,936
|
PdfFloatingToolbox.h
|
xournalpp_xournalpp/src/core/gui/PdfFloatingToolbox.h
|
#pragma once
#include <cstdint> // for uint8_t
#include <memory> // for unique_ptr
#include <gdk/gdk.h> // for GdkRectangle
#include <glib.h> // for gboolean
#include <gtk/gtk.h> // for GtkButton, GtkOverlay
#include "pdf/base/XojPdfPage.h" // for XojPdfPageSelectionStyle
#include "util/raii/GObjectSPtr.h" // for GObjectSPtr
class MainWindow;
class PdfElemSelection;
enum class PdfMarkerStyle : uint8_t {
POS_TEXT_BOTTOM = 0,
POS_TEXT_MIDDLE,
POS_TEXT_TOP,
WIDTH_TEXT_LINE,
WIDTH_TEXT_HEIGHT
};
class PdfFloatingToolbox {
public:
PdfFloatingToolbox(MainWindow* theMainWindow, GtkOverlay* overlay);
PdfFloatingToolbox& operator=(const PdfFloatingToolbox&) = delete;
PdfFloatingToolbox(const PdfFloatingToolbox&) = delete;
PdfFloatingToolbox& operator=(PdfFloatingToolbox&&) = delete;
PdfFloatingToolbox(PdfFloatingToolbox&&) = delete;
~PdfFloatingToolbox();
public:
/// Show the toolbox at the provided coordinates (relative to the application GTK window).
///
/// Must have an active selection.
void show(int x, int y);
/// Hide the floating toolbox widget (keeping the current selection).
void hide();
/// Returns true if the toolbox is currently hidden.
bool isHidden() const;
/// Returns the selection, or nullptr if no PDF element is selected.
PdfElemSelection* getSelection() const;
/// Clears the current selection (without any visual effects).
void clearSelection();
/// Create a new selection (without any visual effects)
const PdfElemSelection* newSelection(double x, double y);
/// Returns true iff a PDF element is selected;
bool hasSelection() const;
/// Cancel the selection, rerender the page, and hide the toolbox.
void userCancelSelection();
/// Track selection style used for unfinalized selections
XojPdfPageSelectionStyle selectionStyle = XojPdfPageSelectionStyle::Linear;
/// Copy Selection to the Clipboard.
void copyTextToClipboard();
private:
void show();
static gboolean getOverlayPosition(GtkOverlay* overlay, GtkWidget* widget, GdkRectangle* allocation,
PdfFloatingToolbox* self);
static void switchSelectTypeCb(GtkButton* button, PdfFloatingToolbox* pft);
static void strikethroughCb(GtkButton* button, PdfFloatingToolbox* pft);
static void underlineCb(GtkButton* button, PdfFloatingToolbox* pft);
static void copyTextCb(GtkButton* button, PdfFloatingToolbox* pft);
static void highlightCb(GtkButton* button, PdfFloatingToolbox* pft);
void createStrokes(PdfMarkerStyle position, PdfMarkerStyle width, int markerOpacity);
private:
GtkWidget* floatingToolbox;
MainWindow* theMainWindow;
/// The overlay that the toolbox should be displayed in.
xoj::util::GObjectSPtr<GtkOverlay> overlay;
std::unique_ptr<PdfElemSelection> pdfElemSelection;
struct {
int x;
int y;
} position;
};
| 2,995
|
C++
|
.h
| 69
| 38.449275
| 104
| 0.734138
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,937
|
GladeSearchpath.h
|
xournalpp_xournalpp/src/core/gui/GladeSearchpath.h
|
/*
* Xournal++
*
* Search directory for icons and Glade files
*
* @author andreas
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <vector> // for vector
#include "filesystem.h" // for path
class GladeSearchpath {
public:
GladeSearchpath();
virtual ~GladeSearchpath();
public:
void addSearchDirectory(fs::path const& directory);
/**
* Searches for a path, return the path, an empty string if not found
*/
fs::path findFile(fs::path const& subdir, fs::path const& file) const;
/**
* @return The first search path
*/
fs::path getFirstSearchPath() const;
private:
/**
* Search directory for icons and Glade files
*/
std::vector<fs::path> directories;
};
| 785
|
C++
|
.h
| 33
| 20.272727
| 74
| 0.676075
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,938
|
PageViewFindObjectHelper.h
|
xournalpp_xournalpp/src/core/gui/PageViewFindObjectHelper.h
|
/*
* Xournal++
*
* Helper classes to find / select objects
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
// No include needed, this is included after PageView.h
#include <limits>
#include <mutex>
#include <optional>
#include "control/AudioController.h"
#include "control/Control.h"
#include "control/layer/LayerController.h"
#include "control/settings/Settings.h"
#include "control/tools/EditSelection.h"
#include "gui/PageView.h"
#include "model/Layer.h"
#include "model/XojPage.h"
#include "util/safe_casts.h"
#include "XournalView.h"
class BaseSelectObject {
public:
BaseSelectObject(XojPageView* view): view(view) {}
virtual ~BaseSelectObject() = default;
public:
bool findAt(double x, double y, bool multiLayer = false, bool clearSelection = true) {
this->x = x;
this->y = y;
Control* ctrl = this->view->getXournal()->getControl();
if (clearSelection) {
ctrl->clearSelection();
}
std::lock_guard lock(*ctrl->getDocument());
if (multiLayer) {
size_t initialLayer = this->view->getPage()->getSelectedLayerId();
auto* layers = this->view->getPage()->getLayers();
for (auto it = layers->rbegin(); it != layers->rend(); it++) {
Layer* layer = *it;
Layer::Index index = layers->size() - as_unsigned(std::distance(layers->rbegin(), it));
ctrl->getLayerController()->switchToLay(index);
if (checkLayer(layer)) {
return true;
}
}
ctrl->getLayerController()->switchToLay(initialLayer);
return false;
} else {
Layer* layer = this->view->getPage()->getSelectedLayer();
return checkLayer(layer);
}
}
protected:
bool checkLayer(Layer* l) {
/* Search for Element whose bounding box center is closest to the place (x,y) where the object is searched for.
* Only those strokes are taken into account that pass the appropriate checkElement test.
*/
bool found = false;
double minDistSq = std::numeric_limits<double>::max();
Element::Index pos = 0;
for (auto&& e: l->getElements()) {
const double eX = e->getX() + e->getElementWidth() / 2.0;
const double eY = e->getY() + e->getElementHeight() / 2.0;
const double dx = eX - this->x;
const double dy = eY - this->y;
const double distSq = dx * dx + dy * dy;
const GdkRectangle matchRect = {gint(x - 10), gint(y - 10), 20, 20};
if (e->intersectsArea(&matchRect) && distSq < minDistSq) {
if (this->checkElement(e.get(), pos)) {
minDistSq = distSq;
found = true;
}
}
pos++;
}
return found;
}
virtual bool checkElement(Element* e, Element::Index pos) = 0;
protected:
XojPageView* view{};
double x{0};
double y{0};
};
class SelectObject: public BaseSelectObject {
public:
SelectObject(XojPageView* view):
BaseSelectObject(view), strokeMatch(nullptr), elementMatch(nullptr), gap(1000000000) {}
~SelectObject() override = default;
bool at(double x, double y, bool multiLayer = false) {
findAt(x, y, multiLayer);
if (strokeMatch) {
elementMatch = strokeMatch;
}
if (elementMatch) {
Control* ctrl = view->getXournal()->getControl();
auto sel = SelectionFactory::createFromElementOnActiveLayer(ctrl, view->getPage(), view, elementMatch,
matchIndex);
view->xournal->setSelection(sel.release());
view->repaintPage();
return true;
}
return false;
}
bool atAggregate(double x, double y) {
EditSelection* previousSelection = view->getXournal()->getSelection();
xoj_assert(previousSelection);
findAt(x, y, false, false);
if (strokeMatch) {
elementMatch = strokeMatch;
}
if (elementMatch) {
auto sel = SelectionFactory::addElementFromActiveLayer(view->getXournal()->getControl(), previousSelection,
elementMatch, matchIndex);
view->getXournal()->setSelection(sel.release());
view->repaintPage();
return true;
}
return false;
}
protected:
bool checkElement(Element* e, Element::Index pos) override {
if (e->getType() == ELEMENT_STROKE) {
Stroke* s = (Stroke*)e;
double tmpGap = 0;
if ((s->intersects(x, y, 5, &tmpGap)) && (gap > tmpGap)) {
gap = tmpGap;
strokeMatch = s;
matchIndex = pos;
return true;
}
} else {
elementMatch = e;
matchIndex = pos;
return true;
}
return false;
}
private:
Stroke* strokeMatch;
Element* elementMatch;
Element::Index matchIndex;
double gap;
};
class PlayObject: public BaseSelectObject {
public:
PlayObject(XojPageView* view): BaseSelectObject(view), playbackStatus() {}
~PlayObject() override = default;
struct Status {
bool success;
fs::path filename;
};
std::optional<Status> playbackStatus;
public:
bool at(double x, double y, bool multiLayer = false) { return findAt(x, y, multiLayer); }
protected:
bool checkElement(Element* e, Element::Index) override {
if (e->getType() != ELEMENT_STROKE && e->getType() != ELEMENT_TEXT) {
return false;
}
AudioElement* s = (AudioElement*)e;
double tmpGap = 0;
if ((s->intersects(x, y, 15, &tmpGap))) {
size_t ts = s->getTimestamp();
if (auto fn = s->getAudioFilename(); !fn.empty()) {
if (!fn.has_parent_path() || fs::weakly_canonical(fn.parent_path()) == "/") {
auto const& path = view->settings->getAudioFolder();
// Assume path exists
fn = path / fn;
}
auto* audioController = view->getXournal()->getControl()->getAudioController();
if (!audioController) {
g_warning("Audio has been disabled");
return false;
}
bool success = audioController->startPlayback(fn, (unsigned int)ts);
playbackStatus = {success, std::move(fn)};
return success;
}
}
return false;
}
};
| 6,847
|
C++
|
.h
| 186
| 27.080645
| 119
| 0.563944
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,939
|
LayoutMapper.h
|
xournalpp_xournalpp/src/core/gui/LayoutMapper.h
|
/*
* Xournal++
*
* A layout manager - map where( row,column) to which page( document index)
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <cstdint> // for uint32_t
#include <optional> // for optional
#include <tuple> // for operator==, tie, tuple
#include <vector> // for vector
class Settings;
struct GridPosition {
size_t col{};
size_t row{};
constexpr friend bool operator==(GridPosition const& lhs, GridPosition const& rhs) noexcept {
return lhs.col == rhs.col && lhs.row == rhs.row;
}
};
struct LayoutSettings {
/// @brief The Layout of the pages
enum Orientation : bool {
Horizontal = false,
Vertical = true,
};
/// Horizontal read direction
enum HorizontalDirection : bool {
LeftToRight = false,
RightToLeft = true,
};
/// Vertical read direction
enum VerticalDirection : bool {
TopToBottom = false,
BottomToTop = true,
};
size_t cols = 0;
size_t rows = 0;
size_t actualPages = 0;
uint32_t offset = 0;
bool showPairedPages = false;
Orientation orientation = Vertical;
HorizontalDirection horizontalDir = LeftToRight;
VerticalDirection verticalDir = TopToBottom;
constexpr friend auto operator==(LayoutSettings const& lhs, LayoutSettings const& rhs) {
auto tier = [](auto&& other) {
return std::tie(other.cols, other.rows, other.actualPages, other.offset, other.showPairedPages,
other.orientation, other.horizontalDir, other.verticalDir);
};
return tier(lhs) == tier(rhs);
}
};
auto layoutSettings(Settings const*) -> LayoutSettings;
/**
* @brief Layout asks this mapper what page ( if any ) should be at a given column,row.
*/
class LayoutMapper {
public:
LayoutMapper() = default;
/**
* configureFromSettings
* Obtain user settings to determine arguments to configure().
*
* @param pages The number of pages in the document
* @param settings The Settings from which users settings are obtained
*/
void configureFromSettings(size_t numPages, Settings* settings);
auto at(size_t) const -> GridPosition;
auto at(GridPosition const&) const -> std::optional<size_t>;
size_t getColumns() const;
size_t getRows() const;
bool isPairedPages() const;
private:
void precalculateMappers();
/**
* Map page location to document index
*
* @param x Row we are interested in
* @param y Column we are interested in
*
* @return Page index to put at coordinates
*/
public:
LayoutSettings data_;
friend void calculate(LayoutSettings& data, size_t numRows, size_t numCols, bool useRows, uint32_t firstPageOffset);
std::vector<GridPosition> pageToRaster;
std::vector<size_t> rasterToPage; // access with x*y_max+y+
};
| 3,000
|
C++
|
.h
| 92
| 27.630435
| 120
| 0.669439
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,940
|
XournalppCursor.h
|
xournalpp_xournalpp/src/core/gui/XournalppCursor.h
|
/*
* Xournal++
*
* Handles the XournalppCursor
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gdk/gdk.h> // for GdkCursor
#include <glib.h> // for guint, gulong
#include "control/tools/CursorSelectionType.h" // for CursorSelectionType
#include "gui/inputdevices/InputEvents.h" // for InputDeviceClass, INP...
class Control;
class XournalppCursor {
public:
XournalppCursor(Control* control);
virtual ~XournalppCursor();
void setCursorBusy(bool busy);
void updateCursor();
void setMouseSelectionType(CursorSelectionType selectionType);
void setMouseDown(bool mouseDown);
void setInvisible(bool invisible);
void setInsidePage(bool insidePage);
void activateDrawDirCursor(bool enable, bool shift = false, bool ctrl = false);
void setInputDeviceClass(InputDeviceClass inputDevice);
void setRotationAngle(double angle);
void setMirror(bool mirror);
private:
void setCursor(guint id);
GdkCursor* getPenCursor();
GdkCursor* getEraserCursor();
GdkCursor* getHighlighterCursor();
GdkCursor* getResizeCursor(double deltaAngle);
GdkCursor* createHighlighterOrPenCursor(double alpha);
GdkCursor* createCustomDrawDirCursor(int size, bool shift, bool ctrl);
private:
InputDeviceClass inputDevice = INPUT_DEVICE_MOUSE;
Control* control = nullptr;
bool busy = false;
bool insidePage = false;
CursorSelectionType selectionType = CURSOR_SELECTION_NONE;
bool mouseDown = false;
bool invisible = false;
// One shot drawDir custom cursor -drawn instead of pen/stylus then cleared.
bool drawDirActive = false;
bool drawDirShift = false;
bool drawDirCtrl = false;
// avoid re-assigning same cursor
guint currentCursor = 0; // enum AVAILABLECURSORS
gulong currentCursorFlavour{}; // for different flavours of a cursor (i.e. drawdir, pen and highlighter custom
// cursors)
// for resizing rotated/mirrored selections
double angle = 0;
bool mirror = false;
};
| 2,139
|
C++
|
.h
| 58
| 32.310345
| 115
| 0.730005
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,941
|
Layout.h
|
xournalpp_xournalpp/src/core/gui/Layout.h
|
/*
* Xournal++
*
* Handles the layout of the pages within a Xournal document
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <mutex> // for mutex
#include <optional> // for optional
#include <vector> // for vector
#include <gtk/gtk.h> // for GtkAdjustment
#include "util/Rectangle.h" // for Rectangle
#include "LayoutMapper.h" // for LayoutMapper
class XojPageView;
class XournalView;
class ScrollHandling;
/**
* @brief The Layout manager for the XournalWidget
*
* This class manages the layout of the XojPageView's contained
* in the XournalWidget
*/
class Layout final {
public:
Layout(XournalView* view, ScrollHandling* scrollHandling);
struct PreCalculated {
std::mutex m;
// The width and height of all our pages
size_t minWidth = 0;
size_t minHeight = 0;
std::vector<double> widthCols;
std::vector<double> heightRows;
bool valid = false;
};
public:
// Todo(Fabian): move to ScrollHandling also it must not depend on Layout
/**
* Increases the adjustments by the given amounts
*/
void scrollRelative(double x, double y);
// Todo(Fabian): move to ScrollHandling also it must not depend on Layout
/**
* Changes the adjustments by absolute amounts (for pinch-to-zoom)
*/
void scrollAbs(double x, double y);
// Todo(Fabian): move to XournalView
/**
* Changes the adjustments in such a way as to make sure that
* the given Rectangle is visible
*
* @remark If the given Rectangle won't fit into the scrolled window
* then only its top left corner will be visible
*/
void ensureRectIsVisible(int x, int y, int width, int height);
/**
* Returns the height of the entire Layout
*/
int getMinimalHeight() const;
/**
* Returns the width of the entire Layout
*/
int getMinimalWidth() const;
// Todo(Fabian): move to XournalView this must not depend on Layout directly
/**
* Returns the Rectangle which is currently visible
*/
xoj::util::Rectangle<double> getVisibleRect();
/**
* recalculate and resize Layout
*/
void recalculate();
/**
* Performs a layout of the XojPageView's managed in this Layout
* Sets out pages in a grid.
* Document pages are assigned to grid positions by the mapper object and may be ordered in a myriad of ways.
* ONLY call this on size allocation
*/
void layoutPages(int width, int height);
// Todo(Fabian): move to View:
/**
* Updates the current XojPageView. The XojPageView is selected based on
* the percentage of the visible area of the XojPageView relative
* to its total area.
*/
void updateVisibility();
/**
* Return the pageview containing co-ordinates.
*/
XojPageView* getPageViewAt(int x, int y);
/**
* Return the page index found ( or std::nullopt if not found) at layout grid row,col
*
*/
std::optional<size_t> getPageIndexAtGridMap(size_t row, size_t col);
/**
* @brief Get the total padding above the page at the given index.
*
* The size of this padding does not scale with pages as the user zooms in and out.
* As such, it is often necessary to get _just_ this padding.
*
* @param pageIndex is the index of the XojPageView as returned by [getIndexAtGridMap]
* @return the sum of the padding between pages above the page with the given index
* and any padding the user added vertically above all pages (i.e. in settings).
*/
int getPaddingAbovePage(size_t pageIndex) const;
/**
* @brief Get the static padding added to the left of the current page.
*
* This does not include padding added to center the page on the screen.
*
* @param pageIndex is the index of the XojPageView, as given by [getIndexAtGridMap]
* @return the sum of the padding between pages left of the page at [pageIndex] and
* any horizontal padding the user decided to add (from settings)
*/
int getPaddingLeftOfPage(size_t pageIndex) const;
protected:
// Todo(Fabian): move to ScrollHandling also it must not depend on Layout
static void horizontalScrollChanged(GtkAdjustment* adjustment, Layout* layout);
static void verticalScrollChanged(GtkAdjustment* adjustment, Layout* layout);
private:
void recalculate_int() const;
void maybeAddLastPage(Layout* layout);
// Todo(Fabian): move to ScrollHandling also it must not depend on Layout
static void checkScroll(GtkAdjustment* adjustment, double& lastScroll);
/**
* Calls the scroll handler to set the layout size by updating the horizontal and vertical GtkAdjustments
*/
// Todo(Fabian): remove this function the true size always depends on the expose event
void setLayoutSize(int width, int height);
private:
XournalView* view = nullptr;
ScrollHandling* scrollHandling = nullptr;
// Todo(Fabian): move to ScrollHandling also it must not depend on Layout
double lastScrollHorizontal = -1;
double lastScrollVertical = -1;
/**
* layoutPages invalidates the precalculation of recalculate
* this bool prevents that layotPages can be called without a previously call to recalculate
* Todo: we may want to remove the additional calculation in layoutPages, since we stored those values in
*/
mutable LayoutMapper mapper;
mutable PreCalculated pc{};
mutable std::vector<unsigned> colXStart;
mutable std::vector<unsigned> rowYStart;
};
| 5,721
|
C++
|
.h
| 150
| 33.193333
| 113
| 0.697292
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,942
|
PagePreviewDecoration.h
|
xournalpp_xournalpp/src/core/gui/PagePreviewDecoration.h
|
/*
* Xournal++
*
* Settings Dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cairo.h> // for cairo_surface_t, cairo_t
#include "sidebar/previews/page/SidebarPreviewPageEntry.h"
class Control;
class PagePreviewDecoration {
public:
static void drawDecoration(cairo_t* cr, SidebarPreviewPageEntry* pageEntry, Control* control);
private:
static void drawPageNumberBelowPreview(cairo_t* cr, SidebarPreviewPageEntry* pageEntry, Control* control);
static void drawPageNumberWithCircleBackground(cairo_t* cr, SidebarPreviewPageEntry* pageEntry, Control* control);
static void drawPageNumberWithSquareBackground(cairo_t* cr, SidebarPreviewPageEntry* pageEntry, Control* control);
public:
/* For the style with the page numbers below the preview the widget height has to be extended by this amount */
static constexpr int MARGIN_BOTTOM = 20;
private:
/* The font sized used for drawing the page number*/
static constexpr double FONT_SIZE = 16.0;
/* Line width for drawing the circle and the square background*/
static constexpr double LINE_WIDTH = 1.0;
/* Indention of the circle from the right border as percentage to the total widget width */
static constexpr double CIRCLE_INDENT_RIGHT = 0.28;
/* Indention of the circle from the bottom border as percentage to the total widget height */
static constexpr double CIRCLE_INDENT_BOTTOM = 0.2;
/* Transparency value for the circle background */
static constexpr double CIRCLE_LABEL_OPACITY = 0.6;
/* Circle radius in pixels */
static constexpr double CIRCLE_RADIUS = 11;
/* Vertical alignment of page number to circle center */
static constexpr double CIRCLE_TEXT_Y = 6;
/* Padding for the text in the circle */
static constexpr double CIRCLE_TEXT_PADDING = 8;
/* Height and minimum width of background square in pixels */
static constexpr double SQUARE_SIZE = 20;
/* Pixel-Distance form widgets right border to previews right border */
static constexpr double SQUARE_INDENT_RIGHT = 12;
/* Pixel-Distance from widgets bottom border to previews bottom border */
static constexpr double SQUARE_INDENT_BOTTOM = 12;
/* Vertical alignment of the page number in the square */
static constexpr double SQUARE_TEXT_Y = 16;
/* Padding for the text in the circle, to be applied on both sides*/
static constexpr double SQUARE_TEXT_PADDING = 4;
static constexpr double PREVIEW_BORDER_LINE_WIDTH = 2.0;
static constexpr double PREVIEW_UPPER_LEFT = 8.5;
static constexpr double PREVIEW_WIDTH_INDENT = 21;
static constexpr double PREVIEW_HEIGHT_INDENT = 21;
static constexpr char FONT_NAME[] = "Sans";
};
| 2,783
|
C++
|
.h
| 57
| 44.842105
| 118
| 0.747881
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,943
|
XournalView.h
|
xournalpp_xournalpp/src/core/gui/XournalView.h
|
/*
* Xournal++
*
* The widget which displays the PDF and the drawings
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <limits> // for numeric_limits
#include <memory> // for unique_ptr
#include <string> // for string
#include <utility> // for pair
#include <vector> // for vector
#include <gdk/gdk.h> // for GdkEventKey, GdkEventExpose
#include <glib.h> // for gboolean
#include <gtk/gtk.h> // for GtkWidget, GtkAllocation
#include "control/zoom/ZoomListener.h" // for ZoomListener
#include "gui/inputdevices/InputEvents.h" // for KeyEvent
#include "model/DocumentChangeType.h" // for DocumentChangeType
#include "model/DocumentListener.h" // for DocumentListener
#include "pdf/base/XojPdfPage.h" // for XojPdfRectangle
#include "util/Util.h" // for npos
class Control;
class XournalppCursor;
class Document;
class EditSelection;
class XojPageView;
class XojPdfRectangle;
class PdfCache;
class RepaintHandler;
class ScrollHandling;
class TextEditor;
class HandRecognition;
namespace xoj::util {
template <class T>
class Rectangle;
} // namespace xoj::util
class XournalView: public DocumentListener, public ZoomListener {
public:
XournalView(GtkWidget* parent, Control* control, ScrollHandling* scrollHandling);
~XournalView() override;
public:
// Recalculate the layout width and height amd layout the pages with the updated layout size
void layoutPages();
void scrollTo(size_t pageNo, XojPdfRectangle rect = {0, 0, -1, -1});
// Relative navigation in current layout:
void pageRelativeXY(int offCol, int offRow);
size_t getCurrentPage() const;
void clearSelection();
void layerChanged(size_t page);
void requestFocus();
void forceUpdatePagenumbers();
XojPageView* getViewFor(size_t pageNr) const;
bool searchTextOnPage(const std::string& text, size_t pageNumber, size_t index, size_t* occurrences,
XojPdfRectangle* matchRect);
bool cut();
bool copy();
bool paste();
void getPasteTarget(double& x, double& y) const;
bool actionDelete();
void endTextAllPages(XojPageView* except = nullptr) const;
void endSplineAllPages() const;
int getDisplayWidth() const;
int getDisplayHeight() const;
bool isPageVisible(size_t page, int* visibleHeight) const;
void ensureRectIsVisible(int x, int y, int width, int height);
void setSelection(EditSelection* selection);
EditSelection* getSelection() const;
void deleteSelection(EditSelection* sel = nullptr);
void repaintSelection(bool evenWithoutSelection = false);
TextEditor* getTextEditor() const;
std::vector<std::unique_ptr<XojPageView>> const& getViewPages() const;
Control* getControl() const;
double getZoom() const;
int getDpiScaleFactor() const;
Document* getDocument() const;
PdfCache* getCache() const;
RepaintHandler* getRepaintHandler() const;
GtkWidget* getWidget() const;
XournalppCursor* getCursor() const;
xoj::util::Rectangle<double>* getVisibleRect(size_t page) const;
xoj::util::Rectangle<double>* getVisibleRect(const XojPageView* redrawable) const;
/**
* Recreate the PDF cache, for example after the underlying PDF file has changed
*/
void recreatePdfCache();
/**
* A pen action was detected now, therefore ignore touch events
* for a short time
*/
void penActionDetected();
/**
* @return Helper class for Touch specific fixes
*/
HandRecognition* getHandRecognition() const;
/**
* @return Scrollbars
*/
ScrollHandling* getScrollHandling() const;
public:
// ZoomListener interface
void zoomChanged() override;
public:
// DocumentListener interface
void pageSelected(size_t page) override;
void pageSizeChanged(size_t page) override;
void pageChanged(size_t page) override;
void pageInserted(size_t page) override;
void pageDeleted(size_t page) override;
void documentChanged(DocumentChangeType type) override;
public:
bool onKeyPressEvent(const KeyEvent& event);
bool onKeyReleaseEvent(const KeyEvent& event);
static void onRealized(GtkWidget* widget, XournalView* view);
void onSettingsChanged();
private:
void fireZoomChanged();
std::pair<size_t, size_t> preloadPageBounds(size_t page, size_t maxPage);
static auto clearMemoryTimer(XournalView* widget) -> gboolean;
void cleanupBufferCache();
private:
/**
* Scrollbars
*/
ScrollHandling* scrollHandling = nullptr;
GtkWidget* widget = nullptr;
std::vector<std::unique_ptr<XojPageView>> viewPages;
Control* control = nullptr;
size_t currentPage = 0;
size_t lastSelectedPage = npos;
std::unique_ptr<PdfCache> cache;
/**
* Handler for rerendering pages / repainting pages
*/
std::unique_ptr<RepaintHandler> repaintHandler;
/**
* Memory cleanup timeout
*/
guint cleanupTimeout = std::numeric_limits<guint>::max();
/**
* Helper class for Touch specific fixes
*/
std::unique_ptr<HandRecognition> handRecognition;
friend class Layout;
};
| 5,309
|
C++
|
.h
| 149
| 31.308725
| 104
| 0.718732
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,944
|
ToolitemDragDrop.h
|
xournalpp_xournalpp/src/core/gui/ToolitemDragDrop.h
|
/*
* Xournal++
*
* Helper for Toolbar Drag & Drop implementation
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory>
#include <gdk-pixbuf/gdk-pixbuf.h> // for GdkPixbuf
#include <gtk/gtk.h> // for GtkWidget
class AbstractToolItem;
struct NamedColor;
enum ToolItemType { TOOL_ITEM_SEPARATOR = 0, TOOL_ITEM_SPACER, TOOL_ITEM_ITEM, TOOL_ITEM_COLOR };
#define ToolItemDragDropData_Identify 0xFA090201
struct ToolItemDragDropData {
unsigned int identify;
ToolItemType type;
int id;
AbstractToolItem* item;
size_t paletteColorIndex;
};
class ToolitemDragDrop {
private:
ToolitemDragDrop();
virtual ~ToolitemDragDrop();
public:
static void attachMetadata(GtkWidget* w, int id, AbstractToolItem* ait);
static void attachMetadata(GtkWidget* w, int id, ToolItemType type);
static void attachMetadataColor(GtkWidget* w, int id, size_t paletteColorIndex, AbstractToolItem* item);
public:
static std::unique_ptr<ToolItemDragDropData> ToolItemDragDropData_new(AbstractToolItem* item);
static bool checkToolItemDragDropData(ToolItemDragDropData const* d);
static ToolItemDragDropData* metadataGetMetadata(GtkWidget* w);
/**
* Returns: (transfer floating)
*/
static GtkWidget* getIcon(ToolItemDragDropData* data);
public:
static void removeFromToolbarForMove(GtkWidget* widget);
};
| 1,460
|
C++
|
.h
| 44
| 30
| 108
| 0.758375
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,945
|
RepaintHandler.h
|
xournalpp_xournalpp/src/core/gui/RepaintHandler.h
|
/*
* Xournal++
*
* Class for render and repaint pages
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
class XojPageView;
class XournalView;
class RepaintHandler {
public:
RepaintHandler(XournalView* xournal);
virtual ~RepaintHandler();
public:
/**
* Repaint a page
*/
void repaintPage(const XojPageView* view);
/**
* Repaint a page area, coordinates are in view coordinates
*/
void repaintPageArea(const XojPageView* view, int x1, int y1, int x2, int y2);
/**
* Repaints the page border (at least)
*/
void repaintPageBorder(const XojPageView* view);
private:
XournalView* xournal;
};
| 734
|
C++
|
.h
| 33
| 18.757576
| 82
| 0.691643
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,946
|
CreatePreviewImage.h
|
xournalpp_xournalpp/src/core/gui/CreatePreviewImage.h
|
/*
* Xournal++
*
* Helper function
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gtk/gtk.h> // for GtkWidget
class PageType;
namespace xoj::helper {
constexpr auto PREVIEW_WIDTH = 100;
constexpr auto PREVIEW_HEIGHT = 141;
/**
* @brief Create a GtkImage containing a miniature of the given (standard) page type
* The returned widget is a floating ref.
*/
auto createPreviewImage(const PageType& pt) -> GtkWidget*;
}; // namespace xoj::helper
| 544
|
C++
|
.h
| 22
| 23
| 84
| 0.727799
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,947
|
SearchBar.h
|
xournalpp_xournalpp/src/core/gui/SearchBar.h
|
/*
* Xournal++
*
* Handles the searchbar and search events
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gtk/gtk.h> // for GtkButton, GtkEntry
#include <gtk/gtkcssprovider.h> // for GtkCssProvider
class Control;
class XojPdfRectangle;
class SearchBar {
public:
SearchBar(Control* control);
virtual ~SearchBar();
void showSearchBar(bool show);
private:
static void buttonCloseSearchClicked(GtkButton* button, SearchBar* searchBar);
static void searchTextChangedCallback(GtkEntry* entry, SearchBar* searchBar);
static void buttonNextSearchClicked(GtkButton* button, SearchBar* searchBar);
static void buttonPreviousSearchClicked(GtkButton* button, SearchBar* searchBar);
/**
* @brief Searches the entire document until a match is found, starting from `page = next(currentPage)` and
* iterating through the pages via page = next(page). The search stops after the first page with at least one match.
* All the match on that page are stored in XojPageView::search of the corresponding page. The current page is not
* search!
* @param next The parameter `next` must be convertible to size_t(size_t) and satisfy the following assertions
* * Iterating from page = next(currentPage) by page = next(page) must reach page == currentPage at
* some point.
* * If page is a valid page number, then so is next(page).
*/
template <class Fun>
void search(Fun next);
/**
* @brief Named specialization of search(), where next(page) = (page + 1) % pageCount
*/
void searchNext();
/**
* @brief Named specialization of search(), where next(page) = (page + pageCount - 1) % pageCount
*/
void searchPrevious();
void search(const char* text);
bool searchTextonCurrentPage(const char* text, size_t index, size_t* occurrences, XojPdfRectangle* matchRect);
private:
Control* control;
GtkCssProvider* cssTextFild;
size_t page = 0;
size_t indexInPage = 0;
size_t occurrences = 0;
};
| 2,141
|
C++
|
.h
| 54
| 35.518519
| 120
| 0.702794
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,948
|
SpinPageAdapter.h
|
xournalpp_xournalpp/src/core/gui/widgets/SpinPageAdapter.h
|
/*
* Xournal++
*
* Handle the Page Spin Widget
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <list> // for list
#include <glib.h> // for guint, gulong
#include <gtk/gtk.h> // for GtkWidget, GtkSpinButton
#include "util/raii/GObjectSPtr.h" // for WidgetSPtr
class SpinPageListener;
class SpinPageAdapter final {
public:
SpinPageAdapter() = default;
~SpinPageAdapter() = default;
public:
/**
* Assumes ownership of widget
*/
void setWidget(GtkWidget* widget);
size_t getPage() const;
void setPage(size_t page);
void setMinMaxPage(size_t min, size_t max);
void addListener(SpinPageListener* listener);
void removeListener(SpinPageListener* listener);
private:
static bool pageNrSpinChangedTimerCallback(SpinPageAdapter* adapter);
static void pageNrSpinChangedCallback(GtkSpinButton* spinbutton, SpinPageAdapter* adapter);
void firePageChanged();
private:
xoj::util::WidgetSPtr widget;
gulong pageNrSpinChangedHandlerId = 0;
size_t page = 0;
guint lastTimeoutId = 0;
SpinPageListener* listener;
size_t min = 0;
size_t max = 0;
};
class SpinPageListener {
public:
virtual void pageChanged(size_t page) = 0;
virtual ~SpinPageListener();
};
| 1,375
|
C++
|
.h
| 49
| 24.653061
| 95
| 0.720824
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,949
|
ZoomCallib.h
|
xournalpp_xournalpp/src/core/gui/widgets/ZoomCallib.h
|
/*
* Xournal++
*
* Control to callibrate the zoom to fit the display DPI
*
* @author Xournal Team
* http://xournal.sf.net
*
* @license GPL
*/
#pragma once
#include <glib-object.h> // for G_TYPE_CHECK_INSTANCE_TYPE, G_TYPE_CHECK_IN...
#include <glib.h> // for gint, G_BEGIN_DECLS, G_END_DECLS
#include <gtk/gtk.h> // for GtkWidget, GtkWidgetClass
struct _ZoomCallib;
struct _ZoomCallibClass;
G_BEGIN_DECLS
#define ZOOM_CALLIB(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, zoomcallib_get_type(), ZoomCallib)
#define ZOOM_CALLIB_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, zoomcallib_get_type(), ZoomCallibClass)
#define IS_ZOOM_CALLIB(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, zoomcallib_get_type())
typedef struct _ZoomCallib ZoomCallib;
typedef struct _ZoomCallibClass ZoomCallibClass;
struct _ZoomCallib {
GtkWidget widget;
gint val;
};
struct _ZoomCallibClass {
GtkWidgetClass parent_class;
};
GType zoomcallib_get_type(void);
void zoomcallib_set_val(ZoomCallib* callib, gint val);
GtkWidget* zoomcallib_new();
G_END_DECLS
| 1,053
|
C++
|
.h
| 33
| 29.969697
| 100
| 0.752475
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,950
|
XournalWidget.h
|
xournalpp_xournalpp/src/core/gui/widgets/XournalWidget.h
|
/*
* Xournal++
*
* Xournal widget which is the "View" widget
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory> // for unique_ptr
#include <glib-object.h> // for G_TYPE_CHECK_INSTANCE_CAST, G_TYPE_C...
#include <glib.h> // for G_BEGIN_DECLS, G_END_DECLS
#include <gtk/gtk.h> // for GtkWidget, GtkWidgetClass
namespace xoj::util {
template <class T>
class Rectangle;
} // namespace xoj::util
struct _GtkXournal;
struct _GtkXournalClass;
G_BEGIN_DECLS
#define GTK_XOURNAL(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, gtk_xournal_get_type(), GtkXournal)
#define GTK_XOURNAL_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, gtk_xournal_get_type(), GtkXournalClass)
#define GTK_IS_XOURNAL(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, gtk_xournal_get_type())
class EditSelection;
class Layout;
class XojPageView;
class ScrollHandling;
class XournalView;
class InputContext;
typedef struct _GtkXournal GtkXournal;
typedef struct _GtkXournalClass GtkXournalClass;
struct _GtkXournal {
GtkWidget widget;
/**
* The view class
*/
XournalView* view;
/**
* Scrollbars
*/
ScrollHandling* scrollHandling;
Layout* layout;
/**
* Selected content, if any
*/
EditSelection* selection;
/**
* Input handling
*/
InputContext* input = nullptr;
};
struct _GtkXournalClass {
GtkWidgetClass parent_class;
};
GType gtk_xournal_get_type();
GtkWidget* gtk_xournal_new(XournalView* view, InputContext* inputContext);
Layout* gtk_xournal_get_layout(GtkWidget* widget);
void gtk_xournal_scroll_relative(GtkWidget* widget, double x, double y);
void gtk_xournal_repaint_area(GtkWidget* widget, int x1, int y1, int x2, int y2);
xoj::util::Rectangle<double>* gtk_xournal_get_visible_area(GtkWidget* widget, const XojPageView* p);
G_END_DECLS
| 1,899
|
C++
|
.h
| 63
| 27.269841
| 101
| 0.73164
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,951
|
PageTypeSelectionMenuBase.h
|
xournalpp_xournalpp/src/core/gui/menus/PageTypeSelectionMenuBase.h
|
/*
* Xournal++
*
* Handles page selection menus -- Base
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <limits>
#include <optional>
#include <string_view>
#include <gio/gio.h> // for GSimpleAction
#include <glib.h>
#include "model/PageType.h" // for PageType
#include "util/raii/GObjectSPtr.h"
class PageTypeHandler;
class PageTypeInfo;
class Settings;
class PageTypeSelectionMenuBase {
protected:
PageTypeSelectionMenuBase(PageTypeHandler* typesHandler, const Settings* settings,
const std::string_view& actionName);
~PageTypeSelectionMenuBase() = default;
public:
/**
* @brief Set the selected page type in the menu. Does not trigger any signals but updates the radio buttons.
*/
void setSelected(const std::optional<PageType>& selected);
private:
/**
* @brief callback subfunction
*/
virtual void entrySelected(const PageTypeInfo* info) = 0;
static void changeSelectionCallback(GSimpleAction* ga, GVariant* parameter,
PageTypeSelectionMenuBase* pageTypeMenu);
protected:
std::optional<PageType> selectedPT;
xoj::util::GObjectSPtr<GSimpleAction> typeSelectionAction;
PageTypeHandler* types;
bool changeCurrentPageUponCallback = false;
public:
static constexpr size_t COPY_CURRENT_PLACEHOLDER = std::numeric_limits<size_t>::max();
};
| 1,476
|
C++
|
.h
| 46
| 27.586957
| 113
| 0.720339
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,952
|
StaticAssertActionNamespace.h
|
xournalpp_xournalpp/src/core/gui/menus/StaticAssertActionNamespace.h
|
/*
* Xournal++
*
* A helper class to statically assert the action namespace is correct
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string_view>
#include "gtk/gtk.h"
class MainWindow;
/**
* @brief Returns true if the provided GAction namespace matches the provided type
* (i.e. "win" for GtkApplicationWindow and "app" for GtkApplication)
*/
template <class action_map_type>
constexpr bool is_action_namespace_match(const char* nspace) {
return false;
}
template <>
constexpr bool is_action_namespace_match<GtkWindow*>(const char* nspace) {
return std::string_view(nspace) == std::string_view("win.");
}
template <>
constexpr bool is_action_namespace_match<GtkApplicationWindow*>(const char* nspace) {
return std::string_view(nspace) == std::string_view("win.");
}
template <>
constexpr bool is_action_namespace_match<MainWindow*>(const char* nspace) {
return std::string_view(nspace) == std::string_view("win.");
}
template <>
constexpr bool is_action_namespace_match<GtkApplication*>(const char* nspace) {
return std::string_view(nspace) == std::string_view("app.");
}
template <>
constexpr bool is_action_namespace_match<GApplication*>(const char* nspace) {
return std::string_view(nspace) == std::string_view("app");
}
| 1,350
|
C++
|
.h
| 42
| 30.047619
| 85
| 0.736518
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,953
|
PageTypeSelectionPopoverGridOnly.h
|
xournalpp_xournalpp/src/core/gui/menus/popoverMenus/PageTypeSelectionPopoverGridOnly.h
|
/*
* Xournal++
*
* Handles page selection menu
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory>
#include <vector> // for vector
#include <gtk/gtk.h> // for GtkWidget
#include "gui/menus/PageTypeSelectionMenuBase.h"
#include "util/raii/GObjectSPtr.h"
namespace xoj::popup {
class PageTemplateDialog;
}
class PageTypeHandler;
class PageTypeInfo;
class Settings;
class PageTypeSelectionPopoverGridOnly final: public PageTypeSelectionMenuBase {
public:
PageTypeSelectionPopoverGridOnly(PageTypeHandler* typesHandler, const Settings* settings,
xoj::popup::PageTemplateDialog* parent);
~PageTypeSelectionPopoverGridOnly() = default;
public:
inline GtkWidget* getPopover() { return popover.get(); }
private:
xoj::util::WidgetSPtr createPopover();
void entrySelected(const PageTypeInfo* info) override;
private:
xoj::popup::PageTemplateDialog* parent;
xoj::util::WidgetSPtr popover;
};
| 1,048
|
C++
|
.h
| 36
| 25.805556
| 93
| 0.751745
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,954
|
PageTypeSelectionPopover.h
|
xournalpp_xournalpp/src/core/gui/menus/popoverMenus/PageTypeSelectionPopover.h
|
/*
* Xournal++
*
* Handles page selection menu
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory>
#include <vector> // for vector
#include <gtk/gtk.h> // for GtkWidget
#include "gui/PopoverFactory.h"
#include "gui/menus/PageTypeSelectionMenuBase.h"
#include "util/raii/GObjectSPtr.h"
class PageBackgroundChangeController;
class PageTypeHandler;
class PageTypeInfo;
class Settings;
class PageTypeSelectionPopover final: public PageTypeSelectionMenuBase, public PopoverFactory {
public:
PageTypeSelectionPopover(PageTypeHandler* typesHandler, PageBackgroundChangeController* controller,
const Settings* settings, GtkApplicationWindow* win);
~PageTypeSelectionPopover() override = default;
public:
GtkWidget* createPopover() const override;
private:
void entrySelected(const PageTypeInfo* info) override;
private:
PageBackgroundChangeController* controller;
};
| 1,010
|
C++
|
.h
| 33
| 27.575758
| 103
| 0.782025
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,955
|
RecentDocumentsSubmenu.h
|
xournalpp_xournalpp/src/core/gui/menus/menubar/RecentDocumentsSubmenu.h
|
/*
* Xournal++
*
* The recent opened files
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gio/gio.h> // for GMenu
#include <glib.h> // for gulong
#include <gtk/gtk.h>
#include "control/RecentManager.h"
#include "util/raii/GObjectSPtr.h"
#include "AbstractSubmenu.h"
class Control;
class Menubar;
/**
* @brief Handles the GtkMenu displaying the recent files
*/
class RecentDocumentsSubmenu final: public Submenu {
public:
RecentDocumentsSubmenu(Control* control, GtkApplicationWindow* win);
~RecentDocumentsSubmenu();
/**
* Updates the menu of recent files
*/
void updateMenu();
void setDisabled(bool disabled) override;
void addToMenubar(Menubar& menubar) override;
private:
static void openFileCallback(GSimpleAction* ga, GVariant* parameter, RecentDocumentsSubmenu* self);
static void removeFileCallback(GSimpleAction* ga, GVariant* parameter, RecentDocumentsSubmenu* self);
gulong recentHandlerId{};
TinyVector<fs::path, RecentManager::MAX_RECENT> xoppFiles;
TinyVector<fs::path, RecentManager::MAX_RECENT> pdfFiles;
Control* control;
/**
* Keep one menu for each section!
* Using a single menu with two sections does not work: when adding this to the suitable submenu in the main
* menubar, it would give
* <submenu>
* <section>
* <section>
* ...
* </section>
* <section>
* ...
* </section>
* </section>
* </submenu>
* and the section separator does not appear in this case...
*/
xoj::util::GObjectSPtr<GMenu> recentFilesSubmenu;
xoj::util::GObjectSPtr<GMenu> menuXoppFiles;
xoj::util::GObjectSPtr<GMenu> menuPdfFiles;
xoj::util::GObjectSPtr<GSimpleAction> openFileAction;
xoj::util::GObjectSPtr<GSimpleAction> clearListAction;
xoj::util::GObjectSPtr<GSimpleAction> removeFileAction;
};
| 1,975
|
C++
|
.h
| 62
| 27.887097
| 112
| 0.70647
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,956
|
PageTypeSubmenu.h
|
xournalpp_xournalpp/src/core/gui/menus/menubar/PageTypeSubmenu.h
|
/*
* Xournal++
*
* Handles page selection menu
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gio/gio.h> // for GMenu, GSimpleAction
#include "gui/menus/PageTypeSelectionMenuBase.h"
#include "util/raii/GObjectSPtr.h"
#include "AbstractSubmenu.h"
class PageTypeHandler;
class Settings;
class PageBackgroundChangeController;
class PageTypeSubmenu final: public Submenu, public PageTypeSelectionMenuBase {
public:
PageTypeSubmenu(PageTypeHandler* typesHandler, PageBackgroundChangeController* controller, const Settings* settings,
GtkApplicationWindow* win);
~PageTypeSubmenu() = default;
void setDisabled(bool disabled) override;
void addToMenubar(Menubar& menubar) override;
private:
void entrySelected(const PageTypeInfo*) override;
PageBackgroundChangeController* controller;
xoj::util::GObjectSPtr<GMenu> generatedPageTypesSection;
xoj::util::GObjectSPtr<GMenu> specialPageTypesSection;
xoj::util::GObjectSPtr<GMenu> applyToAllPagesSection;
xoj::util::GObjectSPtr<GSimpleAction> applyToAllPagesAction;
};
| 1,166
|
C++
|
.h
| 33
| 31.939394
| 120
| 0.785396
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,957
|
Menubar.h
|
xournalpp_xournalpp/src/core/gui/menus/menubar/Menubar.h
|
/*
* Xournal++
*
* The Main menu bar
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory>
#include <string_view>
#include <gio/gio.h> // for GMenu, GMenuItem...
#include "util/raii/GObjectSPtr.h"
#include "config-features.h" // for ENABLE_PLUGINS
class GladeSearchpath;
class MainWindow;
class RecentDocumentsSubmenu;
class ToolbarSelectionSubmenu;
class PageTypeSubmenu;
class PluginsSubmenu;
class Menubar {
public:
Menubar();
~Menubar() noexcept;
void populate(const GladeSearchpath* gladeSearchPath, MainWindow* win);
public:
inline GMenuModel* getModel() const { return menu; }
inline ToolbarSelectionSubmenu& getToolbarSelectionSubmenu() const { return *toolbarSelectionSubmenu; }
inline PageTypeSubmenu& getPageTypeSubmenu() const { return *pageTypeSubmenu; }
void setDisabled(bool disabled);
void setUndoDescription(const std::string& description);
void setRedoDescription(const std::string& description);
template <typename gobj, typename Fun>
gobj* get(const std::string_view& name, Fun&& converter) const {
gobj* w = converter(gtk_builder_get_object(const_cast<GtkBuilder*>(builder.get()), name.data()));
if (w == nullptr) {
g_warning("Menubar::get: Could not find menu object: \"%s\"", name.data());
}
return w;
}
private:
xoj::util::GObjectSPtr<GtkBuilder> builder;
GMenuModel* menu; // owned by `builder`
// Dynamically created submenus -- also add to forEachSubmenu() below
std::unique_ptr<RecentDocumentsSubmenu> recentDocumentsSubmenu;
std::unique_ptr<ToolbarSelectionSubmenu> toolbarSelectionSubmenu;
std::unique_ptr<PageTypeSubmenu> pageTypeSubmenu;
#ifdef ENABLE_PLUGINS
std::unique_ptr<PluginsSubmenu> pluginsSubmenu;
#endif
template <class Fun>
void forEachSubmenu(Fun&& fun) {
fun(*recentDocumentsSubmenu);
fun(*toolbarSelectionSubmenu);
fun(*pageTypeSubmenu);
#ifdef ENABLE_PLUGINS
fun(*pluginsSubmenu);
#endif
}
GMenu* undoRedoSection; // owned by `builder`
};
| 2,165
|
C++
|
.h
| 63
| 30.285714
| 107
| 0.727098
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,958
|
AbstractSubmenu.h
|
xournalpp_xournalpp/src/core/gui/menus/menubar/AbstractSubmenu.h
|
/*
* Xournal++
*
* A submenu
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include "util/raii/GObjectSPtr.h"
class Menubar;
class Submenu {
protected:
Submenu() = default;
~Submenu() noexcept = default;
public:
virtual void setDisabled(bool disabled) = 0;
virtual void addToMenubar(Menubar& menubar) = 0;
};
| 409
|
C++
|
.h
| 21
| 17.047619
| 52
| 0.707572
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,959
|
ToolbarSelectionSubmenu.h
|
xournalpp_xournalpp/src/core/gui/menus/menubar/ToolbarSelectionSubmenu.h
|
/*
* Xournal++
*
* Submenu for toolbar selection
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include "util/raii/GObjectSPtr.h"
#include "AbstractSubmenu.h"
class Settings;
class ToolMenuHandler;
class ToolbarData;
class MainWindow;
class ToolbarSelectionSubmenu final: public Submenu {
public:
ToolbarSelectionSubmenu(MainWindow* win, Settings* settings, ToolMenuHandler* toolbar);
~ToolbarSelectionSubmenu();
public:
void update(ToolMenuHandler* toolbarHandler, const ToolbarData* selectedToolbar);
void setDisabled(bool disabled) override;
void addToMenubar(Menubar& menubar) override;
private:
xoj::util::GObjectSPtr<GMenu> stockConfigurationsSection;
xoj::util::GObjectSPtr<GMenu> customConfigurationsSection;
xoj::util::GObjectSPtr<GSimpleAction> gAction;
};
| 886
|
C++
|
.h
| 30
| 26.9
| 91
| 0.790094
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,960
|
PluginsSubmenu.h
|
xournalpp_xournalpp/src/core/gui/menus/menubar/PluginsSubmenu.h
|
/*
* Xournal++
*
* Submenu listing plugins
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <vector>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include "AbstractSubmenu.h"
class PluginController;
class PluginsSubmenu final: public Submenu {
public:
PluginsSubmenu(PluginController* pluginController, GtkApplicationWindow* win);
~PluginsSubmenu() noexcept = default;
public:
void setDisabled(bool disabled) override;
void addToMenubar(Menubar& menubar) override;
private:
xoj::util::GObjectSPtr<GMenu> submenu;
};
| 626
|
C++
|
.h
| 26
| 21.653846
| 82
| 0.761824
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,961
|
AbstractSidebarPage.h
|
xournalpp_xournalpp/src/core/gui/sidebar/AbstractSidebarPage.h
|
/*
* Xournal++
*
* Abstract Sidebar Page
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <string> // for string
#include <gtk/gtk.h> // for GtkToolItem
#include "model/DocumentListener.h" // for DocumentListener
class Control;
class AbstractSidebarPage: public DocumentListener {
public:
AbstractSidebarPage(Control* control);
~AbstractSidebarPage() override;
public:
virtual void enableSidebar() = 0;
virtual void disableSidebar() = 0;
virtual void layout() = 0;
/**
* The name of this sidebar page
*/
virtual std::string getName() = 0;
/**
* The name of this sidebar page
*/
virtual std::string getIconName() = 0;
/**
* If this sidebar page has data for the current document, e.g. if there are bookmarks or not
*/
virtual bool hasData() = 0;
/**
* Gets the Widget to display
*/
virtual GtkWidget* getWidget() = 0;
/**
* Temporary disable Sidebar (e.g. while saving)
*/
virtual void setTmpDisabled(bool disabled);
/**
* A page was selected, supply additional to the Document Page the PDF Page
*/
virtual void selectPageNr(size_t page, size_t pdfPage);
/**
* Returns the Application controller
*/
Control* getControl();
private:
protected:
/**
* The Control of the Application
*/
Control* control = nullptr;
public:
/**
* The Sidebar button
*/
GtkWidget* tabButton = nullptr;
};
| 1,620
|
C++
|
.h
| 64
| 21.0625
| 97
| 0.648473
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,962
|
Sidebar.h
|
xournalpp_xournalpp/src/core/gui/sidebar/Sidebar.h
|
/*
* Xournal++
*
* The Sidebar
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <memory> // for unique_ptr
#include <vector> // for vector
#include <gtk/gtk.h> // for GtkWidget, Gtk...
#include "model/DocumentChangeType.h" // for DocumentChange...
#include "model/DocumentListener.h" // for DocumentListener
class AbstractSidebarPage;
class Control;
class GladeGui;
class SidebarTabButton;
class Sidebar: public DocumentListener {
public:
Sidebar(GladeGui* gui, Control* control);
~Sidebar() override;
private:
void initTabs(GtkWidget* sidebarContents);
void addTab(std::unique_ptr<AbstractSidebarPage> tab);
public:
/**
* Layout sidebar
*/
void layout();
/**
* A page was selected, so also select this page in the sidebar
*/
void selectPageNr(size_t page, size_t pdfPage);
Control* getControl();
/**
* Temporary disable Sidebar (e.g. while saving)
*/
void setTmpDisabled(bool disabled);
/**
* Saves the current size to the settings
*/
void saveSize();
/**
* Get how many pages are contained in this sidebar
*
* Todo: it makes no sense to expose this, as the caller has no way of knowing what those pages correspond to
*/
[[deprecated]] size_t getNumberOfTabs() const;
/**
* Get index of the currently selected page
*
* Todo: it makes no sense to expose this, as the caller has no way of knowing what this number corresponds to
*/
[[deprecated]] size_t getSelectedTab() const;
/**
* Sets the current selected tab
*
* Todo: this should be private
*/
void setSelectedTab(size_t tab);
public:
// DocumentListener interface
void documentChanged(DocumentChangeType type) override;
private:
/**
* Page selected
*/
static void buttonClicked(GtkButton* button, SidebarTabButton* buttonData);
/**
* Show/hide tabs based on whether they have content. Select first active tab (page).
*/
void updateVisibleTabs();
private:
Control* control = nullptr;
/**
* The sidebar pages
*/
std::vector<std::unique_ptr<AbstractSidebarPage>> tabs;
/**
* The bar with the tab selection
*/
GtkBox* tbSelectTab = nullptr;
/**
* The close button of the sidebar
*/
GtkWidget* buttonCloseSidebar = nullptr;
/**
* The current visible page in the sidebar
*/
GtkWidget* visibleTab = nullptr;
/**
* Current active page
*/
size_t currentTabIdx{0};
/**
* The sidebarContents widget
*/
GtkWidget* sidebarContents = nullptr;
};
class SidebarTabButton {
public:
SidebarTabButton(Sidebar* sidebar, size_t index, AbstractSidebarPage* page);
public:
Sidebar* sidebar = nullptr;
size_t index = 0;
AbstractSidebarPage* page = nullptr;
};
| 3,028
|
C++
|
.h
| 111
| 22.810811
| 114
| 0.663205
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,963
|
SidebarPreviewPages.h
|
xournalpp_xournalpp/src/core/gui/sidebar/previews/page/SidebarPreviewPages.h
|
/*
* Xournal++
*
* Previews of the pages in the document
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <memory> // for unique_ptr
#include <string> // for string
#include <tuple> // for tuple
#include <vector> // for vector
#include <glib.h> // for gulong
#include <gtk/gtk.h> // for GtkWidget
#include "gui/IconNameHelper.h" // for IconNameHe...
#include "gui/sidebar/previews/base/SidebarPreviewBase.h" // for SidebarPre...
#include "util/raii/GObjectSPtr.h"
class Control;
class GladeGui;
class SidebarPreviewPages: public SidebarPreviewBase {
public:
SidebarPreviewPages(Control* control);
~SidebarPreviewPages() override;
public:
void enableSidebar() override;
/**
* @overwrite
*/
std::string getName() override;
/**
* @overwrite
*/
std::string getIconName() override;
/**
* Update the preview images
* @overwrite
*/
void updatePreviews() override;
public:
// DocumentListener interface (only the part which is not handled by SidebarPreviewBase)
void pageSizeChanged(size_t page) override;
void pageChanged(size_t page) override;
void pageSelected(size_t page) override;
void pageInserted(size_t page) override;
void pageDeleted(size_t page) override;
private:
/**
* Unselect the last selected page, if any
*/
void unselectPage();
/**
* Updates the indices of the pages
*/
void updateIndices();
private:
IconNameHelper iconNameHelper;
};
| 1,657
|
C++
|
.h
| 61
| 23.557377
| 92
| 0.682479
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,964
|
SidebarPreviewPageEntry.h
|
xournalpp_xournalpp/src/core/gui/sidebar/previews/page/SidebarPreviewPageEntry.h
|
/*
* Xournal++
*
* A Sidebar preview widget
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include "gui/sidebar/previews/base/SidebarPreviewBaseEntry.h" // for Previ...
#include "model/PageRef.h" // for PageRef
class SidebarPreviewPages;
class SidebarPreviewPageEntry: public SidebarPreviewBaseEntry {
public:
SidebarPreviewPageEntry(SidebarPreviewPages* sidebar, const PageRef& page, size_t index);
~SidebarPreviewPageEntry() override;
public:
int getHeight() const override;
PreviewRenderType getRenderType() const override;
void setIndex(size_t index);
size_t getIndex() const;
bool isSelected() const;
double getZoom() const;
protected:
SidebarPreviewPages* sidebar;
void mouseButtonPressCallback() override;
void paint(cairo_t* cr) override;
private:
size_t index;
friend class PreviewJob;
void drawEntryNumber(cairo_t* cr);
};
| 1,017
|
C++
|
.h
| 34
| 26.676471
| 93
| 0.725309
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,965
|
SidebarPreviewLayers.h
|
xournalpp_xournalpp/src/core/gui/sidebar/previews/layer/SidebarPreviewLayers.h
|
/*
* Xournal++
*
* Previews of the layers in the current page
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <memory> // for shared_ptr
#include <string> // for string
#include "control/layer/LayerCtrlListener.h" // for LayerCtrlL...
#include "gui/IconNameHelper.h" // for IconNameHe...
#include "gui/sidebar/previews/base/SidebarPreviewBase.h" // for SidebarPre...
#include "model/Layer.h" // for Layer, Lay...
class Control;
class GladeGui;
class LayerController;
class SidebarLayersContextMenu;
class SidebarPreviewLayers: public SidebarPreviewBase, public LayerCtrlListener {
public:
SidebarPreviewLayers(Control* control, bool stacked);
~SidebarPreviewLayers() override;
public:
void rebuildLayerMenu() override;
void layerVisibilityChanged() override;
void updateSelectedLayer() override;
public:
void enableSidebar() override;
/**
* @overwrite
*/
std::string getName() override;
/**
* @overwrite
*/
std::string getIconName() override;
/**
* Update the preview images
* @overwrite
*/
void updatePreviews() override;
/**
* Select a layer
*/
void layerSelected(Layer::Index layerIndex);
/**
* A layer was hidden / showed
*/
void layerVisibilityChanged(Layer::Index layerIndex, bool enabled);
public:
// DocumentListener interface (only the part which is not handled by SidebarPreviewBase)
void pageSizeChanged(size_t page) override;
void pageChanged(size_t page) override;
private:
/**
* Layer Controller
*/
LayerController* lc;
/**
* render as stacked
*/
bool stacked;
IconNameHelper iconNameHelper;
};
| 1,898
|
C++
|
.h
| 68
| 24
| 92
| 0.672737
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,966
|
SidebarPreviewLayerEntry.h
|
xournalpp_xournalpp/src/core/gui/sidebar/previews/layer/SidebarPreviewLayerEntry.h
|
/*
* Xournal++
*
* A Sidebar preview widget
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <string> // for string
#include <gtk/gtk.h> // for GtkWi...
#include "gui/sidebar/previews/base/SidebarPreviewBaseEntry.h" // for Previ...
#include "model/Layer.h" // for Layer
#include "model/PageRef.h" // for PageRef
#include "util/raii/GObjectSPtr.h"
class SidebarPreviewLayers;
class SidebarPreviewLayerEntry: public SidebarPreviewBaseEntry {
public:
SidebarPreviewLayerEntry(SidebarPreviewLayers* sidebar, const PageRef& page, Layer::Index layerId,
const std::string& layerName, bool stacked);
~SidebarPreviewLayerEntry() override;
public:
int getHeight() const override;
/**
* @return What should be rendered
* @override
*/
PreviewRenderType getRenderType() const override;
/**
* @return The layer to be rendered
*/
Layer::Index getLayer() const;
GtkWidget* getWidget() const override;
/**
* Set the value of the visible checkbox
*/
void setVisibleCheckbox(bool enabled);
protected:
void mouseButtonPressCallback() override;
void checkboxToggled();
SidebarPreviewLayers* sidebar;
private:
/// Layer to render
Layer::Index layerId;
/**
* Toolbar with controls
*/
int toolbarHeight = 0;
/// Container box for the preview and the button
xoj::util::WidgetSPtr box;
/// Visibility checkbox
GtkWidget* cbVisible = nullptr;
gulong callbackId = 0;
/// render as stacked
bool stacked = false;
friend class PreviewJob;
};
| 1,803
|
C++
|
.h
| 60
| 25.683333
| 102
| 0.662993
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,967
|
SidebarPreviewBase.h
|
xournalpp_xournalpp/src/core/gui/sidebar/previews/base/SidebarPreviewBase.h
|
/*
* Xournal++
*
* Base class for prviews in the sidebar
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <memory> // for unique_ptr
#include <vector> // for vector
#include <gtk/gtk.h> // for GtkWidget, GtkAllocation
#include "gui/sidebar/AbstractSidebarPage.h" // for AbstractSidebarPage
#include "model/DocumentChangeType.h" // for DocumentChangeType
#include "util/Util.h"
#include "util/raii/GObjectSPtr.h"
class PdfCache;
class SidebarLayout;
class SidebarPreviewBaseEntry;
class Control;
class SidebarPreviewBase: public AbstractSidebarPage {
public:
SidebarPreviewBase(Control* control, const char* menuId, const char* toolbarId);
~SidebarPreviewBase() override;
public:
void enableSidebar() override;
void disableSidebar() override;
/**
* Layout the pages to the current size of the sidebar
*/
void layout() override;
/**
* Update the preview images
*/
virtual void updatePreviews() = 0;
/**
* @overwrite
*/
bool hasData() override;
/**
* @overwrite
*/
GtkWidget* getWidget() override;
/**
* Gets the zoom factor for the previews
*/
double getZoom() const;
/**
* Gets the PDF cache for preview rendering
*/
PdfCache* getCache();
public:
// DocumentListener interface (only the part handled by SidebarPreviewBase)
void documentChanged(DocumentChangeType type) override;
void pageInserted(size_t page) override;
void pageDeleted(size_t page) override;
protected:
/**
* Timeout callback to scroll to a page
*/
static bool scrollToPreview(SidebarPreviewBase* sidebar);
/// The width of the sidebar has changed
void newWidth(double width);
public:
/**
* Opens a context menu, at the current cursor position.
*/
void openPreviewContextMenu(GdkEvent* currentEvent);
private:
/**
* The Zoom of the previews
*/
double zoom = 0.15;
/// last recorded width of the sidebar
double lastWidth = -1;
/**
* For preview rendering
*/
std::unique_ptr<PdfCache> cache;
protected:
/// The scrollable area with the miniatures
xoj::util::WidgetSPtr scrollableBox;
/// Main box, containing the scrollable area and the toolbar.
xoj::util::WidgetSPtr mainBox;
/// The widget within the scrollable area with the page miniatures
xoj::util::GObjectSPtr<GtkFixed> miniaturesContainer;
/**
* The context menu to display when a miniature is right-clicked.
* This must be populated by the derived classes constructors.
* It must be a GtkPopover parented (gtk_widget_set_parent()) by this->miniaturesContainer
*/
xoj::util::GObjectSPtr<GtkMenu> contextMenu;
/**
* The currently selected entry in the sidebar, starting from 0
* -1 means no valid selection
*/
size_t selectedEntry = npos;
/**
* The previews
*/
std::vector<std::unique_ptr<SidebarPreviewBaseEntry>> previews;
/**
* The sidebar is enabled
*/
bool enabled = false;
friend class SidebarLayout;
};
| 3,236
|
C++
|
.h
| 110
| 24.963636
| 94
| 0.690123
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,968
|
SidebarLayout.h
|
xournalpp_xournalpp/src/core/gui/sidebar/previews/base/SidebarLayout.h
|
/*
* Xournal++
*
* Sidebar preview layout
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
class SidebarPreviewBase;
class SidebarLayout {
public:
SidebarLayout() = delete;
~SidebarLayout() = delete;
public:
/**
* Layouts the sidebar
*/
static void layout(SidebarPreviewBase* sidebar);
private:
};
| 405
|
C++
|
.h
| 23
| 14.869565
| 52
| 0.700265
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,969
|
SidebarPreviewBaseEntry.h
|
xournalpp_xournalpp/src/core/gui/sidebar/previews/base/SidebarPreviewBaseEntry.h
|
/*
* Xournal++
*
* A preview entry in a sidebar
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <mutex> // for mutex
#include <cairo.h> // for cairo_t, cairo_surface_t
#include <glib.h> // for gboolean
#include <gtk/gtk.h> // for GtkWidget
#include "model/PageRef.h" // for PageRef
#include "util/raii/CairoWrappers.h"
#include "util/raii/GObjectSPtr.h"
class SidebarPreviewBase;
typedef enum {
/**
* Render the whole page
*/
RENDER_TYPE_PAGE_PREVIEW = 1,
/**
* Render only a layer
*/
RENDER_TYPE_PAGE_LAYER,
/**
* Render the stack up to a layer
*/
RENDER_TYPE_PAGE_LAYERSTACK
} PreviewRenderType;
class SidebarPreviewBaseEntry {
public:
SidebarPreviewBaseEntry(SidebarPreviewBase* sidebar, const PageRef& page);
virtual ~SidebarPreviewBaseEntry();
public:
virtual GtkWidget* getWidget() const;
virtual int getWidth() const;
virtual int getHeight() const;
virtual void setSelected(bool selected);
virtual void repaint();
virtual void updateSize();
/**
* @return What should be rendered
*/
virtual PreviewRenderType getRenderType() const = 0;
private:
static gboolean drawCallback(GtkWidget* widget, cairo_t* cr, SidebarPreviewBaseEntry* preview);
protected:
virtual void mouseButtonPressCallback() = 0;
virtual void drawLoadingPage();
virtual void paint(cairo_t* cr);
protected:
/**
* If this page is currently selected
*/
bool selected = false;
int imageWidth;
int imageHeight;
int DPIscaling; ///< 1, maybe 2 in HiDPI setups
/**
* The sidebar which displays the previews
*/
SidebarPreviewBase* sidebar;
/**
* The page which is representated
*/
PageRef page;
/// Mutex protecting the buffer
std::mutex drawingMutex{};
/// Buffer because of performance reasons
xoj::util::CairoSurfaceSPtr buffer;
/// The main widget, containing the miniature
xoj::util::WidgetSPtr button;
friend class PreviewJob;
};
| 2,137
|
C++
|
.h
| 78
| 23.217949
| 99
| 0.691249
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,970
|
SidebarIndexPage.h
|
xournalpp_xournalpp/src/core/gui/sidebar/indextree/SidebarIndexPage.h
|
/*
* Xournal++
*
* Index Sidebar Page
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <string> // for string
#include <glib.h> // for gboolean, gchar, gint
#include <gtk/gtk.h> // for GtkWidget, GtkTreeIter
#include "gui/IconNameHelper.h" // for IconNameHelper
#include "gui/sidebar/AbstractSidebarPage.h" // for AbstractSidebarPage
#include "model/DocumentChangeType.h" // for DocumentChangeType
class Control;
class SidebarToolbar;
class SidebarIndexPage: public AbstractSidebarPage {
public:
SidebarIndexPage(Control* control);
~SidebarIndexPage() override;
public:
void enableSidebar() override;
void disableSidebar() override;
void layout() override;
/**
* @overwrite
*/
std::string getName() override;
/**
* @overwrite
*/
std::string getIconName() override;
/**
* @overwrite
*/
bool hasData() override;
/**
* @overwrite
*/
GtkWidget* getWidget() override;
/**
* @overwrite
*/
void selectPageNr(size_t page, size_t pdfPage) override;
/**
* Select page in the tree
*/
bool selectPageNr(size_t page, size_t pdfPage, GtkTreeIter* parent);
/**
* @overwrite
*/
void documentChanged(DocumentChangeType type) override;
private:
/**
* Tree search function if you type chars within the tree. Source: Pidgin
*/
static gboolean treeSearchFunction(GtkTreeModel* model, gint column, const gchar* key, GtkTreeIter* iter,
SidebarIndexPage* sidebar);
/**
* A bookmark was selected
*/
static auto treeBookmarkSelected(GtkWidget* treeview, SidebarIndexPage* sidebar) -> bool;
/**
* The function which is called after a search timeout
*/
static auto searchTimeoutFunc(SidebarIndexPage* sidebar) -> bool;
private:
/**
* Expand links
*/
int expandOpenLinks(GtkTreeModel* model, GtkTreeIter* parent);
private:
/**
* The Tree with the Bookmarks
*/
GtkWidget* treeViewBookmarks = nullptr;
/**
* The scrollbars for the Tree
*/
GtkWidget* scrollBookmarks = nullptr;
/**
* Keep track of the tree bookmark selection handler; see documentChanged
* method for why this is necessary.
*/
unsigned long selectHandler = 0; // g_signal_connect uses 0 as error value
/**
* If currently searching, scroll to the page is disable, else search is not really working
*
* After a timeout we scroll to the selected page
*/
guint searchTimeout = 0;
/**
* If there is something to display in the tree
*/
bool hasContents = false;
IconNameHelper iconNameHelper;
};
| 2,866
|
C++
|
.h
| 101
| 23.415842
| 109
| 0.660219
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,971
|
GotoDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/GotoDialog.h
|
/*
* Xournal++
*
* Goto-Page dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <functional>
#include <gtk/gtk.h>
#include "util/raii/GtkWindowUPtr.h"
class GladeSearchpath;
namespace xoj::popup {
class GotoDialog {
public:
GotoDialog(GladeSearchpath* gladeSearchPath, size_t initialPage, size_t maxPage,
std::function<void(size_t)> callback);
~GotoDialog();
public:
inline GtkWindow* getWindow() const { return window.get(); }
private:
xoj::util::GtkWindowUPtr window;
GtkSpinButton* spinButton = nullptr;
std::function<void(size_t)> callback;
};
}; // namespace xoj::popup
| 714
|
C++
|
.h
| 29
| 21.655172
| 84
| 0.715976
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,972
|
PluginDialogEntry.h
|
xournalpp_xournalpp/src/core/gui/dialog/PluginDialogEntry.h
|
/*
* Xournal++
*
* Configuration of a single plugin
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include "config-features.h"
#ifdef ENABLE_PLUGINS
#include <string> // for string
#include <gtk/gtk.h>
class Plugin;
class GladeSearchpath;
class PluginDialogEntry {
public:
PluginDialogEntry(Plugin* plugin, GladeSearchpath* gladeSearchPath, GtkBox* box);
public:
void saveSettings(std::string& pluginEnabled, std::string& pluginDisabled);
private:
/**
* Plugin instance
*/
Plugin* plugin;
GtkCheckButton* stateButton;
};
#endif
| 648
|
C++
|
.h
| 30
| 18.966667
| 85
| 0.738487
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,973
|
SettingsDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/SettingsDialog.h
|
/*
* Xournal++
*
* Settings Dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <functional>
#include <string> // for string
#include <vector> // for vector
#include <gtk/gtk.h> // for GtkWidget, GtkWindow
#include "audio/DeviceInfo.h" // for DeviceInfo
#include "control/tools/StrokeStabilizerEnum.h" // for AveragingMethod, Pre...
#include "gui/Builder.h"
#include "util/raii/GtkWindowUPtr.h"
#include "ButtonConfigGui.h"
#include "DeviceClassConfigGui.h"
#include "LanguageConfigGui.h"
#include "LatexSettingsPanel.h"
#include "SettingsDialogPaletteTab.h"
#include "filesystem.h" // for path
class Control;
class Settings;
struct Palette;
class SettingsDialog {
public:
SettingsDialog(GladeSearchpath* gladeSearchPath, Settings* settings, Control* control,
const std::vector<fs::path>& paletteDirectories, std::function<void()> callback);
inline GtkWindow* getWindow() const { return window.get(); }
private:
void save();
void setDpi(int dpi);
/**
* Set active regions
*/
void enableWithCheckbox(const std::string& checkbox, const std::string& widget);
void disableWithCheckbox(const std::string& checkbox, const std::string& widget);
void enableWithEnabledCheckbox(const std::string& checkbox, const std::string& widget);
/*
* Listeners for changes to settings.
*/
void customHandRecognitionToggled();
void customStylusIconTypeChanged();
/**
* Update whether options can be selected, tooltips, etc. for
* pressure sensitivity options (e.g. pressure multiplier).
*/
void updatePressureSensitivityOptions();
private:
void load();
void loadCheckbox(const char* name, bool value);
bool getCheckbox(const char* name);
void loadSlider(const char* name, double value);
double getSlider(const char* name);
void initMouseButtonEvents(GladeSearchpath* gladeSearchPath);
void showStabilizerAvMethodOptions(StrokeStabilizer::AveragingMethod method);
void showStabilizerPreprocessorOptions(StrokeStabilizer::Preprocessor preprocessor);
private:
Settings* settings = nullptr;
Control* control = nullptr;
GtkWidget* callib = nullptr;
int dpi = 72;
std::vector<DeviceInfo> audioInputDevices;
std::vector<DeviceInfo> audioOutputDevices;
Builder builder;
xoj::util::GtkWindowUPtr window;
LanguageConfigGui languageConfig;
std::vector<std::unique_ptr<ButtonConfigGui>> buttonConfigs;
std::vector<DeviceClassConfigGui> deviceClassConfigs;
LatexSettingsPanel latexPanel;
SettingsDialogPaletteTab paletteTab;
std::function<void()> callback;
};
| 2,755
|
C++
|
.h
| 77
| 31.857143
| 100
| 0.740211
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,974
|
PageTemplateDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/PageTemplateDialog.h
|
/*
* Xournal++
*
* Dialog to configure page template for new pages
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory> // for unique_ptr
#include "control/settings/PageTemplateSettings.h" // for PageTemplateSettings
#include "util/raii/GtkWindowUPtr.h"
class PageTypeHandler;
class PageTypeInfo;
class GladeSearchpath;
class Settings;
class ToolMenuHandler;
class PageTypeSelectionPopoverGridOnly;
namespace xoj::popup {
class PageTemplateDialog final {
public:
PageTemplateDialog(GladeSearchpath* gladeSearchPath, Settings* settings, ToolMenuHandler* toolmenu,
PageTypeHandler* types);
PageTemplateDialog(PageTemplateDialog&) = delete;
PageTemplateDialog(PageTemplateDialog&&) = delete;
PageTemplateDialog& operator=(PageTemplateDialog&) = delete;
PageTemplateDialog&& operator=(PageTemplateDialog&&) = delete;
~PageTemplateDialog();
public:
/**
* The dialog was confirmed / saved
*/
bool isSaved() const;
void changeCurrentPageBackground(const PageTypeInfo* info);
inline GtkWindow* getWindow() const { return window.get(); }
private:
void showPageSizeDialog();
void updatePageSize();
void saveToFile();
void loadFromFile();
void updateDataFromModel();
void saveToModel();
private:
GladeSearchpath* gladeSearchPath; // For opening subdialogs as needed
xoj::util::GtkWindowUPtr window;
Settings* settings;
ToolMenuHandler* toolMenuHandler;
PageTypeHandler* types;
PageTemplateSettings model;
std::unique_ptr<PageTypeSelectionPopoverGridOnly> pageTypeSelectionMenu;
/**
* The dialog was confirmed / saved
*/
bool saved = false;
private:
// Sub-widgets, owned by this->window
GtkLabel* pageSizeLabel;
GtkLabel* backgroundTypeLabel;
GtkColorChooser* backgroundColorChooser;
GtkToggleButton* copyLastPageButton;
GtkToggleButton* copyLastPageSizeButton;
};
}; // namespace xoj::popup
| 2,057
|
C++
|
.h
| 65
| 27.707692
| 103
| 0.75215
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,975
|
ExportDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/ExportDialog.h
|
/*
* Xournal++
*
* Dialog with export settings
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <functional>
#include <gtk/gtk.h> // for GtkComboBox, GtkWindow
#include "control/jobs/BaseExportJob.h" // for ExportBackgroundType
#include "control/jobs/ImageExport.h" // for RasterImageQualityParameter
#include "gui/Builder.h"
#include "util/ElementRange.h" // for PageRangeVector
#include "util/raii/GtkWindowUPtr.h"
class GladeSearchpath;
namespace xoj::popup {
class ExportDialog {
public:
ExportDialog(GladeSearchpath* gladeSearchPath, ExportGraphicsFormat format, size_t currentPage, size_t pageCount,
std::function<void(const ExportDialog&)> callbackFun);
~ExportDialog();
public:
bool isConfirmed() const;
const PageRangeVector& getRange() const;
bool progressiveModeSelected() const;
ExportBackgroundType getBackgroundType() const;
/**
* @brief Reads the quality parameter from the dialog
*
* @return The selected quality parameter
*/
RasterImageQualityParameter getPngQualityParameter() const;
inline GtkWindow* getWindow() const { return window.get(); }
private:
/**
* @brief Handler for changes in combobox cbQuality
*/
static void selectQualityCriterion(GtkComboBox* comboBox, ExportDialog* self);
static void onSuccessCallback(ExportDialog* self);
private:
xoj::util::GtkWindowUPtr window;
size_t currentPage = 0;
size_t pageCount = 0;
bool confirmed = false;
bool progressiveMode;
ExportBackgroundType backgroundType;
RasterImageQualityParameter qualityParameter;
PageRangeVector pageRanges;
Builder builder;
std::function<void(const ExportDialog&)> callbackFun;
};
}; // namespace xoj::popup
| 1,883
|
C++
|
.h
| 57
| 29.22807
| 117
| 0.744199
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,976
|
PluginDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/PluginDialog.h
|
/*
* Xournal++
*
* Plugin manage dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include "config-features.h"
#ifdef ENABLE_PLUGINS
#include <memory> // for unique_ptr
#include <vector> // for vector
#include "util/raii/GtkWindowUPtr.h"
#include "PluginDialogEntry.h" // for PluginDialogEntry
class Plugin;
class PluginController;
class Settings;
class GladeSearchpath;
class PluginDialog {
public:
PluginDialog(GladeSearchpath* gladeSearchPath, Settings* settings,
const std::vector<std::unique_ptr<Plugin>>& plugins);
public:
inline GtkWindow* getWindow() const { return window.get(); }
private:
void saveSettings();
private:
Settings* settings;
std::vector<std::unique_ptr<PluginDialogEntry>> plugins;
xoj::util::GtkWindowUPtr window;
};
#endif
| 889
|
C++
|
.h
| 35
| 22.6
| 70
| 0.741974
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,977
|
DeviceClassConfigGui.h
|
xournalpp_xournalpp/src/core/gui/dialog/DeviceClassConfigGui.h
|
/*
* Xournal++
*
* The configuration for a button in the Settings Dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gtk/gtk.h> // for GtkWidget, GtkComboBox, GtkWindow
#include "control/DeviceListHelper.h" // for InputDevice
class Settings;
class GladeSearchpath;
class DeviceClassConfigGui {
public:
DeviceClassConfigGui(GladeSearchpath* gladeSearchPath, GtkBox* box, Settings* settings, const InputDevice& device);
public:
void loadSettings();
void saveSettings();
private:
static void cbSelectCallback(GtkComboBox* widget, DeviceClassConfigGui* gui);
void enableDisableTools();
private:
Settings* settings;
InputDevice device;
GtkWidget* labelDevice;
GtkWidget* cbDeviceClass;
};
| 822
|
C++
|
.h
| 30
| 24.6
| 119
| 0.766284
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,978
|
SelectOpacityDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/SelectOpacityDialog.h
|
/*
* Xournal++
*
* The about dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <functional>
#include "control/ToolEnums.h"
#include "util/raii/GtkWindowUPtr.h"
class GladeSearchpath;
namespace xoj::popup {
class SelectOpacityDialog {
public:
SelectOpacityDialog(GladeSearchpath* gladeSearchPath, int alpha, OpacityFeature type,
std::function<void(int, OpacityFeature)> callback);
~SelectOpacityDialog();
inline GtkWindow* getWindow() const { return window.get(); }
private:
void setPreviewImage(int alpha);
private:
xoj::util::GtkWindowUPtr window;
GtkImage* previewImage;
GtkRange* alphaRange;
OpacityFeature opacityFeature;
std::function<void(int, OpacityFeature)> callback;
};
}; // namespace xoj::popup
| 868
|
C++
|
.h
| 32
| 23.6875
| 89
| 0.733978
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,979
|
ButtonConfigGui.h
|
xournalpp_xournalpp/src/core/gui/dialog/ButtonConfigGui.h
|
/*
* Xournal++
*
* The configuration for a button in the Settings Dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <map> // for map, map<>::value_compare
#include <string> // for string
#include <vector> // for vector
#include <gtk/gtk.h> // for GtkWidget, GtkComboBox, GtkWindow
#include "control/DeviceListHelper.h" // for InputDevice
#include "control/ToolEnums.h" // for ToolSize
#include "gui/IconNameHelper.h" // for IconNameHelper
class Settings;
class GladeSearchpath;
class ButtonConfigGui {
public:
ButtonConfigGui(GladeSearchpath* gladeSearchPath, GtkBox* box, Settings* settings, unsigned int button,
bool withDevice);
public:
void loadSettings();
void saveSettings();
private:
static void cbSelectCallback(GtkComboBox* widget, ButtonConfigGui* gui);
void enableDisableTools();
std::string toolSizeToLabel(ToolSize size);
private:
Settings* settings;
GtkWidget* cbDevice;
GtkWidget* cbDisableDrawing;
GtkWidget* cbTool;
GtkWidget* cbThickness;
GtkWidget* colorButton;
GtkWidget* cbEraserType;
GtkWidget* cbDrawingType;
GtkWidget* cbStrokeType;
std::vector<InputDevice> deviceList;
unsigned int button = 0;
bool withDevice = false;
typedef std::map<int, ToolSize> ToolSizeIndexMap;
static ToolSizeIndexMap toolSizeIndexMap;
IconNameHelper iconNameHelper;
};
| 1,502
|
C++
|
.h
| 48
| 27.645833
| 107
| 0.734028
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,980
|
RenameLayerDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/RenameLayerDialog.h
|
/*
* Xournal++
*
* The rename layer dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gtk/gtk.h>
#include "util/raii/GtkWindowUPtr.h"
class GladeSearchpath;
class Layer;
class LayerController;
class UndoRedoHandler;
class RenameLayerDialog {
public:
RenameLayerDialog(GladeSearchpath* gladeSearchPath, UndoRedoHandler* undo, LayerController* lc, Layer* l);
inline GtkWindow* getWindow() const { return window.get(); }
private:
LayerController* lc;
UndoRedoHandler* undo;
Layer* l;
xoj::util::GtkWindowUPtr window;
GtkEntry* layerNameEntry;
};
| 671
|
C++
|
.h
| 28
| 21.357143
| 110
| 0.754331
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,981
|
ToolbarManageDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/ToolbarManageDialog.h
|
/*
* Xournal++
*
* Toolbar edit dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <functional>
#include <glib.h> // for gchar
#include <gtk/gtk.h> // for GtkButton, GtkCellRendererText, GtkListStore
#include "util/raii/GObjectSPtr.h"
#include "util/raii/GtkWindowUPtr.h"
class ToolbarData;
class ToolbarModel;
class GladeSearchpath;
class ToolbarManageDialog {
public:
ToolbarManageDialog(GladeSearchpath* gladeSearchPath, ToolbarModel* model, std::function<void()> callback);
~ToolbarManageDialog();
public:
inline GtkWindow* getWindow() const { return window.get(); }
private:
static void treeSelectionChangedCallback(GtkTreeSelection* selection, ToolbarManageDialog* dlg);
static void treeCellEditedCallback(GtkCellRendererText* renderer, gchar* pathString, gchar* newText,
ToolbarManageDialog* dlg);
static void buttonNewCallback(GtkButton* button, ToolbarManageDialog* dlg);
static void buttonDeleteCallback(GtkButton* button, ToolbarManageDialog* dlg);
static void buttonCopyCallback(GtkButton* button, ToolbarManageDialog* dlg);
void addToolbarData(std::unique_ptr<ToolbarData> tbd);
void entrySelected(ToolbarData* data);
void updateSelectionData();
ToolbarData* getSelectedEntry();
private:
ToolbarModel* tbModel;
xoj::util::GObjectSPtr<GtkListStore> model;
GtkTreeView* tree;
GtkWidget* copyButton;
GtkWidget* deleteButton;
xoj::util::GtkWindowUPtr window;
std::function<void()> callback;
};
| 1,628
|
C++
|
.h
| 45
| 32.088889
| 111
| 0.754464
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,982
|
XojOpenDlg.h
|
xournalpp_xournalpp/src/core/gui/dialog/XojOpenDlg.h
|
/*
* Xournal++
*
* GTK Open dialog to select XOJ (or PDF) file with preview
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <functional>
#include <gtk/gtk.h> // for GtkWindow
#include "filesystem.h" // for path
class Settings;
namespace xoj::OpenDlg {
void showOpenFileDialog(GtkWindow* parent, Settings* settings, std::function<void(fs::path)> callback);
/// @param callback(path, attachPdf)
void showAnnotatePdfDialog(GtkWindow* parent, Settings* settings, std::function<void(fs::path, bool)> callback);
void showOpenTemplateDialog(GtkWindow* parent, Settings* settings, std::function<void(fs::path)> callback);
/// @param callback(path, attachImg)
void showOpenImageDialog(GtkWindow* parent, Settings* settings, std::function<void(fs::path, bool)> callback);
void showMultiFormatDialog(GtkWindow* parent, std::vector<std::string> formats, std::function<void(fs::path)> callback);
}; // namespace xoj::OpenDlg
| 1,009
|
C++
|
.h
| 24
| 40.333333
| 120
| 0.758444
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,983
|
FileChooserFiltersHelper.h
|
xournalpp_xournalpp/src/core/gui/dialog/FileChooserFiltersHelper.h
|
/*
* Xournal++
*
* Helper functions to add filters to GtkFileChooserDialogs
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gtk/gtk.h>
namespace xoj {
void addFilterAllFiles(GtkFileChooser* fc);
void addFilterSupported(GtkFileChooser* fc);
void addFilterPdf(GtkFileChooser* fc);
void addFilterXoj(GtkFileChooser* fc);
void addFilterXopp(GtkFileChooser* fc);
void addFilterXopt(GtkFileChooser* fc);
void addFilterSvg(GtkFileChooser* fc);
void addFilterPng(GtkFileChooser* fc);
void addFilterImages(GtkFileChooser* fc); ///< All images supported by GdkPixbuf
}; // namespace xoj
| 669
|
C++
|
.h
| 23
| 27.565217
| 81
| 0.791602
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,984
|
LatexDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/LatexDialog.h
|
/*
* Xournal++
*
* Latex implementation
*
* @author W Brenna
* http://wbrenna.ca
*
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <functional>
#include <string> // for string
#include <cairo.h> // for cairo_t
#include <gtk/gtk.h> // for GtkWidget, GtkTextBuffer, GtkWindow
#include <gtk/gtkcssprovider.h> // for GtkCssProvider
#include <poppler.h> // for PopplerDocument, PopplerPage
#include "util/Color.h"
#include "util/raii/GObjectSPtr.h"
#include "util/raii/GtkWindowUPtr.h"
#include "view/Mask.h"
class LatexController;
class LatexSettings;
class GladeSearchpath;
class LatexDialog final {
public:
LatexDialog() = delete;
LatexDialog(const LatexDialog& other) = delete;
LatexDialog& operator=(const LatexDialog& other) = delete;
LatexDialog(GladeSearchpath* gladeSearchPath, std::unique_ptr<LatexController> texCtrl);
~LatexDialog();
public:
void setCompilationStatus(bool isTexValid, bool isCompilationDone, const std::string& compilationOutput);
/**
* Set temporary Tex render and queue a re-draw.
* @param pdf PDF document with rendered TeX.
*/
void setTempRender(PopplerDocument* pdf);
/**
* Set TeX preview background color to the given color.
* @param color New preview background color.
*/
void setPreviewBackgroundColor(Color color);
// Necessary for the controller in order to connect the 'text-changed'
// signal handler
GtkTextBuffer* getTextBuffer();
/**
* @return The contents of the formula input text buffer.
*/
std::string getBufferContents();
inline GtkWindow* getWindow() const { return window.get(); }
private:
/**
* @brief Preview DrawingArea draw function
*/
static void previewDrawFunc(GtkDrawingArea* drawing_area, cairo_t* cr, int width, int height, LatexDialog* self);
private:
std::unique_ptr<LatexController> texCtrl;
xoj::util::GtkWindowUPtr window;
// Preview
GtkDrawingArea* previewDrawingArea;
xoj::view::Mask previewMask;
// Text field
xoj::util::GObjectSPtr<GtkCssProvider> cssProvider; ///< For tex code display font and size
GtkWidget* texBox;
GtkButton* btOk;
GtkLabel* texErrorLabel;
GtkTextBuffer* compilationOutputTextBuffer;
GtkTextBuffer* textBuffer;
/**
* Source page from which we render the preview.
*/
xoj::util::GObjectSPtr<PopplerPage> previewPdfPage;
/**
* The final LaTeX string to save once the dialog is closed.
*/
std::string finalLatex;
/**
* Background color for the LaTeX preview.
*/
Color previewBackgroundColor;
std::function<void()> callback;
};
| 2,761
|
C++
|
.h
| 85
| 28.435294
| 117
| 0.707078
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,985
|
FormatDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/FormatDialog.h
|
/*
* Xournal++
*
* The page format dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <functional>
#include <memory> // for unique_ptr
#include <vector> // for vector
#include <gtk/gtk.h> // for gtk_paper_size_free, GtkComboBox, GtkToggl...
#include "gui/Builder.h"
#include "util/raii/GtkWindowUPtr.h"
class GladeSearchpath;
class Settings;
namespace xoj::popup {
class FormatDialog {
public:
FormatDialog(GladeSearchpath* gladeSearchPath, Settings* settings, double width, double height,
std::function<void(double w, double h)> callback);
inline GtkWindow* getWindow() const { return window.get(); }
private:
enum Orientation { ORIENTATION_NOT_DEFINED, ORIENTATION_LANDSCAPE, ORIENTATION_PORTRAIT };
void loadPageFormats();
void setOrientation(Orientation orientation);
void setSpinValues(double width, double heigth);
static void portraitSelectedCb(GtkToggleButton* bt, FormatDialog* dlg);
static void landscapeSelectedCb(GtkToggleButton* bt, FormatDialog* dlg);
static void cbFormatChangedCb(GtkComboBox* widget, FormatDialog* dlg);
static void cbUnitChanged(GtkComboBox* widget, FormatDialog* dlg);
static void spinValueChangedCb(FormatDialog* dlg);
static void reset(FormatDialog* self);
private:
Settings* settings = nullptr;
std::vector<std::unique_ptr<GtkPaperSize, decltype(>k_paper_size_free)>> paperSizes;
Orientation orientation = ORIENTATION_NOT_DEFINED;
int selectedScale = 0;
double scale = 0;
double origWidth = 0;
double origHeight = 0;
bool ignoreSpinChange = false;
GtkComboBox* paperTemplatesCombo;
GtkSpinButton* widthSpin;
GtkSpinButton* heightSpin;
GtkToggleButton* landscapeButton;
GtkToggleButton* portraitButton;
xoj::util::GtkWindowUPtr window;
std::function<void(double w, double h)> callbackFun;
};
}; // namespace xoj::popup
| 1,995
|
C++
|
.h
| 54
| 33.12963
| 99
| 0.74831
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,986
|
SettingsDialogPaletteTab.h
|
xournalpp_xournalpp/src/core/gui/dialog/SettingsDialogPaletteTab.h
|
#pragma once
#include <filesystem>
#include <optional>
#include <vector>
#include <gtk/gtk.h>
#include "gui/Builder.h"
#include "gui/GladeGui.h"
#include "gui/toolbarMenubar/model/ColorPalette.h"
class SettingsDialogPaletteTab {
public:
SettingsDialogPaletteTab(GladeSearchpath* gladeSearchPath, const std::vector<fs::path>& paletteDirectories);
void renderPaletteTab(const fs::path& currentlySetPalettePath);
auto getSelectedPalette() const -> std::optional<fs::path>;
inline GtkWidget* getPanel() const { return GTK_WIDGET(panel); }
private:
std::vector<fs::path> allPaletteFilePaths;
GtkLabel* colorPaletteExplainLabel;
GtkListBox* paletteListBox;
Builder builder;
GtkScrolledWindow* panel;
void setAllPaletteFilePaths(const std::vector<fs::path>& paletteDirectories);
void renderColorPaletteExplainLabel() const;
static auto newErrorListBoxRow(const fs::path& palettePath, const std::string& error) -> GtkWidget*;
static auto newPaletteTextBox(const std::string& mainContent, const fs::path& path) -> GtkWidget*;
static auto newPaletteColorIconsBox(const Palette& palette) -> GtkWidget*;
static auto newPaletteListBoxRow(Palette& palette) -> GtkWidget*;
static void renderNoPaletteFoundDisclaimer(GtkListBox* lb);
static auto renderPaletteListBoxRow(GtkListBox* lb, const fs::path& p) -> GtkWidget*;
};
| 1,382
|
C++
|
.h
| 29
| 44.068966
| 112
| 0.774889
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,987
|
SelectBackgroundColorDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/SelectBackgroundColorDialog.h
|
/*
* Xournal++
*
* Dialog for selecting a background color
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <array> // for array
#include <functional>
#include <gdk/gdk.h> // for GdkRGBA
#include <gtk/gtk.h> // for GtkWindow
#include "util/Color.h"
#include "util/raii/GtkWindowUPtr.h"
class Control;
/**
* Count of last background colors
*/
const int LAST_BACKGROUND_COLOR_COUNT = 9;
class SelectBackgroundColorDialog {
public:
SelectBackgroundColorDialog(Control* control, std::function<void(Color)> callback);
inline GtkWindow* getWindow() const { return window.get(); }
private:
void storeLastUsedValuesInSettings(GdkRGBA color);
private:
Control* control{nullptr};
/**
* Last used background colors (stored in settings)
*/
std::array<GdkRGBA, LAST_BACKGROUND_COLOR_COUNT> lastBackgroundColors{};
xoj::util::GtkWindowUPtr window;
std::function<void(Color)> callback;
};
| 1,022
|
C++
|
.h
| 37
| 24.837838
| 87
| 0.731481
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,988
|
LanguageConfigGui.h
|
xournalpp_xournalpp/src/core/gui/dialog/LanguageConfigGui.h
|
/*
* Xournal++
*
* The configuration for a language in the Settings Dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string> // for string, basic_string
#include <vector> // for vector
#include <gtk/gtk.h> // for GtkWidget, GtkWindow
#include "gui/GladeGui.h" // for GladeGui
class Settings;
class GladeSearchpath;
class LanguageConfigGui: public GladeGui {
public:
LanguageConfigGui(GladeSearchpath* gladeSearchPath, GtkWidget* w, Settings* settings);
public:
void loadSettings(){};
void saveSettings();
// Not implemented! This is not a dialog!
void show(GtkWindow* parent) override{};
private:
std::vector<std::string> availableLocales;
Settings* settings;
};
| 799
|
C++
|
.h
| 29
| 24.896552
| 90
| 0.736495
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,989
|
AboutDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/AboutDialog.h
|
/*
* Xournal++
*
* The about dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include "util/raii/GtkWindowUPtr.h"
class GladeSearchpath;
namespace xoj::popup {
class AboutDialog {
public:
AboutDialog(GladeSearchpath* gladeSearchPath);
~AboutDialog();
inline GtkWindow* getWindow() const { return window.get(); }
private:
xoj::util::GtkWindowUPtr window;
};
}; // namespace xoj::popup
| 491
|
C++
|
.h
| 23
| 19
| 64
| 0.727273
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,990
|
LatexSettingsPanel.h
|
xournalpp_xournalpp/src/core/gui/dialog/LatexSettingsPanel.h
|
/*
* Xournal++
*
* Latex settings panel
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gtk/gtk.h> // for GtkToggleButton, GtkFileChooser, GtkWidget
#include "gui/Builder.h"
class GladeSearchpath;
class LatexSettings;
class LatexSettingsPanel {
public:
explicit LatexSettingsPanel(GladeSearchpath*);
LatexSettingsPanel(const LatexSettingsPanel&) = delete;
LatexSettingsPanel& operator=(const LatexSettingsPanel&) = delete;
LatexSettingsPanel(const LatexSettingsPanel&&) = delete;
LatexSettingsPanel& operator=(const LatexSettingsPanel&&) = delete;
void load(const LatexSettings& settings);
void save(LatexSettings& settings);
inline GtkWidget* getPanel() const { return GTK_WIDGET(panel); }
private:
void checkDeps();
/**
* @brief Update whether options accept input ("grayed-out" or not)
* based on the current panel state.
*/
void updateWidgetSensitivity();
Builder builder;
GtkScrolledWindow* panel;
GtkCheckButton* cbAutoDepCheck;
GtkFileChooser* globalTemplateChooser;
GtkWidget* sourceViewThemeSelector;
GtkCheckButton* cbUseSystemFont;
};
| 1,231
|
C++
|
.h
| 39
| 27.923077
| 71
| 0.750212
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,991
|
XojSaveDlg.h
|
xournalpp_xournalpp/src/core/gui/dialog/XojSaveDlg.h
|
/*
* Xournal++
*
* GTK Save/Export dialog to select destination file
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <functional>
#include <optional>
#include <gtk/gtk.h> // for GtkWindow
#include "util/raii/GtkWindowUPtr.h"
#include "filesystem.h" // for path
class Settings;
namespace xoj {
/// Helper class, for a single dialog
class SaveExportDialog {
public:
/**
* Shows a save file dialog. The callback is called with std::nullopt if no path were selected
*/
static void showSaveFileDialog(GtkWindow* parent, Settings* settings, fs::path suggestedPath,
std::function<void(std::optional<fs::path>)> callback);
/**
* Creates a save or export file dialog. The callback is called with std::nullopt if no path were selected
* @param pathValidation May modify the given path. Returns true if the path is (now) valid for saving/exporting.
* @param callback(path)
*/
SaveExportDialog(Settings* settings, fs::path suggestedPath, const char* windowTitle, const char* buttonLabel,
std::function<bool(fs::path&, const char* filterName)> pathValidation,
std::function<void(std::optional<fs::path>)> callback);
~SaveExportDialog() = default;
inline GtkWindow* getWindow() const { return window.get(); }
private:
/// Closes the dialog and calls the callback on `path`
void close(std::optional<fs::path> path);
xoj::util::GtkWindowUPtr window;
std::function<void(std::optional<fs::path>)> callback;
std::function<bool(fs::path&, const char* filterName)> pathValidation;
gulong signalId{};
};
}; // namespace xoj
| 1,757
|
C++
|
.h
| 45
| 34.155556
| 117
| 0.69077
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,992
|
ImageElementView.h
|
xournalpp_xournalpp/src/core/gui/dialog/backgroundSelect/ImageElementView.h
|
/*
* Xournal++
*
* Image view
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cairo.h> // for cairo_t
#include "model/BackgroundImage.h" // for BackgroundImage
#include "util/Util.h" // for npos
#include "BaseElementView.h" // for BaseElementView
class BackgroundSelectDialogBase;
class ImageElementView: public BaseElementView {
public:
ImageElementView(size_t id, BackgroundSelectDialogBase* dlg);
~ImageElementView() override;
protected:
/**
* Paint the contents (without border / selection)
*/
void paintContents(cairo_t* cr) override;
/**
* Get the width in pixel, without shadow / border
*/
int getContentWidth() override;
/**
* Get the height in pixel, without shadow / border
*/
int getContentHeight() override;
/**
* Will be called before getContentWidth() / getContentHeight(), can be overwritten
*/
void calcSize() override;
private:
double zoom = 1;
BackgroundImage backgroundImage;
int width = -1;
int height = -1;
friend class ImagesDialog;
};
| 1,175
|
C++
|
.h
| 44
| 22.909091
| 87
| 0.686661
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,993
|
BaseElementView.h
|
xournalpp_xournalpp/src/core/gui/dialog/backgroundSelect/BaseElementView.h
|
/*
* Xournal++
*
* Base class for Background selection dialog entry
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cairo.h> // for cairo_t, cairo_surface_t
#include <gdk/gdk.h> // for GdkEventButton
#include <glib.h> // for gboolean
#include <gtk/gtk.h> // for GtkWidget
#include "util/Util.h" // for npos
class BackgroundSelectDialogBase;
class BaseElementView {
public:
BaseElementView(size_t id, BackgroundSelectDialogBase* dlg);
virtual ~BaseElementView();
public:
GtkWidget* getWidget();
int getWidth();
int getHeight();
/**
* Select / unselect this entry
*/
void setSelected(bool selected);
/**
* Repaint this widget
*/
void repaint();
protected:
/**
* Apply the size to the Widget
*/
void updateSize();
/**
* Paint the whole widget
*/
void paint(cairo_t* cr);
/**
* Paint the contents (without border / selection)
*/
virtual void paintContents(cairo_t* cr) = 0;
/**
* Get the width in pixel, without shadow / border
*/
virtual int getContentWidth() = 0;
/**
* Get the height in pixel, without shadow / border
*/
virtual int getContentHeight() = 0;
/**
* Will be called before getContentWidth() / getContentHeight(), can be overwritten
*/
virtual void calcSize();
protected:
BackgroundSelectDialogBase* dlg;
private:
/**
* Element ID
*/
size_t id = npos;
bool selected = false;
GtkWidget* widget = nullptr;
cairo_surface_t* crBuffer = nullptr;
};
| 1,667
|
C++
|
.h
| 69
| 19.898551
| 87
| 0.64557
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,994
|
BackgroundSelectDialogBase.h
|
xournalpp_xournalpp/src/core/gui/dialog/backgroundSelect/BackgroundSelectDialogBase.h
|
/*
* Xournal++
*
* Base class for Background selection dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory>
#include <vector> // for vector
#include <gtk/gtk.h> // for GtkWidget, GtkWindow
#include "util/Util.h" // for npos
#include "util/raii/GtkWindowUPtr.h"
class Document;
class Settings;
class BaseElementView;
class GladeSearchpath;
class BackgroundSelectDialogBase {
protected:
BackgroundSelectDialogBase(GladeSearchpath* gladeSearchPath, Document* doc, Settings* settings, const char* title);
~BackgroundSelectDialogBase();
public:
Settings* getSettings();
void setSelected(size_t selected);
inline GtkWindow* getWindow() const { return window.get(); }
protected:
/// Adds the entry widgets
void populate();
void layout();
protected:
xoj::util::GtkWindowUPtr window;
Settings* settings = nullptr;
GtkScrolledWindow* scrolledWindow = nullptr;
GtkFixed* container = nullptr; ///< Area where miniatures are layed out
GtkWidget* okButton = nullptr;
GtkBox* vbox = nullptr; ///< Vertical GtkBox containing all.
Document* doc = nullptr;
/// Selection confirmed
bool confirmed = false;
/// Selected entry, none if npos
size_t selected = npos;
/// Entries to display
std::vector<std::unique_ptr<BaseElementView>> entries;
};
| 1,429
|
C++
|
.h
| 47
| 27.106383
| 119
| 0.72714
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,995
|
PdfElementView.h
|
xournalpp_xournalpp/src/core/gui/dialog/backgroundSelect/PdfElementView.h
|
/*
* Xournal++
*
* PDF view
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cairo.h> // for cairo_t
#include "pdf/base/XojPdfPage.h" // for XojPdfPageSPtr
#include "BaseElementView.h" // for BaseElementView
class PdfPagesDialog;
class PdfElementView: public BaseElementView {
public:
PdfElementView(size_t id, XojPdfPageSPtr page, PdfPagesDialog* dlg);
~PdfElementView() override;
protected:
/**
* Paint the contents (without border / selection)
*/
void paintContents(cairo_t* cr) override;
/**
* Get the width in pixel, without shadow / border
*/
int getContentWidth() override;
/**
* Get the height in pixel, without shadow / border
*/
int getContentHeight() override;
public:
bool isUsed() const;
void setUsed(bool used);
void setHideIfUsed(bool hideIfUsed);
private:
XojPdfPageSPtr page;
/**
* This page is already used as background
*/
bool used = false;
};
| 1,061
|
C++
|
.h
| 43
| 20.953488
| 72
| 0.688867
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,996
|
ImagesDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/backgroundSelect/ImagesDialog.h
|
/*
* Xournal++
*
* Dialog to select a Image (to insert as background)
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gtk/gtk.h> // for GtkButton, GtkWindow
#include "BackgroundSelectDialogBase.h" // for BackgroundSelectDialogBase
struct BackgroundImage;
class Document;
class GladeSearchpath;
class Settings;
class ImagesDialog final: public BackgroundSelectDialogBase {
public:
ImagesDialog(GladeSearchpath* gladeSearchPath, Document* doc, Settings* settings,
std::function<void(BackgroundImage)> callback);
~ImagesDialog();
private:
/**
* Load all images form all pages
*/
void loadImagesFromPages();
/**
* Check if this image is already displayed
*/
bool isImageAlreadyInTheList(BackgroundImage& image);
static void okButtonCallback(GtkButton* button, ImagesDialog* dlg);
static void filechooserButtonCallback(GtkButton* button, ImagesDialog* dlg);
private:
GtkButton* fileChooserButton = nullptr;
std::function<void(BackgroundImage)> callback;
};
| 1,128
|
C++
|
.h
| 37
| 26.891892
| 85
| 0.746531
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,997
|
PdfPagesDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/backgroundSelect/PdfPagesDialog.h
|
/*
* Xournal++
*
* Dialog to select a PDF page (to insert as background)
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gtk/gtk.h> // for GtkButton, GtkToggleButton
#include "BackgroundSelectDialogBase.h" // for BackgroundSelectDialogBase
class Document;
class GladeSearchpath;
class Settings;
class PdfPagesDialog final: public BackgroundSelectDialogBase {
public:
PdfPagesDialog(GladeSearchpath* gladeSearchPath, Document* doc, Settings* settings,
std::function<void(size_t)> callback);
~PdfPagesDialog();
public:
void updateOkButton();
static constexpr double ZOOM_VALUE = 0.25;
private:
static void onlyNotUsedCallback(GtkToggleButton* tb, PdfPagesDialog* dlg);
GtkCheckButton* cbUnusedOnly;
/// Takes parameter the pdf page number
std::function<void(size_t)> callback;
};
| 929
|
C++
|
.h
| 30
| 27.6
| 87
| 0.75
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,998
|
ToolbarDragDropHelper.h
|
xournalpp_xournalpp/src/core/gui/dialog/toolbarCustomize/ToolbarDragDropHelper.h
|
/*
* Xournal++
*
* Toolbar drag and drop helpers
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gdk/gdk.h> // for GdkAtom, GdkDragContext, _GdkAtom
#include <gtk/gtk.h> // for GtkWidget, GtkTargetEntry
namespace ToolbarDragDropHelper {
void dragDestAddToolbar(GtkWidget* target);
void dragSourceAddToolbar(GtkWidget* widget);
auto gdk_context_set_icon_from_image(GdkDragContext* ctx, GtkWidget* image) -> bool;
extern const GdkAtom atomToolItem;
extern const GtkTargetEntry dropTargetEntry;
}; // namespace ToolbarDragDropHelper
| 625
|
C++
|
.h
| 20
| 29.55
| 84
| 0.781667
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
12,999
|
ToolItemDragCurrentData.h
|
xournalpp_xournalpp/src/core/gui/dialog/toolbarCustomize/ToolItemDragCurrentData.h
|
/*
* Xournal++
*
* Toolbar drag & drop helper class
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory>
#include <gtk/gtk.h> // for GtkWidget
#include "gui/ToolitemDragDrop.h" // for ToolItemDragDropData (ptr only)
class AbstractToolItem;
struct NamedColor;
class ToolItemDragCurrentData {
private:
ToolItemDragCurrentData();
virtual ~ToolItemDragCurrentData();
public:
static void clearData();
static void setData(ToolItemDragDropData* d);
static void setData(ToolItemType type, int id, AbstractToolItem* item);
static void setData(GtkWidget* widget);
static void setDataColor(int id, size_t paletteColorIndex);
static const ToolItemDragDropData* getData();
private:
static std::unique_ptr<ToolItemDragDropData> data;
};
| 859
|
C++
|
.h
| 30
| 25.866667
| 75
| 0.760049
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,000
|
ToolbarAdapter.h
|
xournalpp_xournalpp/src/core/gui/dialog/toolbarCustomize/ToolbarAdapter.h
|
/*
* Xournal++
*
* Toolbar drag & drop helper class
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string> // for string
#include <gdk/gdk.h> // for GdkDragContext
#include <glib.h> // for gint, guint
#include <gtk/gtk.h> // for GtkWidget, GtkToolbar, GtkToolItem, GtkSelectio...
#include "gui/toolbarMenubar/model/ColorPalette.h"
class AbstractToolItem;
class MainWindow;
class ToolMenuHandler;
class ToolbarAdapter {
public:
ToolbarAdapter(GtkWidget* toolbar, std::string toolbarName, ToolMenuHandler* toolHandler, MainWindow* window);
~ToolbarAdapter();
private:
void cleanupToolbars();
void prepareToolItems();
void cleanToolItem(GtkToolItem* it);
void prepareToolItem(GtkToolItem* it);
void showToolbar();
private:
/**
* Drag a Toolitem from toolbar
*/
static void toolitemDragBegin(GtkWidget* widget, GdkDragContext* context, void* unused);
/**
* Drag a Toolitem from toolbar STOPPED
*/
static void toolitemDragEnd(GtkWidget* widget, GdkDragContext* context, void* unused);
/**
* Remove a toolbar item from the tool where it was
*/
void removeFromToolbar(AbstractToolItem* item, const std::string& toolbarName, int id);
static void toolitemDragDataGet(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selection_data,
guint info, guint time, ToolbarAdapter* adapter);
/**
* A tool item was dragged to the toolbar
*/
static bool toolbarDragMotionCb(GtkToolbar* toolbar, GdkDragContext* context, gint x, gint y, guint time,
ToolbarAdapter* adapter);
static void toolbarDragLeafeCb(GtkToolbar* toolbar, GdkDragContext* context, guint time, ToolbarAdapter* adapter);
static void toolbarDragDataReceivedCb(GtkToolbar* toolbar, GdkDragContext* context, gint x, gint y,
GtkSelectionData* data, guint info, guint time, ToolbarAdapter* adapter);
/**
* @brief Wrapper around gtk_toolbar_get_drop index with coorect coordinate handling
*
* @param toolbar the corresponding toolbar for the drop index
* @param x coordinate in toolbar coordinate system
* @param y coordinate in toolbar coordinate system
* @param horizontal denotes whether the toolbar is horizontal
* @return gint position at which drop item should be inserted
*/
static gint toolbarGetDropIndex(GtkToolbar* toolbar, gint x, gint y, bool horizontal);
private:
GtkWidget* w;
std::string toolbarName;
MainWindow* window;
Palette palette;
};
| 2,711
|
C++
|
.h
| 68
| 34.25
| 118
| 0.709285
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,001
|
ToolbarCustomizeDialog.h
|
xournalpp_xournalpp/src/core/gui/dialog/toolbarCustomize/ToolbarCustomizeDialog.h
|
/*
* Xournal++
*
* Toolbar edit dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <array>
#include <memory>
#include <vector>
#include <gdk/gdk.h> // for GdkDragContext
#include <glib.h> // for guint, gint
#include <gtk/gtk.h> // for GtkWidget, GtkSelectionData, GtkToolbar
#include "gui/toolbarMenubar/model/ColorPalette.h"
#include "util/raii/GtkWindowUPtr.h"
class AbstractToolItem;
struct Palette;
class MainWindow;
class ToolbarDragDropHandler;
class GladeSearchpath;
class ToolbarCustomizeDialog {
public:
ToolbarCustomizeDialog(GladeSearchpath* gladeSearchPath, MainWindow* win, ToolbarDragDropHandler* handler);
~ToolbarCustomizeDialog();
public:
inline GtkWindow* getWindow() const { return window.get(); }
void show(GtkWindow* parent);
private:
struct ToolItemDragData;
struct ColorToolItemDragData;
struct SeparatorData;
std::vector<ToolItemDragData> buildToolDataVector(const std::vector<std::unique_ptr<AbstractToolItem>>& tools);
std::vector<ColorToolItemDragData> buildColorDataVector(const Palette& palette);
// void rebuildIconview();
private:
static void dragDataReceived(GtkWidget* widget, GdkDragContext* dragContext, gint x, gint y, GtkSelectionData* data,
guint info, guint time, ToolbarCustomizeDialog* dlg);
static void toolbarDragLeafeCb(GtkToolbar* toolbar, GdkDragContext* context, guint time,
ToolbarCustomizeDialog* dlg);
static void toolbarDragDataReceivedCb(GtkToolbar* toolbar, GdkDragContext* context, gint x, gint y,
GtkSelectionData* data, guint info, guint time, ToolbarCustomizeDialog* dlg);
static void toolitemDragBegin(GtkWidget* widget, GdkDragContext* context, ToolItemDragData* data);
static void toolitemDragEnd(GtkWidget* widget, GdkDragContext* context, ToolItemDragData* data);
static void toolitemDragDataGet(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selection_data,
guint info, guint time, ToolItemDragData* data);
static void toolitemColorDragBegin(GtkWidget* widget, GdkDragContext* context, ColorToolItemDragData* data);
static void toolitemColorDragEnd(GtkWidget* widget, GdkDragContext* context, ColorToolItemDragData* data);
static void toolitemColorDragDataGet(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selection_data,
guint info, guint time, ColorToolItemDragData* data);
static void toolitemDragBeginSeparator(GtkWidget* widget, GdkDragContext* context, void* unused);
static void toolitemDragEndSeparator(GtkWidget* widget, GdkDragContext* context, void* unused);
static void toolitemDragDataGetSeparator(GtkWidget* widget, GdkDragContext* context,
GtkSelectionData* selection_data, guint info, guint time, void* unused);
// void freeIconview();
private:
/**
* @brief Stores the widget and other data associated to each drag-able toolbar item
* Modifications are not allowed to avoid vector reallocation and pointer invalidation
* (pointers are feed to g_signal's callback data)
*/
const std::vector<ToolItemDragData> itemData;
/**
* @brief Stores the widget and other data associated to each drag-able color item
*/
const std::vector<ColorToolItemDragData> colorItemData;
static std::array<SeparatorData, 2> separators;
xoj::util::GtkWindowUPtr window;
GtkNotebook* notebook;
Palette palette;
};
| 3,698
|
C++
|
.h
| 74
| 43.378378
| 120
| 0.734535
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,002
|
ToolbarDragDropHandler.h
|
xournalpp_xournalpp/src/core/gui/dialog/toolbarCustomize/ToolbarDragDropHandler.h
|
/*
* Xournal++
*
* Toolbar drag & drop controller
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory>
#include <vector>
class Control;
class ToolbarAdapter;
class ToolbarCustomizeDialog;
class ToolbarDragDropHandler {
public:
ToolbarDragDropHandler(Control* control);
virtual ~ToolbarDragDropHandler();
public:
void configure();
void toolbarConfigDialogClosed();
public:
void prepareToolbarsForDragAndDrop();
void clearToolbarsFromDragAndDrop();
inline Control* getControl() const { return control; }
private:
Control* control;
std::vector<std::unique_ptr<ToolbarAdapter>> toolbars;
std::unique_ptr<ToolbarCustomizeDialog> customizeDialog;
};
| 784
|
C++
|
.h
| 32
| 21.65625
| 60
| 0.765499
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,003
|
ToolPdfCombocontrol.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/ToolPdfCombocontrol.h
|
#pragma once
#include <string>
#include "ComboToolButton.h"
class IconNameHelper;
class ActionDatabase;
class ToolPdfCombocontrol: public ComboToolButton {
public:
ToolPdfCombocontrol(std::string id, IconNameHelper& icons, const ActionDatabase& db);
~ToolPdfCombocontrol() override = default;
};
| 308
|
C++
|
.h
| 10
| 28.6
| 89
| 0.812925
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,004
|
ToolPageLayer.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/ToolPageLayer.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string> // for string
#include <vector> // for vector
#include <gtk/gtk.h> // for GtkWidget, GtkToolItem
#include "control/layer/LayerCtrlListener.h" // for LayerCtrlListener
#include "model/Layer.h" // for Layer, Layer::Index
#include "util/raii/GObjectSPtr.h" // for WidgetSPtr
#include "AbstractToolItem.h" // for AbstractToolItem
class LayerController;
class IconNameHelper;
class ToolPageLayer: public AbstractToolItem {
public:
ToolPageLayer(std::string id, LayerController* lc, IconNameHelper iconNameHelper);
~ToolPageLayer() override;
public:
std::string getToolDisplayName() const override;
xoj::util::WidgetSPtr createItem(bool horizontal) override;
GtkWidget* getNewToolIcon() const override;
private:
LayerController* lc = nullptr;
std::string iconName;
};
| 1,047
|
C++
|
.h
| 32
| 30.25
| 86
| 0.724378
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,005
|
ColorToolItem.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/ColorToolItem.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gtk/gtk.h> // for GtkWidget
#include "gui/toolbarMenubar/model/ColorPalette.h"
#include "util/Color.h" // for Color
#include "util/NamedColor.h" // for NamedColor
#include "AbstractToolItem.h" // for AbstractToolItem
class ActionDatabase;
class ColorToolItem: public AbstractToolItem {
public:
ColorToolItem(NamedColor namedColor);
ColorToolItem(ColorToolItem const&) = delete;
ColorToolItem(ColorToolItem&&) noexcept = delete;
auto operator=(ColorToolItem const&) -> ColorToolItem& = delete;
auto operator=(ColorToolItem&&) noexcept -> ColorToolItem& = delete;
~ColorToolItem() override;
public:
std::string getToolDisplayName() const override;
GtkWidget* getNewToolIcon() const override;
Color getColor() const;
/**
* @brief Update Color based on (new) palette
*
* @param palette
*/
void updateColor(const Palette& palette);
xoj::util::WidgetSPtr createItem(bool horizontal) override;
private:
NamedColor namedColor;
xoj::util::GVariantSPtr target; ///< Contains the color in ARGB as a uint32_t
};
| 1,286
|
C++
|
.h
| 40
| 28.725
| 82
| 0.726904
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,006
|
PluginToolButton.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/PluginToolButton.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string> // for string, allocator
#include <gtk/gtk.h> // for GtkWidget, GtkToolItem
#include "AbstractToolItem.h" // for AbstractToolItem
struct ToolbarButtonEntry;
class PluginToolButton: public AbstractToolItem {
public:
PluginToolButton(ToolbarButtonEntry* t);
~PluginToolButton() override;
std::string getToolDisplayName() const override;
protected:
xoj::util::WidgetSPtr createItem(bool horizontal) override;
GtkWidget* getNewToolIcon() const override;
private:
ToolbarButtonEntry* t;
};
| 717
|
C++
|
.h
| 26
| 24.961538
| 63
| 0.762463
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,007
|
ToolButton.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/ToolButton.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory>
#include <string> // for string, allocator
#include <gtk/gtk.h> // for GtkWidget
#include "enums/Action.enum.h" // for Action
#include "gui/PopoverFactory.h"
#include "util/raii/GVariantSPtr.h"
#include "AbstractToolItem.h" // for AbstractToolItem
class ToolButton: public AbstractToolItem {
public:
ToolButton(std::string id, Category cat, Action action, std::string iconName, std::string description, bool toggle);
ToolButton(std::string id, Category cat, Action action, GVariant* target, std::string iconName,
std::string description);
~ToolButton() override = default;
public:
std::string getToolDisplayName() const override;
void setPopoverFactory(const PopoverFactory* factory);
protected:
xoj::util::WidgetSPtr createItem(bool horizontal) override;
GtkWidget* getNewToolIcon() const override;
protected:
std::string iconName;
std::string description;
/// @brief If set, a MenuButton is added with this popover
const PopoverFactory* popoverFactory = nullptr;
Action action;
/// @brief If set, the action target value the button corresponds to
xoj::util::GVariantSPtr target;
/// @brief Whether or not the button is a ToggleButton.
bool toggle;
};
| 1,443
|
C++
|
.h
| 41
| 31.780488
| 120
| 0.73688
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,008
|
SliderItemCreationHelper.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/SliderItemCreationHelper.h
|
/*
* Xournal++
*
* Abstract representation of slider-based tools.
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string> // for string
#include <gtk/gtk.h> // for GtkRange
#include "control/actions/ActionRef.h"
#include "util/GVariantTemplate.h" // for makeGVariant
#include "util/GtkUtil.h" // for setWidgetFollowActionEnabled
#include "util/glib_casts.h" // for wrap_for_g_callback_v
#include "util/gtk4_helper.h" // for gtk_scale_set_format_value_func
#include "AbstractSliderItem.h"
/**
* @brief Helper function. We rely on a template to avoid adding a vtable to every callback data
*/
template <class FinalSliderType>
class SliderItemCreationHelper {
public:
static void valueChangedCb(GtkRange* slider, gpointer gAction) {
double state = FinalSliderType::scaleInverseFunction(gtk_range_get_value(slider));
g_action_change_state(G_ACTION(gAction), makeGVariant(state));
}
static xoj::util::WidgetSPtr createItem(AbstractSliderItem* self, bool horizontal) {
GtkOrientation orientation = horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
const double min = FinalSliderType::scaleFunction(self->range.min);
const double max = FinalSliderType::scaleFunction(self->range.max);
const double fineStepSize = (max - min) / self->range.nbFineSteps;
const double coarseStepSize = (max - min) / self->range.nbCoarseSteps;
GtkRange* slider = GTK_RANGE(gtk_scale_new_with_range(orientation, min, max, fineStepSize));
gtk_range_set_increments(slider, fineStepSize, coarseStepSize);
if (horizontal) {
gtk_widget_set_size_request(GTK_WIDGET(slider), 120, 16);
} else {
gtk_widget_set_size_request(GTK_WIDGET(slider), 16, 120);
}
gtk_widget_set_can_focus(GTK_WIDGET(slider), false); // todo(gtk4) not necessary anymore
// gAction does not own the return GVariant and it is not floating either!
xoj::util::GVariantSPtr state(g_action_get_state(G_ACTION(self->gAction.get())), xoj::util::adopt);
gtk_range_set_value(slider, FinalSliderType::scaleFunction(getGVariantValue<double>(state.get())));
g_signal_connect_object(slider, "value-changed", G_CALLBACK(valueChangedCb), self->gAction.get(),
GConnectFlags(0));
g_signal_connect_object(
self->gAction.get(), "notify::state", G_CALLBACK(+[](GObject* action, GParamSpec*, gpointer slider) {
// action does not own the return GVariant and it is not floating either!
xoj::util::GVariantSPtr state(g_action_get_state(G_ACTION(action)), xoj::util::adopt);
xoj_assert(state);
g_signal_handlers_block_by_func(slider, (gpointer)valueChangedCb, action);
gtk_range_set_value(GTK_RANGE(slider),
FinalSliderType::scaleFunction(getGVariantValue<double>(state.get())));
g_signal_handlers_unblock_by_func(slider, (gpointer)valueChangedCb, action);
}),
slider, GConnectFlags(0));
xoj::util::gtk::setWidgetFollowActionEnabled(GTK_WIDGET(slider), G_ACTION(self->gAction.get()));
if constexpr (FinalSliderType::DISPLAY_VALUE) {
gtk_scale_set_draw_value(GTK_SCALE(slider), true);
gtk_scale_set_format_value_func(
GTK_SCALE(slider),
+[](GtkScale*, double value, gpointer) -> char* {
return g_strdup(FinalSliderType::formatSliderValue(value).c_str());
},
nullptr, nullptr);
}
return xoj::util::WidgetSPtr(GTK_WIDGET(slider), xoj::util::adopt);
}
};
| 3,897
|
C++
|
.h
| 72
| 44.638889
| 117
| 0.648989
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,009
|
AbstractToolItem.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/AbstractToolItem.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string> // for string
#include <vector>
#include <gtk/gtk.h> // for GtkWidget
#include "enums/Action.enum.h"
#include "util/raii/GObjectSPtr.h"
#include "util/raii/GVariantSPtr.h"
class AbstractToolItem {
public:
// If you add a category, don't forget to give it a label in ToolbarCustomizeDialog.cpp.
// Keep the enum contiguous
enum class Category : unsigned char {
FILES,
TOOLS,
COLORS,
NAVIGATION,
MISC,
SELECTION,
AUDIO,
SEPARATORS,
PLUGINS,
ENUMERATOR_COUNT // Keep last
};
AbstractToolItem(std::string id, Category cat);
virtual ~AbstractToolItem();
AbstractToolItem(AbstractToolItem const&) = delete;
auto operator=(AbstractToolItem const&) -> AbstractToolItem& = delete;
AbstractToolItem(AbstractToolItem&&) = delete; // Implement if desired
auto operator=(AbstractToolItem&&) -> AbstractToolItem& = delete; // Implement if desired
public:
virtual xoj::util::WidgetSPtr createItem(bool horizontal) = 0;
xoj::util::WidgetSPtr createToolItem(bool horizontal);
const std::string& getId() const;
Category getCategory() const;
virtual std::string getToolDisplayName() const = 0;
/**
* Returns: (transfer floating)
*/
virtual GtkWidget* getNewToolIcon() const = 0;
protected:
std::string id;
const Category category;
};
| 1,612
|
C++
|
.h
| 53
| 25.90566
| 94
| 0.682171
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,010
|
ToolMenuHandler.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/ToolMenuHandler.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <memory> // for unique_ptr
#include <optional> // for optional
#include <string> // for string
#include <vector> // for vector
#include <gio/gio.h>
#include <glib-object.h> // for GObject, GConnectFlags
#include <glib.h> // for gchar
#include <gtk/gtk.h> // for GtkWidget, GtkWindow, GtkBuilder
#include "gui/IconNameHelper.h" // for IconNameHelper
#include "util/raii/GObjectSPtr.h"
class AbstractToolItem;
class GladeGui;
class GladeSearchpath;
class ToolbarData;
class ToolbarModel;
class ToolButton;
class ToolHandler;
class ToolPageLayer;
class ToolPageSpinner;
class PageTypeMenu;
class SpinPageAdapter;
class ZoomControl;
class Control;
class PageBackgroundChangeController;
class ColorToolItem;
struct ToolbarButtonEntry;
class PageTypeSelectionPopover;
class PageType;
struct Palette;
class StylePopoverFactory;
class ToolMenuHandler {
public:
ToolMenuHandler(Control* control, GladeGui* gui);
virtual ~ToolMenuHandler();
void populate(const GladeSearchpath* gladeSearchPath);
public:
void freeDynamicToolbarItems();
static void unloadToolbar(GtkWidget* toolbar);
/**
* @brief Load the toolbar.ini file
* This file persists the customized toolbars and is loaded upon starting the application.
*
* @param d Data Object representing the selected toolbars (e.g Portrait)
* @param toolbar reference to the widget representing the toolbar
* @param toolbarName toolbarName which should be read from the file
* @param horizontal whether the toolbar is horizontal
*/
void load(const ToolbarData* d, GtkWidget* toolbar, const char* toolbarName, bool horizontal);
/**
* @brief Update all ColorToolItems based on palette
*
* @param palette
*/
void updateColorToolItems(const Palette& palette);
void initToolItems();
void addPluginItem(ToolbarButtonEntry* t);
void setPageInfo(size_t currentPage, size_t pageCount, size_t pdfpage);
[[maybe_unused]] void removeColorToolItem(AbstractToolItem* it);
void addColorToolItem(std::unique_ptr<ColorToolItem> it);
ToolbarModel* getModel();
const std::vector<std::unique_ptr<AbstractToolItem>>& getToolItems() const;
const std::vector<std::unique_ptr<ColorToolItem>>& getColorToolItems() const;
Control* getControl();
void hideAudioMenuItems();
std::string iconName(const char* icon);
void setDefaultNewPageType(const std::optional<PageType>& pt);
private:
template <class tool_item, class... Args>
tool_item& emplaceItem(Args&&... args);
void initPenToolItem();
void initEraserToolItem();
private:
std::vector<std::unique_ptr<ColorToolItem>> toolbarColorItems;
GtkWindow* parent = nullptr;
std::vector<std::unique_ptr<AbstractToolItem>> toolItems;
ToolPageSpinner* toolPageSpinner = nullptr;
Control* control = nullptr;
ZoomControl* zoom = nullptr;
GladeGui* gui = nullptr;
ToolHandler* toolHandler = nullptr;
std::unique_ptr<ToolbarModel> tbModel;
PageTypeMenu* newPageType = nullptr;
PageBackgroundChangeController* pageBackgroundChangeController = nullptr;
IconNameHelper iconNameHelper;
std::unique_ptr<PageTypeSelectionPopover> pageTypeSelectionPopup;
std::unique_ptr<StylePopoverFactory> penLineStylePopover;
std::unique_ptr<StylePopoverFactory> eraserTypePopover;
xoj::util::GObjectSPtr<GSimpleAction> gAction;
};
| 3,659
|
C++
|
.h
| 101
| 32.633663
| 98
| 0.755455
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,011
|
AbstractSliderItem.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/AbstractSliderItem.h
|
/*
* Xournal++
*
* Abstract representation of slider-based tools.
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory> // for unique_ptr
#include <string> // for string
#include <gtk/gtk.h> // for GtkToolItem, GtkRange
#include "control/actions/ActionRef.h"
#include "AbstractToolItem.h" // for AbstractToolItem
class AbstractSliderItem: public AbstractToolItem {
public:
struct SliderRange {
// Internal units: minimum and maximum slider values.
double min;
double max;
// Number of fine/coarse steps between min and max.
int nbFineSteps;
int nbCoarseSteps;
};
public:
/**
* @param id Unique identifier for this. e.g. `TOOL_FOO_SLIDER`.
* @param range The minimum/maximum/step in internal units. {@see #scaleFunc}.
* @param gAction A GAction whose (double) state is synced with the slider's value
*/
AbstractSliderItem(std::string id, Category cat, SliderRange range, ActionRef gAction);
~AbstractSliderItem() override = default;
protected:
SliderRange range;
ActionRef gAction;
template <class FinalSliderType>
friend class SliderItemCreationHelper;
};
| 1,263
|
C++
|
.h
| 40
| 27.5
| 91
| 0.711459
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,012
|
FontButton.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/FontButton.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string> // for string
#include <gtk/gtk.h> // for GtkWidget
#include "control/actions/ActionRef.h"
#include "AbstractToolItem.h"
class ActionDatabase;
class FontButton: public AbstractToolItem {
public:
FontButton(std::string id, ActionDatabase& db);
~FontButton() override = default;
public:
GtkWidget* getNewToolIcon() const override;
std::string getToolDisplayName() const override;
xoj::util::WidgetSPtr createItem(bool horizontal) override;
private:
ActionRef gAction; ///< Points to the GAction corresponding to Action::FONT
};
| 759
|
C++
|
.h
| 27
| 25.518519
| 80
| 0.749307
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,013
|
ComboToolButton.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/ComboToolButton.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include "control/actions/ActionRef.h"
#include "util/raii/GObjectSPtr.h" // for WidgetSPtr
#include "AbstractToolItem.h" // for AbstractToolItem
class ActionDatabase;
class ComboToolButton: public AbstractToolItem {
public:
struct Entry {
template <typename T>
Entry(std::string name, std::string icon, T t):
name(std::move(name)), icon(std::move(icon)), target(xoj::util::makeGVariantSPtr<T>(t)) {}
std::string name;
std::string icon;
xoj::util::GVariantSPtr target; /// Target value of the associated GSimpleAction corresponding to the entry
};
/**
* @brief When all entries correspond to a single action (but different target values)
* @param iconName Icon used in the toolbar customization dialog to represent this combo button.
* @param description Description used in the toolbar customization dialog to explain this combo button.
* @param entries Entries of the combo menu.
*/
ComboToolButton(std::string id, Category cat, std::string iconName, std::string description,
std::vector<Entry> entries, ActionRef gAction);
~ComboToolButton() override = default;
public:
std::string getToolDisplayName() const override;
protected:
xoj::util::WidgetSPtr createItem(bool horizontal) override;
GtkWidget* getNewToolIcon() const override;
protected:
const std::vector<Entry> entries;
ActionRef gAction;
std::string iconName;
std::string description;
};
| 1,789
|
C++
|
.h
| 50
| 31.38
| 116
| 0.714534
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,014
|
ToolZoomSlider.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/ToolZoomSlider.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory> // for unique_ptr
#include <string> // for string
#include <gdk-pixbuf/gdk-pixbuf.h> // for GdkPixbuf
#include <gtk/gtk.h> // for GtkRange, GtkWidget
#include "control/zoom/ZoomListener.h" // for ZoomListener
#include "gui/IconNameHelper.h" // for IconNameHelper
#include "AbstractSliderItem.h" // for NewAbstractSliderItem
class ZoomControl;
class ActionDatabase;
class ToolZoomSlider: public AbstractSliderItem {
public:
ToolZoomSlider(std::string id, ZoomControl* zoom, IconNameHelper iconNameHelper, ActionDatabase& db);
~ToolZoomSlider() override = default;
xoj::util::WidgetSPtr createItem(bool horizontal) override;
protected:
static constexpr bool DISPLAY_VALUE = true;
static std::string formatSliderValue(double value);
std::string getToolDisplayName() const override;
protected:
GtkWidget* getNewToolIcon() const override;
protected:
/**
* @brief Function to convert from the GAction's state value to the slider's position. (e.g. for log scaling)
*/
static double scaleFunction(double x);
/**
* @brief Function to convert from the slider's position to the GAction's state value. (e.g. for log scaling)
*/
static double scaleInverseFunction(double x);
protected:
std::string iconName;
ZoomControl* zoomCtrl;
template <class FinalSliderType>
friend class SliderItemCreationHelper;
};
| 1,612
|
C++
|
.h
| 46
| 31.782609
| 113
| 0.737589
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,015
|
ToolSelectCombocontrol.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/ToolSelectCombocontrol.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string>
#include "ComboToolButton.h"
class IconNameHelper;
class ActionDatabase;
class ToolSelectCombocontrol: public ComboToolButton {
public:
ToolSelectCombocontrol(std::string id, IconNameHelper& icons, const ActionDatabase& db, bool hideAudio);
~ToolSelectCombocontrol() override = default;
};
| 498
|
C++
|
.h
| 20
| 22.85
| 108
| 0.776371
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,016
|
StylePopoverFactory.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/StylePopoverFactory.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string> // for string, allocator
#include <vector>
#include <gtk/gtk.h> // for GtkWidget
#include "enums/Action.enum.h" // for Action
#include "gui/PopoverFactory.h"
#include "util/raii/GVariantSPtr.h"
class StylePopoverFactory final: public PopoverFactory {
public:
struct Entry {
template <typename T>
Entry(std::string name, std::string icon, T t):
name(std::move(name)), icon(std::move(icon)), target(xoj::util::makeGVariantSPtr<T>(t)) {}
template <typename T>
Entry(std::string name, T t): name(std::move(name)), target(xoj::util::makeGVariantSPtr<T>(t)) {}
std::string name;
std::string icon;
xoj::util::GVariantSPtr target; /// Target value of the associated GSimpleAction corresponding to the entry
};
/// @param styleAction The action activated when an entry in the popover is clicked
StylePopoverFactory(Action styleAction, std::vector<Entry> entries);
~StylePopoverFactory() override = default;
GtkWidget* createPopover() const override;
private:
std::vector<Entry> entries;
/// The action activated when an entry in the popover is clicked
Action styleAction;
};
| 1,382
|
C++
|
.h
| 38
| 32.078947
| 116
| 0.697605
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,017
|
DrawingTypeComboToolButton.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/DrawingTypeComboToolButton.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory>
#include <string>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include "control/actions/ActionRef.h"
#include "enums/Action.enum.h" // for Action
#include "util/EnumIndexedArray.h"
#include "util/raii/GObjectSPtr.h" // for WidgetSPtr
#include "AbstractToolItem.h" // for AbstractToolItem
class ActionDatabase;
class IconNameHelper;
class DrawingTypeComboToolButton: public AbstractToolItem {
public:
struct Entry {
Entry() = default;
Entry(std::string name, std::string icon, const ActionDatabase& db, Action a);
std::string name;
std::string icon;
ActionRef gAction;
std::string fullActionName;
};
DrawingTypeComboToolButton(std::string id, IconNameHelper& icons, const ActionDatabase& db);
~DrawingTypeComboToolButton() override;
public:
std::string getToolDisplayName() const override;
enum class Type : size_t {
RECTANGLE,
ELLIPSE,
ARROW,
DOUBLE_ARROW,
LINE,
COORDINATE_SYSTEM,
SPLINE,
SHAPE_RECOGNIZER,
ENUMERATOR_COUNT
};
protected:
xoj::util::WidgetSPtr createItem(bool horizontal) override;
GtkWidget* getNewToolIcon() const override;
private:
template <Type s>
static void setProminentIconCallback(GObject* action, GParamSpec*, DrawingTypeComboToolButton* self);
protected:
std::shared_ptr<const EnumIndexedArray<Entry, Type>> entries;
std::string iconName;
std::string description;
};
| 1,682
|
C++
|
.h
| 58
| 24.568966
| 105
| 0.713043
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,018
|
ToolPageSpinner.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/ToolPageSpinner.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <cstddef> // for size_t
#include <memory> // for unique_ptr
#include <string> // for string
#include <gdk-pixbuf/gdk-pixbuf.h> // for GdkPixbuf
#include <gtk/gtk.h> // for GtkWidget, GtkToolItem, GTK_ORIEN...
#include "gui/IconNameHelper.h" // for IconNameHelper
#include "util/raii/GObjectSPtr.h" // for WidgetSPtr
#include "AbstractToolItem.h" // for AbstractToolItem
class SpinPageListener;
class ToolPageSpinner: public AbstractToolItem {
public:
ToolPageSpinner(std::string id, IconNameHelper iconNameHelper, SpinPageListener* listener);
~ToolPageSpinner() override;
public:
/// Propagates the info to all instances of the Page Spinner
void setPageInfo(size_t currentPage, size_t pageCount, size_t pdfPage);
std::string getToolDisplayName() const override;
xoj::util::WidgetSPtr createItem(bool horizontal) override;
inline SpinPageListener* getListener() const { return listener; }
protected:
GtkWidget* getNewToolIcon() const override;
private:
IconNameHelper iconNameHelper;
SpinPageListener* listener;
class Instance;
std::vector<Instance*> instances;
};
| 1,338
|
C++
|
.h
| 38
| 32.394737
| 95
| 0.743789
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,019
|
ColorSelectorToolItem.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/ColorSelectorToolItem.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string> // for string
#include <gtk/gtk.h> // for GtkWindget
#include "control/actions/ActionRef.h"
#include "AbstractToolItem.h" // for AbstractToolItem
class ActionDatabase;
class ColorSelectorToolItem: public AbstractToolItem {
public:
ColorSelectorToolItem(ActionDatabase& db);
ColorSelectorToolItem(ColorSelectorToolItem const&) = delete;
ColorSelectorToolItem(ColorSelectorToolItem&&) noexcept = delete;
auto operator=(ColorSelectorToolItem const&) -> ColorSelectorToolItem& = delete;
auto operator=(ColorSelectorToolItem&&) noexcept -> ColorSelectorToolItem& = delete;
~ColorSelectorToolItem() override = default;
public:
std::string getToolDisplayName() const override;
GtkWidget* getNewToolIcon() const override;
xoj::util::WidgetSPtr createItem(bool horizontal) override;
private:
ActionRef gAction; ///< Corresponds to Action::TOOL_COLOR
};
| 1,094
|
C++
|
.h
| 31
| 32.387097
| 88
| 0.769231
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,020
|
TooltipToolButton.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/TooltipToolButton.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <functional>
#include <string> // for string, allocator
#include <gtk/gtk.h> // for GtkWidget
#include "enums/Action.enum.h" // for Action
#include "gui/PopoverFactory.h"
#include "util/raii/GVariantSPtr.h"
#include "ToolButton.h"
/// ToolButton with dynamic tooltip description (overrides the GtkWidget::query-tooltip signal handler)
class TooltipToolButton: public ToolButton {
public:
TooltipToolButton(std::string id, Category cat, Action action, std::string iconName, std::string description,
std::function<std::string()> fetchTooltip);
~TooltipToolButton() override = default;
xoj::util::WidgetSPtr createItem(bool horizontal) override;
private:
std::function<std::string()> fetchTooltip;
};
| 934
|
C++
|
.h
| 28
| 30.392857
| 113
| 0.738307
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,021
|
ColorPalette.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/model/ColorPalette.h
|
#pragma once
#include <cstddef> // for size_t
#include <exception> // for exception
#include <iosfwd> // for istream
#include <map> // for map
#include <string> // for string, basic_string
#include <vector> // for vector
#include "util/NamedColor.h" // for NamedColor
#include "filesystem.h" // for path
/**
* @brief Header entity of a gpl file
* This is simply a key value pair. The main reason to define a struct for this is to define a custom input operator.
*
*/
struct Header {
/**
* @brief Input operator for parsing Header from input string stream
*
* @param str input string stream
* @param header output for parsed Header
* @return std::istream& which is the rest of the input string stream after parsing
*/
friend std::istream& operator>>(std::istream& str, Header& header);
std::string getAttribute() const;
std::string getValue() const;
private:
/**
* @brief Attribute name given in gpl file
*
*/
std::string attribute;
/**
* @brief Value for corresponding attribute in gpl file
*
*/
std::string value;
/**
* @brief Swap all properties between two Header instances
*
* @param other other Header instance to swap properties with
*/
void swap(Header& other);
};
/**
* @brief ColorPalette coming from a parsed gpl file
*
*/
struct Palette {
/**
* @brief Construct a new Palette
* This does not yet parse the file. It simply sets up the class.
*
* @param path to the gpl file
*/
Palette(fs::path path);
/**
* @brief Create default gpl file string
* Default xournalpp color scheme
* 0 0 0 Black
* 0 128 0 Green
* 0 192 255 Light Blue
* 0 255 0 Light Green
* 51 51 204 Blue
* 128 128 128 Gray
* 255 0 0 Red
* 255 0 255 Magenta
* 255 128 0 Orange
* 255 255 0 Yellow
* 255 255 255 White
*
* @return const std::string
*/
static const std::string default_palette();
/**
* @brief Create a default gpl file for the xournalpp color scheme
* See default_palette() for further information.
*
* @param path to write gpl file to
*/
static void create_default(fs::path path);
/**
* @brief Parse the gpl file in filepath
* This fills the header map and the namedColors vector after clearing them first
*
* @throw exception in case of wrong formatted file
*
*/
void load();
/**
* @brief Load the default Palette
*
*/
void load_default();
/**
* @brief Show a Dialog with only an OK button
*
* @param message to be displayed in the dialog
*/
void parseErrorDialog(const std::exception& e) const;
/**
* @brief Get the number of namedColors part of the palette
*
* @return size_t number of namedColors in palette
*/
size_t size() const;
/**
* @brief Get a NamedColor from the palette
*
* @param i palette index
* @return NamedColor of palette at palette index
*/
NamedColor const& getColorAt(size_t i) const;
fs::path const& getFilePath() const;
std::string getHeader(const std::string& attr) const;
private:
/**
* @brief filepath to the gpl file the palette is coming from
*
*/
fs::path filepath;
/**
* @brief Vector containing all colors of the palette
*
*/
std::vector<NamedColor> namedColors;
/**
* @brief Map containing the key value pairs of the gpl header
* e.g. "Palette Name", "Description"
*
*/
std::map<std::string, std::string> header;
/**
* @brief Verify if line contains the expected "GIMP Palette" string
*
* @param line first line of gpl file
* @return true if line is "GIMP Palette"
* @return false otherwise
*/
bool parseFirstGimpPaletteLine(const std::string& line) const;
/**
* @brief Try to parse a color and add it to namedColors
*
*
* @param line line of gpl file
* @return true if line is of form "255 255 255 White" (r g b name)
* @return false otherwise
*/
bool parseColorLine(const std::string& line);
/**
* @brief Try to parse a header key value pair and add it to header
*
* @param line line of gpl file
* @return true if line is of form "key:value"
* @return false otherwise
*/
bool parseHeaderLine(const std::string& line);
/**
* @brief Parse a Comment line
* Every line starting with "#" will be considered a comment
*
* @param line
* @return true if line starts with "#"
* @return false else
*/
bool parseCommentLine(const std::string& line) const;
/**
* @brief Parse an empty line
* Empty lines do not contain any characters and are ignored
*
* @param line
* @return true if line is empty
* @return false otherwise
*/
bool parseEmptyLine(const std::string& line) const;
/**
* @brief Fallback for line parsing
* This function is the fallback in case no other parsing attempt works.
* In this case this function throws an error containing the non-parseable line number
*
* This should be used in the following way
*
* firstLineParseAttempt(line) || secondLineParseAttempt(line) || parseLineFallback(lineNumber)
*
* @param lineNumber of the erroneous line
* @return nothing as it always throws an error
* @throw invalid_argument exception if not a comment
*/
const bool parseLineFallback(int lineNumber) const;
};
| 5,698
|
C++
|
.h
| 189
| 24.84127
| 117
| 0.63638
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,022
|
ToolbarItem.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/model/ToolbarItem.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string> // for string
class ToolbarItem {
public:
ToolbarItem(std::string name);
ToolbarItem() = default;
public:
std::string getName() const;
void setName(std::string name);
bool operator==(ToolbarItem& other);
int getId() const;
private:
/**
* @brief This is the name of the ToolbarItem
* This is also what is stored in the toolbar.ini verbatim.
*
*/
std::string name;
int id;
static int sid;
};
| 656
|
C++
|
.h
| 31
| 17.645161
| 63
| 0.667208
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,023
|
ToolbarEntry.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/model/ToolbarEntry.h
|
/*
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string> // for string
#include <vector> // for vector
class ToolbarItem;
typedef std::vector<ToolbarItem> ToolbarItemVector;
class ToolbarEntry {
public:
ToolbarEntry();
ToolbarEntry(const ToolbarEntry& e);
ToolbarEntry(ToolbarEntry&& e);
~ToolbarEntry();
ToolbarEntry& operator=(const ToolbarEntry& e);
ToolbarEntry& operator=(ToolbarEntry&& e);
public:
std::string getName() const;
void setName(std::string name);
/**
* Adds a new item and return the ID of the item
*/
int addItem(std::string item);
bool removeItemById(int id);
/**
* Insert a new item and return the ID of the item
*/
int insertItem(std::string item, int position);
const ToolbarItemVector& getItems() const;
private:
std::string name;
ToolbarItemVector entries;
};
| 1,021
|
C++
|
.h
| 40
| 21.925
| 54
| 0.7
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,024
|
ToolbarData.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/model/ToolbarData.h
|
/*
* Xournal++
*
* Toolbar definitions model
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <string> // for string
#include <vector> // for vector
#include <glib.h> // for GKeyFile
class ToolbarEntry;
struct Palette;
class ToolbarData {
public:
ToolbarData(bool predefined);
ToolbarData(const ToolbarData& data);
virtual ~ToolbarData();
void operator=(const ToolbarData& other);
public:
const std::string& getName() const;
void setName(std::string name);
const std::string& getId() const;
void setId(std::string id);
bool isPredefined() const;
void load(GKeyFile* config, const char* group, const Palette& colorPalette);
void saveToKeyFile(GKeyFile* config) const;
// Editing API
int insertItem(const std::string& toolbar, const std::string& item, int position);
bool removeItemByID(const std::string& toolbar, int id);
private:
std::string id;
std::string name;
std::vector<ToolbarEntry> contents;
bool predefined = false;
friend class ToolbarModel;
friend class ToolMenuHandler;
};
| 1,166
|
C++
|
.h
| 41
| 24.97561
| 86
| 0.71788
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,025
|
ToolbarModel.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/model/ToolbarModel.h
|
/*
* Xournal++
*
* Toolbar definitions model
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <glib.h>
#include "filesystem.h"
class ToolbarData;
struct Palette;
class ToolbarModel {
public:
ToolbarModel();
virtual ~ToolbarModel();
private:
ToolbarModel(const ToolbarModel& other);
void operator=(const ToolbarModel& other);
public:
const std::vector<std::unique_ptr<ToolbarData>>& getToolbars() const;
bool parse(fs::path const& filepath, bool predefined, const Palette& colorPalette);
ToolbarData* add(std::unique_ptr<ToolbarData> data);
void remove(ToolbarData* data);
void save(const fs::path& filepath) const;
bool existsId(const std::string& id) const;
void initCopyNameId(ToolbarData* data);
private:
void parseGroup(GKeyFile* config, const char* group, bool predefined, const Palette& colorPalette);
private:
std::vector<std::unique_ptr<ToolbarData>> toolbars;
};
| 1,073
|
C++
|
.h
| 38
| 25.368421
| 103
| 0.742439
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,026
|
ColorIcon.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/icon/ColorIcon.h
|
/*
* Xournal++
*
* Icon for color buttons
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gdk-pixbuf/gdk-pixbuf.h> // for GdkPixbuf
#include <gtk/gtk.h> // for GtkWidget
#include "util/Color.h" // for Color
#include "util/raii/GObjectSPtr.h"
namespace ColorIcon {
/**
* @brief Create a new GtkImage with preview color
* @return The pointer is a floating ref
*/
GtkWidget* newGtkImage(Color color, int size = 22, bool circle = true);
/**
* @brief Create a new GdkPixbuf* with preview color
*/
xoj::util::GObjectSPtr<GdkPixbuf> newGdkPixbuf(Color color, int size = 22, bool circle = true);
}; // namespace ColorIcon
| 729
|
C++
|
.h
| 26
| 26.307692
| 95
| 0.706304
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,027
|
ToolbarSeparatorImage.h
|
xournalpp_xournalpp/src/core/gui/toolbarMenubar/icon/ToolbarSeparatorImage.h
|
/*
* Xournal++
*
* Toolbar icon for separator (only used for drag and drop and so)
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gdk-pixbuf/gdk-pixbuf.h> // for GdkPixbuf
#include <gtk/gtk.h> // for GtkWidget
enum SeparatorType { SEPARATOR, SPACER };
/**
* Menuitem handler
*/
namespace ToolbarSeparatorImage {
/**
* @brief Create Seperator Widget
* This is used in the toolbar for spacing between items.
*
* @return GtkWidget* Separator
*/
GtkWidget* newImage(SeparatorType separator);
/**
* @brief Create Separator Pixbuf
* This is used in the toolbar customization to drag the separator
* from the Customization dialog to the toolbar and vice versa.
*
* @return GdkPixbuf* Seperator
*/
GdkPixbuf* getNewToolPixbuf(SeparatorType separator);
}; // namespace ToolbarSeparatorImage
| 906
|
C++
|
.h
| 34
| 24.823529
| 66
| 0.741339
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,028
|
ScrollHandling.h
|
xournalpp_xournalpp/src/core/gui/scroll/ScrollHandling.h
|
/*
* Xournal++
*
* Scroll handling for different scroll implementations
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gtk/gtk.h> // for GtkAdjustment, GtkWidget, GtkScrollable
class Layout;
class ScrollHandling {
public:
ScrollHandling(GtkAdjustment* adjHorizontal, GtkAdjustment* adjVertical);
ScrollHandling(GtkScrollable* scrollable);
~ScrollHandling();
public:
GtkAdjustment* getHorizontal();
GtkAdjustment* getVertical();
void init(GtkWidget* xournal, Layout* layout);
void setLayoutSize(int width, int height);
private:
protected:
GtkAdjustment* adjHorizontal = nullptr;
GtkAdjustment* adjVertical = nullptr;
GtkWidget* xournal = nullptr;
Layout* layout = nullptr;
};
| 817
|
C++
|
.h
| 30
| 24.166667
| 77
| 0.753213
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,029
|
TouchInputHandler.h
|
xournalpp_xournalpp/src/core/gui/inputdevices/TouchInputHandler.h
|
/*
* Xournal++
*
* Handle touchscreen zooming and panning.
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gdk/gdk.h> // for GdkEventSequence
#include "util/Point.h" // for Point
#include "AbstractInputHandler.h" // for AbstractInputHandler
class InputContext;
struct InputEvent;
class TouchInputHandler: public AbstractInputHandler {
private:
GdkEventSequence* primarySequence{};
GdkEventSequence* secondarySequence{};
double startZoomDistance = 0.0;
xoj::util::Point<double> lastZoomScrollCenter{};
xoj::util::Point<double> priLastAbs{-1.0, -1.0};
xoj::util::Point<double> secLastAbs{-1.0, -1.0};
xoj::util::Point<double> priLastRel{-1.0, -1.0};
xoj::util::Point<double> secLastRel{-1.0, -1.0};
// True, if a zoom sequence may be started by a motion event.
bool startZoomReady{false};
bool canBlockZoom{false};
private:
void sequenceStart(InputEvent const& event);
void scrollMotion(InputEvent const& event);
void zoomStart();
void zoomMotion(InputEvent const& event);
void zoomEnd();
public:
explicit TouchInputHandler(InputContext* inputContext);
~TouchInputHandler() override = default;
bool handleImpl(InputEvent const& event) override;
void onUnblock() override;
};
| 1,357
|
C++
|
.h
| 41
| 29.585366
| 65
| 0.730415
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,030
|
HandRecognition.h
|
xournalpp_xournalpp/src/core/gui/inputdevices/HandRecognition.h
|
/*
* Xournal++
*
* Helper class for Touch specific fixes
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gdk/gdk.h> // for GdkDevice
#include <glib.h> // for gint64
#include <gtk/gtk.h> // for GtkWidget
#include "InputEvents.h" // for InputDeviceClass
class Settings;
class TouchDisableInterface;
class InputContext;
class HandRecognition {
public:
HandRecognition(GtkWidget* widget, InputContext* inputContext, Settings* settings);
virtual ~HandRecognition();
public:
/**
* Reload settings
*/
void reload();
/**
* An event from a device occurred
*/
void event(InputDeviceClass device);
/**
* Unblock the touchscreen immediately
*/
void unblock();
private:
/**
* Called after the timeout
*
* @return true to call again
*/
static bool enableTimeout(HandRecognition* self);
/**
* There was a pen event, restart the timer
*/
void penEvent();
/**
* Enable touchscreen
*/
void enableTouch();
/**
* Disable touchscreen
*/
void disableTouch();
private:
/**
* If touch disabling is enabled
*/
bool enabled = false;
/**
* true if touch is enabled, false if disabled
*/
bool touchState = true;
/**
* When the pen last was seen
*/
gint64 lastPenAction = -1;
/**
* Timeout in ms
*/
int disableTimeout = 500;
/**
* True if an X11 session is running
*/
bool x11Session = false;
/**
* Implementation for touch disabling
*/
TouchDisableInterface* touchImpl = nullptr;
/**
* InputContext
*/
InputContext* inputContext;
/**
* Settings
*/
Settings* settings = nullptr;
};
| 1,855
|
C++
|
.h
| 88
| 16.477273
| 87
| 0.623927
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,031
|
MouseInputHandler.h
|
xournalpp_xournalpp/src/core/gui/inputdevices/MouseInputHandler.h
|
/*
* Xournal++
*
* [Header description]
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <glib.h> // for guint
#include "PenInputHandler.h" // for PenInputHandler
class InputContext;
struct InputEvent;
class MouseInputHandler: public PenInputHandler {
private:
void setPressedState(InputEvent const& event);
public:
explicit MouseInputHandler(InputContext* inputContext);
~MouseInputHandler() override;
bool handleImpl(InputEvent const& event) override;
/**
* @brief Change the tool based on the settings and the Button pressed.
* In case
* - no button is pressed
* - or the settings for that button are "No Toolchange"
* - or the click is happening on top of a selection on the canvas
* this function ensures that the tool selected in the toolbar remains selected.
*
* @param event
* @return true if tool was changed successfully
* @return false if tool was not changed successfully
*/
bool changeTool(InputEvent const& event) override;
void onBlock() override;
private:
// see button member in https://docs.gtk.org/gdk3/struct.EventButton.html
static constexpr guint BUTTON_NONE = 0;
guint pressedButton = BUTTON_NONE;
};
| 1,319
|
C++
|
.h
| 41
| 28.390244
| 84
| 0.723186
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,032
|
InputUtils.h
|
xournalpp_xournalpp/src/core/gui/inputdevices/InputUtils.h
|
/**
* Xournal++
*
* Part of the customizable toolbars
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
* @brief Helper functions in use in the different InputHandlers as for example StylusInputHandler.h
*/
#pragma once
#include "control/settings/SettingsEnums.h"
// forward declaration to avoid cyclic dependencies
class ToolHandler;
class Settings;
class InputUtils {
public:
/**
* @brief Change the active tool based on the pressed button and its corresponding settings.
* In case the current tool is already selected nothing is done.
*
* @param toolHandler the toolHandler containing the tools
* @param settings settings storing the information for the buttons
* @param button the button pressed
* @return true if the tool was changed as a result of the function.
* @return false if the tool was not changed as it already was pointing to the correct tool.
*/
static bool applyButton(ToolHandler* toolHandler, Settings* settings, Button button);
/**
* @brief Check whether touch Drawing is disallowed and warn user about this
* Warn the user in case all of the following are true:
* 1. Disable Drawing for this device is set for Touchscreen
* 2. Tool - don't change is set for Touchscreen
* 3. current Tool in the toolbar is a Drawing tool (i.e. Pen/Highlighter/Eraser)
* As this results in xournalpp just using the currently selected tool to draw
* which might be surprising to users. Hence it's logged as warning.
*
* @param toolHandler the toolHandler containing the tools
* @param settings settings storing the information for the buttons
* @return true all above conditions are met
* @return false any of the above conditions is false
*/
static bool touchDrawingDisallowed(ToolHandler* toolHandler, Settings* settings);
};
| 1,925
|
C++
|
.h
| 45
| 38.644444
| 100
| 0.737067
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,033
|
DeviceId.h
|
xournalpp_xournalpp/src/core/gui/inputdevices/DeviceId.h
|
/*
* Xournal++
*
* Device identifier
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <gdk/gdk.h>
struct DeviceId {
constexpr DeviceId() = default;
explicit DeviceId(const GdkDevice* id);
void reset(const GdkDevice* id = nullptr);
explicit operator bool() const;
bool operator==(const DeviceId& o) const;
bool operator!=(const DeviceId& o) const;
private:
const void* id = nullptr;
bool trackpointOrTouchpad = false;
};
| 540
|
C++
|
.h
| 23
| 20.565217
| 46
| 0.702335
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,034
|
StylusInputHandler.h
|
xournalpp_xournalpp/src/core/gui/inputdevices/StylusInputHandler.h
|
/*
* Xournal++
*
* [Header description]
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include "PenInputHandler.h" // for PenInputHandler
class InputContext;
struct InputEvent;
class StylusInputHandler: public PenInputHandler {
public:
explicit StylusInputHandler(InputContext* inputContext);
~StylusInputHandler() override;
bool handleImpl(InputEvent const& event) override;
/**
* @brief Change the tool based on the settings and the Button pressed.
* In case no button is pressed or the settings for that button are "No Toolchange" this function ensures that the
* tool selected in the toolbar remains selected.
*
* @param event
* @return true if tool was changed successfully
* @return false if tool was not changed successfully
*/
bool changeTool(InputEvent const& event) override;
private:
/**
* How many events since hitting the screen with the stylus are still left to be ignored before actually starting
* the action. Set according to the user's setting on every button-1-press-event. Will be evaluated and then
* decreased by one (down to -1) on every button-1-press-event and motion-event. Set to -1 on button-1-release.\n
* If >0: Ignore the (button-1-press- or motion-) event\n
* If 0: Start the action (on the next button-1-press- or motion-event)\n
* If -1: Stylus not touching or action already started, handle the event normally
*/
int eventsToIgnore = -1;
void setPressedState(InputEvent const& event);
};
| 1,618
|
C++
|
.h
| 41
| 35.439024
| 118
| 0.72594
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,035
|
PenInputHandler.h
|
xournalpp_xournalpp/src/core/gui/inputdevices/PenInputHandler.h
|
/*
* Xournal++
*
* [Header description]
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include "gui/inputdevices/InputEvents.h" // for InputEvent
#include "util/Point.h"
#include "AbstractInputHandler.h" // for AbstractInputHandler
class InputContext;
class PositionInputData;
class XojPageView;
enum class PressureMode { NO_PRESSURE, DEVICE_PRESSURE, INFERRED_PRESSURE };
class PenInputHandler: public AbstractInputHandler {
protected:
/**
* Whether the current device class has a device with button 1 in pressed state
*/
bool deviceClassPressed = false;
/**
* modifier variables storing whether button 2 and 3 are pressed
*/
bool modifier2 = false;
bool modifier3 = false;
/**
* Reference to the last event
*/
InputEvent lastEvent{};
PressureMode pressureMode{PressureMode::NO_PRESSURE};
/**
* Last pressure measured or inferred.
*/
double lastPressure{0.0};
/**
* Reference to the last event actually hitting a page
*/
InputEvent lastHitEvent{};
/**
* Start position to reference scroll offset
*/
double scrollStartX = 0;
double scrollStartY = 0;
/**
* The offset to scroll in x-direction
*/
double scrollOffsetX = 0;
/**
* The offset to scroll in y-direction
*/
double scrollOffsetY = 0;
/**
* Flag whether pen is within the widget
*/
bool penInWidget = false;
/**
* Page a selection started at as we require this for motion updates
*/
XojPageView* sequenceStartPage = nullptr;
/**
* For tap event filtering. See Preferences->Drawing Area->Action on Tool Tap
*/
guint32 lastActionEndTimeStamp = 0U;
guint32 lastActionStartTimeStamp = 0U;
xoj::util::Point<double> sequenceStartPosition;
public:
explicit PenInputHandler(InputContext* inputContext);
~PenInputHandler() override;
protected:
/**
* Action for the start of an input
* @param event The event triggering the action
*/
bool actionStart(InputEvent const& event);
/**
* Action for motion during an input
* @param event The event triggering the action
*/
bool actionMotion(InputEvent const& event);
/**
* Action for a discrete input.
*/
void actionPerform(InputEvent const& event);
void actionLeaveWindow(InputEvent const& event);
void actionEnterWindow(InputEvent const& event);
/**
* Action for the end of an input
* @param event The event triggering the action
*/
bool actionEnd(InputEvent const& event);
/**
* @brief Change the tool according to the InputHandler and buttons pressed
*
* @param event some Inputevent
* @return true if tool was changed successfully
* @return false if tool was not changed successfully (currently only in TouchDrawingInputHandler)
*/
virtual bool changeTool(InputEvent const& event) = 0;
/**
* Do the scrolling with the hand tool
*/
void handleScrollEvent(InputEvent const& event);
/**
* Stores references to the provided event in lastEvent and lastHitEvent
* Use this to update the references for the last event.
* lastHitEvent will only be updated when the event did hit a page
* @param event
*/
void updateLastEvent(InputEvent const& event);
/**
* Estimate pressure based on pen speed using the previous event.
*
* @param pos The position of the current event
* @param page The page the event is relative to.
* @return The filtered pressure.
*/
double inferPressureValue(PositionInputData const& pos, XojPageView* page);
/**
* @brief Apply filters (e.g. minimum pressure, pressure inference, etc.) to
* the pressure at pos.
*
* @param pos The position of the current event
* @param page The page the event is relative to
* @return The filtered pressure.
*/
double filterPressure(PositionInputData const& pos, XojPageView* page);
/**
* @brief Detects whether the current input event is to be used as a selection
* rather than drawing
*/
bool isCurrentTapSelection(InputEvent const& event) const;
};
| 4,318
|
C++
|
.h
| 136
| 26.698529
| 102
| 0.687771
|
xournalpp/xournalpp
| 10,962
| 791
| 1,098
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.