Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
P
PI2 View
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PI2
PI2 View
Commits
a0e73151
Commit
a0e73151
authored
Feb 01, 2019
by
Martin Kröning
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix inconsistent window resizing
parent
e22a8fbe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
pi2-view/include/MapApp.hpp
pi2-view/include/MapApp.hpp
+1
-0
pi2-view/src/MapApp.cpp
pi2-view/src/MapApp.cpp
+23
-6
No files found.
pi2-view/include/MapApp.hpp
View file @
a0e73151
...
@@ -48,6 +48,7 @@ private:
...
@@ -48,6 +48,7 @@ private:
void
onVehicleRowSelected
(
Gtk
::
ListBoxRow
*
row
);
void
onVehicleRowSelected
(
Gtk
::
ListBoxRow
*
row
);
void
refreshVehicleLabels
(
const
DrawableVehicle
&
vehicle
);
void
refreshVehicleLabels
(
const
DrawableVehicle
&
vehicle
);
void
refreshArea
(
int
x
,
int
y
,
int
width
,
int
height
);
void
refreshArea
(
int
x
,
int
y
,
int
width
,
int
height
);
void
resizeWindow
();
MapArea
mapArea
;
MapArea
mapArea
;
Gtk
::
Window
win
;
Gtk
::
Window
win
;
Gtk
::
ListBox
*
listBox
;
Gtk
::
ListBox
*
listBox
;
...
...
pi2-view/src/MapApp.cpp
View file @
a0e73151
...
@@ -88,8 +88,8 @@ void MapApp::onZoomEntryActivate() {
...
@@ -88,8 +88,8 @@ void MapApp::onZoomEntryActivate() {
std
::
istringstream
zoomBuffer
(
input
);
std
::
istringstream
zoomBuffer
(
input
);
zoomBuffer
>>
zoom
;
zoomBuffer
>>
zoom
;
mapArea
.
setScale
(
zoom
/
100
);
mapArea
.
setScale
(
zoom
/
100
);
// The window is only resizing, when called from the main thread like this:
Glib
::
signal_idle
().
connect_once
([
this
]()
{
mapArea
.
adaptSizeRequest
();
},
mapArea
.
adaptSizeRequest
(
);
Glib
::
PRIORITY_HIGH_IDLE
+
10
);
std
::
ostringstream
formatBuffer
;
std
::
ostringstream
formatBuffer
;
formatBuffer
<<
zoom
<<
'%'
;
formatBuffer
<<
zoom
<<
'%'
;
...
@@ -105,8 +105,8 @@ void MapApp::onZoomSelectionChanged() {
...
@@ -105,8 +105,8 @@ void MapApp::onZoomSelectionChanged() {
std
::
istringstream
zoomBuffer
(
selection
);
std
::
istringstream
zoomBuffer
(
selection
);
zoomBuffer
>>
zoom
;
zoomBuffer
>>
zoom
;
mapArea
.
setScale
(
zoom
/
100
);
mapArea
.
setScale
(
zoom
/
100
);
// The window is only resizing, when called from the main thread like this:
Glib
::
signal_idle
().
connect_once
([
this
]()
{
mapArea
.
adaptSizeRequest
();
},
mapArea
.
adaptSizeRequest
(
);
Glib
::
PRIORITY_HIGH_IDLE
+
10
);
}
}
}
}
...
@@ -160,6 +160,12 @@ void MapApp::setTimeLabel(const std::chrono::minutes minutes) {
...
@@ -160,6 +160,12 @@ void MapApp::setTimeLabel(const std::chrono::minutes minutes) {
void
MapApp
::
addJunction
(
const
double
x
,
const
double
y
)
{
void
MapApp
::
addJunction
(
const
double
x
,
const
double
y
)
{
auto
&
junction
=
junctions
.
emplace_back
(
x
,
y
);
auto
&
junction
=
junctions
.
emplace_back
(
x
,
y
);
Glib
::
signal_idle
().
connect_once
(
[
this
]()
{
mapArea
.
adaptSizeRequest
();
resizeWindow
();
},
Glib
::
PRIORITY_HIGH_IDLE
+
10
);
int
xRegion
,
yRegion
,
widthRegion
,
heightRegion
;
int
xRegion
,
yRegion
,
widthRegion
,
heightRegion
;
junction
.
getRegion
(
xRegion
,
yRegion
,
widthRegion
,
heightRegion
);
junction
.
getRegion
(
xRegion
,
yRegion
,
widthRegion
,
heightRegion
);
Glib
::
signal_idle
().
connect_once
(
Glib
::
signal_idle
().
connect_once
(
...
@@ -172,8 +178,12 @@ void MapApp::addJunction(const double x, const double y) {
...
@@ -172,8 +178,12 @@ void MapApp::addJunction(const double x, const double y) {
void
MapApp
::
addRoad
(
std
::
string
laneThereName
,
std
::
string
laneBackName
,
void
MapApp
::
addRoad
(
std
::
string
laneThereName
,
std
::
string
laneBackName
,
std
::
vector
<
std
::
valarray
<
double
>>
coordinates
)
{
std
::
vector
<
std
::
valarray
<
double
>>
coordinates
)
{
auto
&
road
=
roads
.
emplace_back
(
laneThereName
,
laneBackName
,
coordinates
);
auto
&
road
=
roads
.
emplace_back
(
laneThereName
,
laneBackName
,
coordinates
);
// The window is only resizing, when called from the main thread like this:
Glib
::
signal_idle
().
connect_once
(
[
this
]()
{
mapArea
.
adaptSizeRequest
();
mapArea
.
adaptSizeRequest
();
resizeWindow
();
},
Glib
::
PRIORITY_HIGH_IDLE
+
10
);
int
xRegion
,
yRegion
,
widthRegion
,
heightRegion
;
int
xRegion
,
yRegion
,
widthRegion
,
heightRegion
;
road
.
getRegion
(
xRegion
,
yRegion
,
widthRegion
,
heightRegion
);
road
.
getRegion
(
xRegion
,
yRegion
,
widthRegion
,
heightRegion
);
Glib
::
signal_idle
().
connect_once
(
Glib
::
signal_idle
().
connect_once
(
...
@@ -264,3 +274,10 @@ void MapApp::addOrReplaceVehicle(const std::string &vehicleName,
...
@@ -264,3 +274,10 @@ void MapApp::addOrReplaceVehicle(const std::string &vehicleName,
listBox
->
select_row
(
*
listBoxRow
);
listBox
->
select_row
(
*
listBoxRow
);
}
}
}
}
void
MapApp
::
resizeWindow
()
{
Gtk
::
Requisition
minimumSize
,
naturalSize
;
win
.
get_preferred_size
(
minimumSize
,
naturalSize
);
win
.
resize
(
static_cast
<
int
>
(
naturalSize
.
width
),
static_cast
<
int
>
(
naturalSize
.
height
));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment