Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI 3 #484

Merged
merged 107 commits into from
Oct 16, 2022
Merged

UI 3 #484

Show file tree
Hide file tree
Changes from 103 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
af8fd46
using a gtkstack to switch between devices, presets and the editor
sezanzeb Oct 2, 2022
27a0080
moving stop-injection and help to headerbar
sezanzeb Oct 2, 2022
4bb26d1
devices are a flowbox now
sezanzeb Oct 2, 2022
3a98c5a
mypy and margins
sezanzeb Oct 2, 2022
c38421b
fixed tests, changed editor margins
sezanzeb Oct 2, 2022
11fc053
switches to preset selection when clicking on a device
sezanzeb Oct 2, 2022
a5ade7f
split menu, breadcrumbs
sezanzeb Oct 2, 2022
0e5867d
preset selection
sezanzeb Oct 2, 2022
bf45fdb
title line wrapping
sezanzeb Oct 3, 2022
c119fa8
responsive device and preset list
sezanzeb Oct 3, 2022
e4cc6e9
comments
sezanzeb Oct 3, 2022
5ce4c55
fixed margin when scrolling
sezanzeb Oct 3, 2022
d957e14
fixed mapping type switch without a mapping
sezanzeb Oct 3, 2022
bda6736
copying a preset goes back to preset overview
sezanzeb Oct 3, 2022
8a10872
some rearranging of the editor page
sezanzeb Oct 3, 2022
4fcffcf
some rearranging of the editor page
sezanzeb Oct 3, 2022
1a332ec
spacings
sezanzeb Oct 3, 2022
73e10a9
button relief normal
sezanzeb Oct 3, 2022
fcb0e14
some css cleanup, border for mapping list
sezanzeb Oct 3, 2022
93b3038
icon size increased, only matters for other icon themes
sezanzeb Oct 3, 2022
4c2943d
typo
sezanzeb Oct 3, 2022
134ad1a
bold title on presets list page
sezanzeb Oct 3, 2022
752405b
simplified _on_gtk_row_selected, added spacing in combination editor …
sezanzeb Oct 3, 2022
9b44b70
put "Type:" in front of the ouptut switch
sezanzeb Oct 4, 2022
cb0378f
reverted entry spacing, improved window resizing in editor page
sezanzeb Oct 4, 2022
90434b0
removed width request from window
sezanzeb Oct 4, 2022
feeb7ef
adjusted spacings in analog axis editor
sezanzeb Oct 4, 2022
82ab155
rearranged graph
sezanzeb Oct 4, 2022
f141cc0
slider vertical height
sezanzeb Oct 4, 2022
d57f310
reduced margin top for the key/macro editor
sezanzeb Oct 4, 2022
597a8ed
moved advanced button down
sezanzeb Oct 4, 2022
ecb12ee
cleanup of default-widths
sezanzeb Oct 4, 2022
eb7725c
moving buttons up
sezanzeb Oct 4, 2022
7bebafc
rearranged input of editor
sezanzeb Oct 4, 2022
982be45
black
sezanzeb Oct 4, 2022
3e0b213
removed the no-mapping-error, updated docs since the advanced buttons…
sezanzeb Oct 4, 2022
fae3524
breadcrumbs class, increased margin
sezanzeb Oct 6, 2022
390b4cb
changed button order
sezanzeb Oct 6, 2022
9f510ef
modern gtk dialogs, dynamic dialog creation
sezanzeb Oct 8, 2022
511ab15
primary and secondary messages in dialog
sezanzeb Oct 8, 2022
c7fb0ce
comment for _on_user_confirm_request
sezanzeb Oct 8, 2022
6a2f883
cleaner
sezanzeb Oct 8, 2022
87cedfd
using double-quotes in messages
sezanzeb Oct 9, 2022
b562642
black
sezanzeb Oct 9, 2022
0e4ee67
split components.py
sezanzeb Oct 9, 2022
9b94df4
reviewdog
sezanzeb Oct 9, 2022
cdd8849
flowbox baseclasses
sezanzeb Oct 9, 2022
41ce6df
module docstrings, some more refactoring
sezanzeb Oct 9, 2022
5ad4f65
black
sezanzeb Oct 9, 2022
89a9d70
reviewdog
sezanzeb Oct 9, 2022
8a3c2ab
black
sezanzeb Oct 9, 2022
0b0f5af
fixed unittest
sezanzeb Oct 9, 2022
19ab0f3
fixed unittest
sezanzeb Oct 9, 2022
9f68b01
record button does nothing without a mapping
sezanzeb Oct 9, 2022
15e9122
RequireActiveMapping
sezanzeb Oct 9, 2022
bf49b0e
removed obsolete CodeEditor enable/disable logic
sezanzeb Oct 9, 2022
f6731ff
Stop Injection -> Stop
sezanzeb Oct 9, 2022
26eaee3
consistent opacities
sezanzeb Oct 9, 2022
47a2be6
black
sezanzeb Oct 9, 2022
e5a3e5f
changes on combination editor and labels of input-widgets
sezanzeb Oct 10, 2022
e637a9c
more advanced editor stuff
sezanzeb Oct 10, 2022
f5517e5
most test_components tests pass
sezanzeb Oct 10, 2022
f3ee984
flexible tearDown in ComponentBaseTest
sezanzeb Oct 10, 2022
bbb3361
extend docstring of ComponentBaseTest
sezanzeb Oct 10, 2022
2d17467
extend docstring of ComponentBaseTest
sezanzeb Oct 10, 2022
b1c2188
found a method of destroying all unreferenced widgets as well
sezanzeb Oct 11, 2022
e52a5ce
dsfakj
sezanzeb Oct 11, 2022
91d81c3
fixed test_draws_transform
sezanzeb Oct 11, 2022
f9dbbfc
cleanup after test_data
sezanzeb Oct 11, 2022
a239e9c
fixed a few tests
sezanzeb Oct 11, 2022
3ec9f94
fixed more tests
sezanzeb Oct 11, 2022
695ab4a
fixed test_cycling
sezanzeb Oct 11, 2022
003ce99
fixed opacity assertion
sezanzeb Oct 11, 2022
3fc4769
ctrl + n shortcut into UserInterface.shortcuts, removed accelerator
sezanzeb Oct 11, 2022
3af9b93
Merge branch 'beta' into ui-3
sezanzeb Oct 11, 2022
e4ce586
all tests passing
sezanzeb Oct 12, 2022
6f07cf7
some new tests
sezanzeb Oct 12, 2022
293e570
all tests written and passing
sezanzeb Oct 12, 2022
2e3c833
showing mapping conflict error, cleaned utils.py
sezanzeb Oct 12, 2022
4d8fc2c
updated badges, fixed test_show_status
sezanzeb Oct 12, 2022
347a4a1
updated coverage badge
sezanzeb Oct 12, 2022
6d9b637
update screenshots
sezanzeb Oct 12, 2022
4048dc4
review
sezanzeb Oct 13, 2022
d5551f9
reviewdog
sezanzeb Oct 13, 2022
9e1c5c2
comment gtk.main
sezanzeb Oct 13, 2022
9da3afb
black
sezanzeb Oct 13, 2022
7c5cdb9
updated usage.md
sezanzeb Oct 13, 2022
34bcc8d
updated known issues
sezanzeb Oct 13, 2022
f9246f8
changed screenshot
sezanzeb Oct 13, 2022
df75d2a
graph style
sezanzeb Oct 15, 2022
ec93dca
using theme colors for the graph
sezanzeb Oct 15, 2022
4948c51
removed commented line
sezanzeb Oct 15, 2022
e22d138
cleanup
sezanzeb Oct 15, 2022
0244981
cleanup
sezanzeb Oct 15, 2022
053dcf1
typo
sezanzeb Oct 15, 2022
cb28bad
typo
sezanzeb Oct 15, 2022
d597316
updated screenshot
sezanzeb Oct 15, 2022
7f0f03e
updated screenshot
sezanzeb Oct 15, 2022
959de35
updated screenshot and autocompletion position
sezanzeb Oct 15, 2022
644c809
updated screenshot
sezanzeb Oct 15, 2022
2492550
moved Colors to utils
sezanzeb Oct 15, 2022
b7cb845
PresetData uses MappingData, format_name, duplicate name formatting code
sezanzeb Oct 16, 2022
91ed3b8
mypy
sezanzeb Oct 16, 2022
5a6c106
message_classes -> message_data
sezanzeb Oct 16, 2022
75fd672
mypy
sezanzeb Oct 16, 2022
ed33553
get_bus_message
sezanzeb Oct 16, 2022
5d96d77
changed punctuation in output type message
sezanzeb Oct 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#### Known Issues (Beta Branch)

