Skip to content

Commit

Permalink
fixed selection issues, added website
Browse files Browse the repository at this point in the history
  • Loading branch information
unruhschuh committed Jan 25, 2016
1 parent f077480 commit 95f9a11
Show file tree
Hide file tree
Showing 80 changed files with 1,668 additions and 6 deletions.
19 changes: 17 additions & 2 deletions selection.cpp
Expand Up @@ -236,6 +236,11 @@ void Selection::paint(QPainter &painter, qreal zoom, QRectF region __attribute__
void Selection::transform(QTransform transform, int pageNum)
{
m_selectionPolygon = transform.map(m_selectionPolygon);

qreal sx = transform.m11();
qreal sy = transform.m22();
qreal s = (sx + sy) / 2.0;

for (int i = 0; i < m_strokes.size(); ++i)
{
m_strokes[i].points = transform.map(m_strokes[i].points);
Expand All @@ -245,10 +250,19 @@ void Selection::transform(QTransform transform, int pageNum)
*/
if (transform.determinant() != 1)
{
qreal s = (transform.m11() + transform.m22()) / 2.0;
m_strokes[i].penWidth = m_strokes[i].penWidth * s;
}
}
if (transform.determinant() != 1)
{
m_x_padding *= sx;
m_y_padding *= sy;
}
if (transform.isRotating())
{
m_x_padding = m_padding;
m_y_padding = m_padding;
}

m_angle = 0.0;

Expand All @@ -260,10 +274,11 @@ void Selection::finalize()
QRectF boundingRect;
for (int i = 0; i < m_strokes.size(); ++i)
{
boundingRect = boundingRect.united(m_strokes[i].points.boundingRect());
boundingRect = boundingRect.united(m_strokes[i].boundingRectSansPenWidth());
}

// boundingRect.adjust(-m_ad, -m_ad, m_ad, m_ad);
boundingRect.adjust(-m_x_padding, -m_y_padding, m_x_padding, m_y_padding);
m_selectionPolygon = QPolygonF(boundingRect);

setWidth(boundingRect.width());
Expand Down
4 changes: 4 additions & 0 deletions selection.h
Expand Up @@ -56,6 +56,10 @@ class Selection : public Page

qreal m_ad = 10;

qreal static constexpr m_padding = 10.0;
qreal m_y_padding = m_padding;
qreal m_x_padding = m_padding;

qreal m_angle = 0.0;

QPolygonF m_selectionPolygon;
Expand Down
15 changes: 13 additions & 2 deletions stroke.cpp
Expand Up @@ -55,8 +55,7 @@ void Stroke::paint(QPainter &painter, qreal zoom, bool last)

QRectF Stroke::boundingRect() const
{
QPolygonF tmpPoints = points;
QRectF bRect = tmpPoints.boundingRect();
QRectF bRect = boundingRectSansPenWidth();
qreal maxPressure = 0.0;
for (qreal p : pressures)
{
Expand All @@ -68,4 +67,16 @@ QRectF Stroke::boundingRect() const
qreal pad = maxPressure * penWidth;
return bRect.adjusted(-pad, -pad, pad, pad);
}

QRectF Stroke::boundingRectSansPenWidth() const
{
QPolygonF tmpPoints = points;
QRectF bRect = tmpPoints.boundingRect();
if (bRect.isNull())
{
qreal ad = 0.0001;
bRect.adjust(-ad,-ad,ad,ad);
}
return bRect;
}
}
1 change: 1 addition & 0 deletions stroke.h
Expand Up @@ -23,6 +23,7 @@ struct Stroke
void paint(QPainter &painter, qreal zoom, bool last = false);

QRectF boundingRect() const;
QRectF boundingRectSansPenWidth() const;

QPolygonF points;
QVector<qreal> pressures;
Expand Down
3 changes: 3 additions & 0 deletions website/.gitignore
@@ -0,0 +1,3 @@
_site
.sass-cache
.jekyll-metadata
114 changes: 114 additions & 0 deletions website/MrWriterDoc.adoc
@@ -0,0 +1,114 @@
---
layout: page
title: Documentation
permalink: /documentation/
weight: 3
---

:toc:
:toc-placement: preamble
:sectnums!:
:data-uri:
:experimental:

= MrWriter

MrWriter is a programm aimed at replacing pen and paper for note taking as well as blackboards in schools and universities.
You can find the newest version at http://github.com/unruhschuh/MrWriter[MrWriter]

== Users Guide

=== Tools

[[ToolsTable]]
.Tools
[cols="^.^1,<.^1,.^100", options="header"]
|===
| Icon
| Name
| Function

| image:../images/penIcon.png[width=32]
| Pen
| Draw freehand lines. If you use a Wacom style pen, lines change their width with respect to pressure.

| image:../images/rulerIcon.png[width=32]
| Ruler
| Draw straight lines.

| image:../images/circleIcon.png[width=32]
| Circle
| Draw circles starting at the center and defining the radius.

| image:../images/eraserIcon.png[width=32]
| Eraser
| Erase strokes. Hold the kbd:[Shift] key to erase freely.

| image:../images/selectIcon.png[width=32]
| Select
| Select strokes. If selected, strokes can be moved, copied, cut, and rotated.

| image:../images/handIcon.png[width=32]
| Hand
| Move the document around.
|===

== Keyboard shortcuts

MrWriter makes excessive use of keyboard shortcuts. The table <<ShortcutsTable>> shows a complete list of all shortcuts.

[[ShortcutsTable]]
.Shortcuts
[cols="1,1",options="header"]
|====================
| Action
| Shortcut

| Choose Pen
| kbd:[1]

| Choose Ruler
| kbd:[2]

| Choose Circle
| kbd:[3]

| Choose Eraser
| kbd:[4]

| Choose Select
| kbd:[5]

| Choose Hand
| kbd:[6]

| Erase freely
| hold kbd:[Shift] while using the Eraser Tool

| Save File
| kbd:[Ctrl] / kbd:[Cmd+s] on Windows and Linux

| Black
| kbd:[Q]

| Red
| kbd:[W]

| Green
| kbd:[E]

| Blue
| kbd:[R]

| Toggle Toolbar
| kbd:[T]

| Toggle Fullscreen
| kbd:[F]

| Toggle Statusbar
| kbd:[S]

| Pen Width
| kbd:[Ctrl]/kbd:[Cmd+1] through kbd:[5]
|====================
28 changes: 28 additions & 0 deletions website/_config.yml
@@ -0,0 +1,28 @@
# Welcome to Jekyll!
#
# This config file is meant for settings that affect your whole blog, values
# which you are expected to set up once and rarely need to edit after that.
# For technical reasons, this file is *NOT* reloaded automatically when you use
# 'jekyll serve'. If you change this file, please restart the server process.

# Site settings
title: MrWriter
author: Thomas Leitz
email: thomas.leitz@web.de
#description: > # this means to ignore newlines until "baseurl:"
# Write an awesome description for your new site here. You can edit this
# line in _config.yml. It will appear in your document head meta (for
# Google search results) and in your feed.xml site description.
baseurl: "" # the subpath of your site, e.g. /blog
url: "http://mrwriter.org" # the base hostname & protocol for your site
twitter_username: unruhschuh
github_username: unruhschuh

# Build settings
markdown: kramdown
#markdown: redcarpet
#redcarpet:
# extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "tables", "strikethrough", "superscript", "with_toc_data"]

gems:
- jekyll-asciidoc
38 changes: 38 additions & 0 deletions website/_includes/footer.html
@@ -0,0 +1,38 @@
<footer class="site-footer">

<div class="wrapper">

<h2 class="footer-heading">Contact</h2>

<div class="footer-col-wrapper">
<div class="footer-col footer-col-1">
<ul class="contact-list">
<li>{{ site.author }}</li>
<li><a href="mailto:{{ site.email }}">{{ site.email }}</a></li>
</ul>
</div>

<div class="footer-col footer-col-2">
<ul class="social-media-list">
{% if site.github_username %}
<li>
{% include icon-github.html username=site.github_username %}
</li>
{% endif %}

{% if site.twitter_username %}
<li>
{% include icon-twitter.html username=site.twitter_username %}
</li>
{% endif %}
</ul>
</div>

<div class="footer-col footer-col-3">
<p>{{ site.description }}</p>
</div>
</div>

</div>

</footer>
12 changes: 12 additions & 0 deletions website/_includes/head.html
@@ -0,0 +1,12 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title>
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">

<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}">
</head>
28 changes: 28 additions & 0 deletions website/_includes/header.html
@@ -0,0 +1,28 @@
<header class="site-header">

<div class="wrapper">

<a class="site-title" href="{{ site.baseurl }}/">{{ site.title }}</a>

<nav class="site-nav">
<a href="#" class="menu-icon">
<svg viewBox="0 0 18 15">
<path fill="#424242" d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.031C17.335,0,18,0.665,18,1.484L18,1.484z"/>
<path fill="#424242" d="M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0c0-0.82,0.665-1.484,1.484-1.484 h15.031C17.335,6.031,18,6.696,18,7.516L18,7.516z"/>
<path fill="#424242" d="M18,13.516C18,14.335,17.335,15,16.516,15H1.484C0.665,15,0,14.335,0,13.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.031C17.335,12.031,18,12.696,18,13.516L18,13.516z"/>
</svg>
</a>

<div class="trigger">
{% assign pages = site.pages | sort:"weight" %}
{% for my_page in pages %}
{% if my_page.title %}
<a class="page-link" href="{{ my_page.url | prepend: site.baseurl }}">{{ my_page.title }}</a>
{% endif %}
{% endfor %}
</div>
</nav>

</div>

</header>
1 change: 1 addition & 0 deletions website/_includes/icon-github.html
@@ -0,0 +1 @@
<a href="https://github.com/{{ include.username }}"><span class="icon icon--github">{% include icon-github.svg %}</span><span class="username">{{ include.username }}</span></a>
1 change: 1 addition & 0 deletions website/_includes/icon-github.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions website/_includes/icon-twitter.html
@@ -0,0 +1 @@
<a href="https://twitter.com/{{ include.username }}"><span class="icon icon--twitter">{% include icon-twitter.svg %}</span><span class="username">{{ include.username }}</span></a>
1 change: 1 addition & 0 deletions website/_includes/icon-twitter.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions website/_layouts/default.html
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>

{% include head.html %}

<body>

{% include header.html %}

<div class="page-content">
<div class="wrapper">
{{ content }}
</div>
</div>

{% include footer.html %}

</body>

</html>
14 changes: 14 additions & 0 deletions website/_layouts/page.html
@@ -0,0 +1,14 @@
---
layout: default
---
<article class="post">

<header class="post-header">
<h1 class="post-title">{{ page.title }}</h1>
</header>

<div class="post-content">
{{ content }}
</div>

</article>
15 changes: 15 additions & 0 deletions website/_layouts/post.html
@@ -0,0 +1,15 @@
---
layout: default
---
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">

<header class="post-header">
<h1 class="post-title" itemprop="name headline">{{ page.title }}</h1>
<p class="post-meta"><time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">{{ page.date | date: "%b %-d, %Y" }}</time>{% if page.author %} • <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">{{ page.author }}</span></span>{% endif %}</p>
</header>

<div class="post-content" itemprop="articleBody">
{{ content }}
</div>

</article>

0 comments on commit 95f9a11

Please sign in to comment.