-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add missing UI functions for X11 Window class #580
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @fullset, coud you please take a look into my comments and discuss with me proposed ideas?
src/ui/x11/x11_ui.cpp
Outdated
} | ||
|
||
for ( size_t i = 0u; i < _lines.size(); ++i ) { | ||
const Point2d & start = std::get<0>( _lines[i] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking to combine the code with /src/ui/win/win_ui.h
file where we use structures to store data instead of tuples. Reading such code is very difficult so we might need to use the same idea in this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move structures from win_ui.h
file into src/ui/ui.h
. The only thing missing is we need an integer value instead of 3 uint8_t values for color.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do the same as it's done for Win32: just calculate RGB value during drawing (add a function at the top of the file to do such).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it sounds good. I'll do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Hi @fullset let's finish this pull request :) |
@@ -26,7 +30,64 @@ class UiWindowX11 : public UiWindow | |||
uint32_t _width; | |||
uint32_t _height; | |||
|
|||
std::vector< std::pair<Point2d, uint32_t> > _point; | |||
struct PointToDraw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @fullset could we move these identical structures in a common location as src/ui/ui.h file to avoid code duplication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I see, there are 2 structures PointToDraw
and LineToDraw
which are almost identical in x11
and win_ui
. And there are no problem to combine them.
But EllipseToDraw
structures in x11
and win_ui
have different semantics. In win_ui
we specify top, left, right and bottom coordinates but it x11
we specify top, left coordinates and width and height. I could make common constructor of 4 doubles but I'm not sure that it's right decision. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's stick to one design which should have top-left coordinate and width with height. For Windows during drawing we could easily find right and bottom values by adding width and height.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @ihhub.
It looks like I've broken windows building by my last changes but I can't find the reason because I haven't windows PC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me check...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you put structures back in ui/ui.h but don't declare these variables:
std::vector<PointToDraw> _point;
std::vector<LineToDraw> _lines;
std::vector<EllipseToDraw> _ellipses;
?
src/ui/x11/x11_ui.cpp
Outdated
void UiWindowX11::drawEllipse( const Point2d & center, double xRadius, double yRadius, const PaintColor & color ) | ||
{ | ||
// XDrawArc needs x and y coordinates of the upper-left corner of the bounding rectangle but not the center of the ellipse. | ||
Point2d position( center.x - xRadius, center.y - yRadius ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this variable const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
5cd6bab
to
607fde4
Compare
Closes #459
@ihhub
I've added 3 methods to
UiWindowX11
class. I've made them similar todrawPoint()
method.Also, I've slightly changed
drawPoint()
method to draw the cross(x).Review please as you'll have a time.