* Mapping relative axis to relative axis (mouse to mouse) is not possible
* Mapping relative axis to absolute axis (mouse to gamepad) is not possible
* Mapping absolute axis to absolute axis (gamepad to gamepad) is not possible

## Installation

Expand Down
2 changes: 1 addition & 1 deletion bin/input-remapper-gtk
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if __name__ == '__main__':
logger.debug('Using locale directory: {}'.format(LOCALE_DIR))

# import input-remapper stuff after setting the log verbosity
from inputremapper.gui.message_broker import MessageBroker, MessageType
from inputremapper.gui.messages.message_broker import MessageBroker, MessageType
from inputremapper.configs.system_mapping import system_mapping
from inputremapper.gui.data_manager import DataManager
from inputremapper.gui.user_interface import UserInterface
Expand Down
1,909 changes: 940 additions & 969 deletions data/input-remapper.glade

Large diffs are not rendered by default.

71 changes: 12 additions & 59 deletions data/style.css
Original file line number Diff line number Diff line change
@@ -1,63 +1,16 @@
row {
padding: 0;
}

.status_bar frame {
/* the status bar is ugly in elementary os otherwise */
border: 0px;
}

/* adds a bottom border for themes that don't add one in primary-toolbar
classes. Interestingly, those that do add a border ignore this separator,
which is perfect. */
.top_separator {
border: 0px; /* fixes light pixels on each end in arc-dark */
}

