浏览代码

code review

Laserlicht 1 年之前
父节点
当前提交
0c836e0797
共有 4 个文件被更改,包括 14 次插入6 次删除
  1. 9 4
      client/gui/CIntObject.cpp
  2. 1 0
      client/gui/CIntObject.h
  3. 1 1
      client/mainmenu/CHighScoreScreen.h
  4. 3 1
      client/mainmenu/CStatisticScreen.cpp

+ 9 - 4
client/gui/CIntObject.cpp

@@ -156,12 +156,17 @@ void CIntObject::setRedrawParent(bool on)
 }
 
 void CIntObject::fitToScreen(int borderWidth, bool propagate)
+{
+	fitToRect(Rect(Point(0, 0), GH.screenDimensions()), borderWidth, propagate);
+}
+
+void CIntObject::fitToRect(Rect rect, int borderWidth, bool propagate)
 {
 	Point newPos = pos.topLeft();
-	vstd::amax(newPos.x, borderWidth);
-	vstd::amax(newPos.y, borderWidth);
-	vstd::amin(newPos.x, GH.screenDimensions().x - borderWidth - pos.w);
-	vstd::amin(newPos.y, GH.screenDimensions().y - borderWidth - pos.h);
+	vstd::amax(newPos.x, rect.x + borderWidth);
+	vstd::amax(newPos.y, rect.y + borderWidth);
+	vstd::amin(newPos.x, rect.x + rect.w - borderWidth - pos.w);
+	vstd::amin(newPos.y, rect.y + rect.h - borderWidth - pos.h);
 	if (newPos != pos.topLeft())
 		moveTo(newPos, propagate);
 }

+ 1 - 0
client/gui/CIntObject.h

@@ -122,6 +122,7 @@ public:
 	const Rect & center(const Point &p, bool propagate = true);  //moves object so that point p will be in its center
 	const Rect & center(bool propagate = true); //centers when pos.w and pos.h are set, returns new position
 	void fitToScreen(int borderWidth, bool propagate = true); //moves window to fit into screen
+	void fitToRect(Rect rect, int borderWidth, bool propagate = true); //moves window to fit into rect
 	void moveBy(const Point &p, bool propagate = true);
 	void moveTo(const Point &p, bool propagate = true);//move this to new position, coordinates are absolute (0,0 is topleft screen corner)
 

+ 1 - 1
client/mainmenu/CHighScoreScreen.h

@@ -71,7 +71,7 @@ public:
 
 class CHighScoreInputScreen : public CWindowObject
 {
-	std::vector<std::shared_ptr<CIntObject>> texts;
+	std::vector<std::shared_ptr<CLabel>> texts;
 	std::shared_ptr<CHighScoreInput> input;
 	std::shared_ptr<TransparentFilledRectangle> background;
 	std::shared_ptr<VideoWidgetBase> videoPlayer;

+ 3 - 1
client/mainmenu/CStatisticScreen.cpp

@@ -497,6 +497,7 @@ LineChart::LineChart(Rect position, std::string title, TData data, TIcons icons,
 void LineChart::updateStatusBar(const Point & cursorPosition)
 {
 	statusBar->moveTo(cursorPosition + Point(-statusBar->pos.w / 2, 20));
+	statusBar->fitToRect(pos, 10);
 	Rect r(pos.x + chartArea.x, pos.y + chartArea.y, chartArea.w, chartArea.h);
 	statusBar->setEnabled(r.isInside(cursorPosition));
 	if(r.isInside(cursorPosition))
@@ -505,7 +506,8 @@ void LineChart::updateStatusBar(const Point & cursorPosition)
 		float y = maxVal - (maxVal / static_cast<float>(chartArea.h)) * (static_cast<float>(cursorPosition.y) - static_cast<float>(r.y));
 		statusBar->write(CGI->generaltexth->translate("core.genrltxt.64") + ": " + CStatisticScreen::getDay(x) + "   " + CGI->generaltexth->translate("vcmi.statisticWindow.value") + ": " + (static_cast<int>(y) > 0 ? std::to_string(static_cast<int>(y)) : std::to_string(y)));
 	}
-	GH.windows().totalRedraw();
+	setRedrawParent(true);
+	redraw();
 }
 
 void LineChart::mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance)