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

Add missing UI functions for X11 Window class #580

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

fullset
Copy link
Collaborator

@fullset fullset commented Nov 21, 2019

Closes #459

@ihhub
I've added 3 methods to UiWindowX11 class. I've made them similar to drawPoint() method.
Also, I've slightly changed drawPoint() method to draw the cross(x).

Review please as you'll have a time.

@fullset fullset added improvement Upgrade existing feature gui Graphical User Interface related issue. labels Nov 21, 2019
Copy link
Owner

@ihhub ihhub left a 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 Show resolved Hide resolved
}

for ( size_t i = 0u; i < _lines.size(); ++i ) {
const Point2d & start = std::get<0>( _lines[i] );
Copy link
Owner

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.

Copy link
Owner

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.

Copy link
Owner

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).

Copy link
Collaborator Author

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.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@ihhub
Copy link
Owner

ihhub commented Dec 20, 2019

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
Copy link
Owner

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?

Copy link
Collaborator Author

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?

Copy link
Owner

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.

Copy link
Collaborator Author

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.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me check...

Copy link
Owner

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;

?

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 );
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this variable const.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@fullset fullset force-pushed the issue-459 branch 2 times, most recently from 5cd6bab to 607fde4 Compare December 25, 2019 14:52
@ihhub ihhub marked this pull request as draft November 2, 2023 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gui Graphical User Interface related issue. improvement Upgrade existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add missing UI functions for X11 Window class
2 participants