.table-header, .row-box {
padding: 2px;
}

.changed {
background: @selected_bg_color;
}

list entry {
border-radius: 4px;
border: 0px;
box-shadow: none;
}

list.basic-editor button:not(:focus) {
border-color: transparent;
background: transparent;
box-shadow: none;
}

list button {
border-color: transparent;
}

.invalid_input {
background-color: #ea9697;
}

.transparent {
background: transparent;
}

.code-editor-text-view > * {
border-radius: 2px;
}

.copyright {
font-size: 7pt;
}

.editor-key-list label {
padding: 11px;
}

.autocompletion label {
padding: 11px;
}
Expand All @@ -67,19 +20,19 @@ list button {
box-shadow: none;
}

.no-border {
border: 0px;
box-shadow: none;
}

.code-editor-text-view.multiline {
/* extra space between text editor and line numbers */
padding-left: 18px;
}

.no-v-padding{
.no-v-padding {
padding-top: 0;
padding-bottom: 0;
}

/* @theme_bg_color, @theme_fg_color */
.transformation-draw-area {
border: 1px solid @borders;
border-radius: 6px;
background: @theme_base_color;
}

/*
@theme_bg_color
@theme_selected_bg_color
@theme_base_color
*/
29 changes: 25 additions & 4 deletions inputremapper/configs/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,22 @@
from inputremapper.configs.system_mapping import system_mapping, DISABLE_NAME
from inputremapper.event_combination import EventCombination
from inputremapper.exceptions import MacroParsingError
from inputremapper.gui.message_broker import MessageType
from inputremapper.gui.messages.message_types import MessageType
from inputremapper.gui.gettext import _
from inputremapper.injection.macros.parse import is_this_a_macro, parse
from inputremapper.input_event import EventActions

# TODO: remove pydantic VERSION check as soon as we no longer support
# Ubuntu 20.04 and with it the ainchant pydantic 1.2
# Ubuntu 20.04 and with it the ancient pydantic 1.2

needs_workaround = pkg_resources.parse_version(
str(VERSION)
) < pkg_resources.parse_version("1.7.1")


EMPTY_MAPPING_NAME = _("Empty Mapping")


class KnownUinput(str, enum.Enum):
keyboard = "keyboard"
mouse = "mouse"
Expand All @@ -69,7 +73,7 @@ class Cfg(BaseConfig):
validate_assignment = True
use_enum_values = True
underscore_attrs_are_private = True
json_encoders = {EventCombination: lambda v: v.json_str()}
json_encoders = {EventCombination: lambda v: v.json_key()}


class ImmutableCfg(Cfg):
Expand Down Expand Up @@ -180,6 +184,23 @@ def copy(self: MappingModel, *args, **kwargs) -> MappingModel:
object.__setattr__(copy, "_combination_changed", self._combination_changed)
return copy

def format_name(self) -> str:
"""Get the custom-name or a readable representation of the combination."""
if self.name:
return self.name

if (
self.event_combination == EventCombination.empty_combination()
or self.event_combination is None
):
return EMPTY_MAPPING_NAME

return self.event_combination.beautify()

def has_input_defined(self) -> bool:
"""Whether this mapping defines an event-input."""
return self.event_combination != EventCombination.empty_combination()

def is_axis_mapping(self) -> bool:
"""whether this mapping specifies an output axis"""
return self.output_type == EV_ABS or self.output_type == EV_REL
Expand Down Expand Up @@ -266,7 +287,7 @@ def validate_symbol(cls, symbol):
if system_mapping.get(symbol) is not None:
return symbol
raise ValueError(
f"the output_symbol '{symbol}' is not a macro and not a valid keycode-name"
f'the output_symbol "{symbol}" is not a macro and not a valid keycode-name'
)

@validator("event_combination")
Expand Down
2 changes: 1 addition & 1 deletion inputremapper/configs/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _convert_to_individual_mappings():
if "mapping" in old_preset.keys():
for combination, symbol_target in old_preset["mapping"].items():
logger.info(
f"migrating from '{combination}: {symbol_target}' to mapping dict"
f'migrating from "{combination}: {symbol_target}" to mapping dict'
)
try:
combination = EventCombination.from_string(combination)
Expand Down
2 changes: 1 addition & 1 deletion inputremapper/configs/preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def save(self) -> None:
del d["event_combination"]
except KeyError:
pass
json_ready[combination.json_str()] = d
json_ready[combination.json_key()] = d

saved_mappings[combination] = mapping.copy()
saved_mappings[combination].remove_combination_changed_callback()
Expand Down
5 changes: 3 additions & 2 deletions inputremapper/event_combination.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ def get_permutations(self):

return permutations

def json_str(self) -> str:
return "+".join([event.json_str() for event in self])
def json_key(self) -> str:
"""Get a representation of the input that works as key in a json object."""
return "+".join([event.json_key() for event in self])

def beautify(self) -> str:
"""Get a human readable string representation."""
Expand Down
43 changes: 34 additions & 9 deletions inputremapper/gui/autocompletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@

from inputremapper.configs.mapping import MappingData
from inputremapper.configs.system_mapping import system_mapping
from inputremapper.gui.components import CodeEditor
from inputremapper.gui.message_broker import MessageBroker, MessageType, UInputsData
from inputremapper.gui.components.editor import CodeEditor
from inputremapper.gui.messages.message_broker import MessageBroker, MessageType
from inputremapper.gui.messages.message_classes import UInputsData
from inputremapper.gui.utils import debounce
from inputremapper.injection.macros.parse import (
FUNCTIONS,
Expand Down Expand Up @@ -293,19 +294,43 @@ def _scroll_to_row(self, row):
# to write code is possible), so here is a custom solution.
row_height = row.get_allocation().height

list_box_height = self.list_box.get_allocated_height()

if row:
y_offset = row.translate_coordinates(self.list_box, 0, 0)[1]
# get coordinate relative to the list_box,
# measured from the top of the selected row to the top of the list_box
row_y_position = row.translate_coordinates(self.list_box, 0, 0)[1]

# Depending on the theme, the y_offset will be > 0, even though it
# is the uppermost element, due to margins/paddings.
if row_y_position < row_height:
row_y_position = 0

# if the selected row sits lower than the second to last row,
# then scroll all the way down. otherwise it will only scroll down
# to the bottom edge of the selected-row, which might not actually be the
# bottom of the list-box due to paddings.
if row_y_position > list_box_height - row_height * 1.5:
# using a value that is too high doesn't hurt here.
row_y_position = list_box_height

# the visible height of the scrolled_window. not the content.
height = self.scrolled_window.get_max_content_height()

current_y_scroll = self.scrolled_window.get_vadjustment().get_value()

vadjustment = self.scrolled_window.get_vadjustment()

if y_offset > current_y_scroll + (height - row_height):
vadjustment.set_value(y_offset - (height - row_height))
# for the selected row to still be visible, its y_offset has to be
# at height - row_height. If the y_offset is higher than that, then
# the autocompletion needs to scroll down to make it visible again.
if row_y_position > current_y_scroll + (height - row_height):
value = row_y_position - (height - row_height)
vadjustment.set_value(value)

if y_offset < current_y_scroll:
# scroll up because the element is not visible anymore
vadjustment.set_value(y_offset)
if row_y_position < current_y_scroll:
# the selected element is not visiable, so we need to scroll up.
vadjustment.set_value(row_y_position)

def _get_text_iter_at_cursor(self):
"""Get Gtk.TextIter at the current text cursor location."""
Expand Down Expand Up @@ -341,7 +366,7 @@ def update(self, *_):
cursor.y += 12

if self.code_editor.gui.get_show_line_numbers():
cursor.x += 25
cursor.x += 48

self.set_pointing_to(cursor)

Expand Down
Empty file.