mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 20:45:59 +01:00
(feature): Began implementing radius scaling for rounded borders.
This commit is contained in:
parent
1a4e6e6a4b
commit
99bfad20b3
4 changed files with 60 additions and 19 deletions
|
@ -523,29 +523,60 @@ void CWindow::updateDynamicRules() {
|
|||
// it is assumed that the point is within the real window box (m_vRealPosition, m_vRealSize)
|
||||
// otherwise behaviour is undefined
|
||||
bool CWindow::isInCurvedCorner(double x, double y) {
|
||||
const uint8_t TOP_LEFT = 0;
|
||||
const uint8_t TOP_RIGHT = 1;
|
||||
const uint8_t BOTTOM_LEFT = 2;
|
||||
const uint8_t BOTTOM_RIGHT = 3;
|
||||
|
||||
|
||||
static auto* const ROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
||||
|
||||
static auto* const ROUNGING_SCALING_TOP_LEFT = &g_pConfigManager->getConfigValuePtr("decoration:rounding_scaling_top_left")->floatValue;
|
||||
static auto* const ROUNGING_SCALING_TOP_RIGHT = &g_pConfigManager->getConfigValuePtr("decoration:rounding_scaling_top_left")->floatValue;
|
||||
static auto* const ROUNGING_SCALING_BOTTOM_LEFT = &g_pConfigManager->getConfigValuePtr("decoration:rounding_scaling_top_left")->floatValue;
|
||||
static auto* const ROUNGING_SCALING_BOTTOM_RIGHT = &g_pConfigManager->getConfigValuePtr("decoration:rounding_scaling_top_left")->floatValue;
|
||||
|
||||
static auto* const BORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||
|
||||
if (BORDERSIZE >= ROUNDING || ROUNDING == 0)
|
||||
return false;
|
||||
static double const ROUNDING_INDEXED[4] = {
|
||||
*ROUNDING * *ROUNGING_SCALING_TOP_LEFT,
|
||||
*ROUNDING * *ROUNGING_SCALING_TOP_RIGHT,
|
||||
*ROUNDING * *ROUNGING_SCALING_BOTTOM_LEFT,
|
||||
*ROUNDING * *ROUNGING_SCALING_BOTTOM_RIGHT
|
||||
};
|
||||
|
||||
// (x0, y0), (x0, y1), ... are the center point of rounding at each corner
|
||||
double x0 = m_vRealPosition.vec().x + *ROUNDING;
|
||||
double y0 = m_vRealPosition.vec().y + *ROUNDING;
|
||||
double x1 = m_vRealPosition.vec().x + m_vRealSize.vec().x - *ROUNDING;
|
||||
double y1 = m_vRealPosition.vec().y + m_vRealSize.vec().y - *ROUNDING;
|
||||
double roundingCenterCoords[8] = {
|
||||
m_vRealPosition.vec().x + ROUNDING_INDEXED[TOP_LEFT],
|
||||
m_vRealPosition.vec().x + m_vRealSize.vec().x - ROUNDING_INDEXED[TOP_RIGHT],
|
||||
m_vRealPosition.vec().x + ROUNDING_INDEXED[BOTTOM_LEFT],
|
||||
m_vRealPosition.vec().x + m_vRealSize.vec().x - ROUNDING_INDEXED[BOTTOM_RIGHT],
|
||||
m_vRealPosition.vec().y + ROUNDING_INDEXED[TOP_LEFT],
|
||||
m_vRealPosition.vec().y + ROUNDING_INDEXED[TOP_RIGHT],
|
||||
m_vRealPosition.vec().y + m_vRealSize.vec().y + ROUNDING_INDEXED[BOTTOM_LEFT],
|
||||
m_vRealPosition.vec().y + m_vRealSize.vec().y + ROUNDING_INDEXED[BOTTOM_RIGHT]
|
||||
};
|
||||
|
||||
if (x < x0 && y < y0) {
|
||||
return Vector2D{x0, y0}.distance(Vector2D{x, y}) > (double)*ROUNDING;
|
||||
Vector2D roundingCenter[4] = {
|
||||
Vector2D(roundingCenterCoords[TOP_LEFT], roundingCenterCoords[TOP_LEFT+4]),
|
||||
Vector2D(roundingCenterCoords[TOP_RIGHT], roundingCenterCoords[TOP_RIGHT+4]),
|
||||
Vector2D(roundingCenterCoords[BOTTOM_RIGHT], roundingCenterCoords[BOTTOM_RIGHT+4]),
|
||||
Vector2D(roundingCenterCoords[BOTTOM_LEFT], roundingCenterCoords[BOTTOM_LEFT+4]),
|
||||
};
|
||||
|
||||
if (x < roundingCenter[TOP_LEFT].x && y < roundingCenter[TOP_LEFT].y) {
|
||||
return roundingCenter->distance(Vector2D(x,y)) > ROUNDING_INDEXED[TOP_LEFT];
|
||||
}
|
||||
if (x > x1 && y < y0) {
|
||||
return Vector2D{x1, y0}.distance(Vector2D{x, y}) > (double)*ROUNDING;
|
||||
|
||||
if (x > roundingCenter[TOP_RIGHT].x && y < roundingCenter[TOP_RIGHT].y) {
|
||||
return roundingCenter->distance(Vector2D(x,y)) > ROUNDING_INDEXED[TOP_RIGHT];
|
||||
}
|
||||
if (x < x0 && y > y1) {
|
||||
return Vector2D{x0, y1}.distance(Vector2D{x, y}) > (double)*ROUNDING;
|
||||
|
||||
if (x < roundingCenter[BOTTOM_LEFT].x && y > roundingCenter[BOTTOM_LEFT].y) {
|
||||
return roundingCenter->distance(Vector2D(x,y)) > ROUNDING_INDEXED[BOTTOM_LEFT];
|
||||
}
|
||||
if (x > x1 && y > y1) {
|
||||
return Vector2D{x1, y1}.distance(Vector2D{x, y}) > (double)*ROUNDING;
|
||||
|
||||
if (x > roundingCenter[BOTTOM_RIGHT].x && y > roundingCenter[BOTTOM_RIGHT].y) {
|
||||
return roundingCenter->distance(Vector2D(x,y)) > ROUNDING_INDEXED[BOTTOM_RIGHT];
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -110,6 +110,10 @@ void CConfigManager::setDefaultVars() {
|
|||
configValues["debug:manual_crash"].intValue = 0;
|
||||
|
||||
configValues["decoration:rounding"].intValue = 0;
|
||||
configValues["decoration:rounding_scaling_top_left"].floatValue = 1.0;
|
||||
configValues["decoration:rounding_scaling_top_right"].floatValue = 1.0;
|
||||
configValues["decoration:rounding_scaling_bottom_right"].floatValue = 1.0;
|
||||
configValues["decoration:rounding_scaling_bottom_left"].floatValue = 1.0;
|
||||
configValues["decoration:blur"].intValue = 1;
|
||||
configValues["decoration:blur_size"].intValue = 8;
|
||||
configValues["decoration:blur_passes"].intValue = 1;
|
||||
|
|
|
@ -1052,7 +1052,7 @@ void pushVert2D(float x, float y, float* arr, int& counter, wlr_box* box) {
|
|||
counter++;
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad, int round, int borderSize, float a) {
|
||||
void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad, int round_top_left, int round_top_right, int round_bottom_left, int round_bottom_right, int borderSize, float a) {
|
||||
RASSERT((box->width > 0 && box->height > 0), "Tried to render rect with width/height < 0!");
|
||||
RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!");
|
||||
|
||||
|
@ -1079,7 +1079,10 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad,
|
|||
box->width += 2 * scaledBorderSize;
|
||||
box->height += 2 * scaledBorderSize;
|
||||
|
||||
round += round == 0 ? 0 : scaledBorderSize;
|
||||
round_top_left += round_top_left == 0 ? 0 : scaledBorderSize;
|
||||
round_top_right += round_top_right == 0 ? 0 : scaledBorderSize;
|
||||
round_bottom_left += round_bottom_left == 0 ? 0 : scaledBorderSize;
|
||||
round_bottom_right += round_bottom_right == 0 ? 0 : scaledBorderSize;
|
||||
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, box, wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), 0,
|
||||
|
|
|
@ -21,7 +21,10 @@ class CShader {
|
|||
GLint bottomRight;
|
||||
GLint fullSize;
|
||||
GLint fullSizeUntransformed;
|
||||
GLint radius;
|
||||
GLint radius_top_left;
|
||||
GLint radius_top_right;
|
||||
GLint radius_bottom_left;
|
||||
GLint radius_bottom_tight;
|
||||
GLint primitiveMultisample;
|
||||
|
||||
GLint thick;
|
||||
|
|
Loading…
Reference in a new issue